mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-21 20:11:04 +01:00
Mouse drop refactor (#20256)
Refactored mousedrag procs, added signals, some safeguards, did some cleanups around, renamed them to make a little more sense. Mostly put in line with TG's code. Fast clicking and releasing with a drag, depending on the grace period and how fast it is done, can be counted as clicks, to aid in combat scenarios where you spamclick.
This commit is contained in:
@@ -73,20 +73,21 @@ LINEN BINS
|
||||
..()
|
||||
add_fingerprint(user)
|
||||
|
||||
/obj/item/bedsheet/MouseDrop(mob/user)
|
||||
if((user && (!use_check(user))) && (user.contents.Find(src) || in_range(src, user)))
|
||||
if(!istype(user, /mob/living/carbon/slime) && !istype(user, /mob/living/simple_animal))
|
||||
if( !user.get_active_hand() ) //if active hand is empty
|
||||
/obj/item/bedsheet/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
|
||||
if((over && (!use_check(over))) && (over.contents.Find(src) || in_range(src, over)))
|
||||
if(!istype(over, /mob/living/carbon/slime) && !istype(over, /mob/living/simple_animal))
|
||||
var/mob/mouse_dropped_over = over
|
||||
if( !mouse_dropped_over.get_active_hand() ) //if active hand is empty
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/item/organ/external/temp = H.organs_by_name["r_hand"]
|
||||
if (H.hand)
|
||||
temp = H.organs_by_name["l_hand"]
|
||||
if(temp && !temp.is_usable())
|
||||
to_chat(user, SPAN_NOTICE("You try to move your [temp.name], but cannot!"))
|
||||
to_chat(H, SPAN_NOTICE("You try to move your [temp.name], but cannot!"))
|
||||
return
|
||||
|
||||
to_chat(user, SPAN_NOTICE("You pick up \the [src]."))
|
||||
user.put_in_hands(src)
|
||||
to_chat(H, SPAN_NOTICE("You pick up \the [src]."))
|
||||
H.put_in_hands(src)
|
||||
return
|
||||
|
||||
/obj/item/bedsheet/update_icon()
|
||||
|
||||
@@ -348,7 +348,7 @@
|
||||
if(opened)
|
||||
if(istype(attacking_item, /obj/item/grab))
|
||||
var/obj/item/grab/G = attacking_item
|
||||
MouseDrop_T(G.affecting, user) //act like they were dragged onto the closet
|
||||
mouse_drop_receive(G.affecting, user) //act like they were dragged onto the closet
|
||||
return 0
|
||||
if(attacking_item.isscrewdriver()) // Moved here so you can only detach linked teleporters when the door is open. So you can like unscrew and bolt the locker normally in most circumstances.
|
||||
if(linked_teleporter)
|
||||
@@ -516,8 +516,8 @@
|
||||
|
||||
. = opened
|
||||
|
||||
/obj/structure/closet/MouseDrop_T(atom/dropping, mob/user)
|
||||
var/atom/movable/O = dropping
|
||||
/obj/structure/closet/mouse_drop_receive(atom/dropped, mob/user, params)
|
||||
var/atom/movable/screen/O = dropped
|
||||
if(istype(O, /atom/movable/screen)) //fix for HUD elements making their way into the world -Pete
|
||||
return
|
||||
if(O.loc == user)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
if(opened)
|
||||
if(istype(attacking_item, /obj/item/grab))
|
||||
var/obj/item/grab/G = attacking_item
|
||||
MouseDrop_T(G.affecting, user) //act like they were dragged onto the closet
|
||||
mouse_drop_receive(G.affecting, user) //act like they were dragged onto the closet
|
||||
return 0
|
||||
if(!attacking_item.dropsafety())
|
||||
return
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
/obj/structure/closet/secure_closet/personal/attackby(obj/item/attacking_item, mob/user)
|
||||
if (opened)
|
||||
if (istype(attacking_item, /obj/item/grab))
|
||||
MouseDrop_T(attacking_item:affecting, user) //act like they were dragged onto the closet
|
||||
mouse_drop_receive(attacking_item:affecting, user) //act like they were dragged onto the closet
|
||||
if(attacking_item)
|
||||
user.drop_from_inventory(attacking_item,loc)
|
||||
else
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
visible_message(SPAN_DANGER("[user] strikes [src] with [attacking_item]."))
|
||||
check_health()
|
||||
|
||||
/obj/structure/closet/statue/MouseDrop_T()
|
||||
/obj/structure/closet/statue/mouse_drop_receive(atom/dropped, mob/user, params)
|
||||
return
|
||||
|
||||
/obj/structure/closet/statue/relaymove(mob/living/user, direction)
|
||||
|
||||
@@ -146,9 +146,9 @@
|
||||
pixel_y = -4
|
||||
|
||||
//For putting on tables
|
||||
/obj/structure/closet/crate/MouseDrop(atom/over_object)
|
||||
if (istype(over_object, /obj/structure/table))
|
||||
put_on_table(over_object, usr)
|
||||
/obj/structure/closet/crate/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
|
||||
if (istype(over, /obj/structure/table))
|
||||
put_on_table(over, user)
|
||||
return TRUE
|
||||
else
|
||||
return ..()
|
||||
|
||||
@@ -87,22 +87,22 @@
|
||||
return
|
||||
toggle_open(user)
|
||||
|
||||
/obj/structure/fireaxecabinet/MouseDrop(over_object, src_location, over_location)
|
||||
if(over_object == usr)
|
||||
var/mob/user = over_object
|
||||
if(!istype(user))
|
||||
/obj/structure/fireaxecabinet/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
|
||||
if(over == user)
|
||||
var/mob/mob_dropped_over = over
|
||||
if(!istype(mob_dropped_over))
|
||||
return
|
||||
|
||||
if(!open)
|
||||
to_chat(user, SPAN_NOTICE("\The [src] is closed."))
|
||||
to_chat(mob_dropped_over, SPAN_NOTICE("\The [src] is closed."))
|
||||
return
|
||||
|
||||
if(!fireaxe)
|
||||
to_chat(user, SPAN_NOTICE("\The [src] is empty."))
|
||||
to_chat(mob_dropped_over, SPAN_NOTICE("\The [src] is empty."))
|
||||
return
|
||||
|
||||
fireaxe.forceMove(get_turf(user))
|
||||
user.put_in_hands(fireaxe)
|
||||
fireaxe.forceMove(get_turf(mob_dropped_over))
|
||||
mob_dropped_over.put_in_hands(fireaxe)
|
||||
fireaxe = null
|
||||
update_icon()
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@
|
||||
//everything else is visible, so doesn't need to be mentioned
|
||||
|
||||
|
||||
/obj/structure/janitorialcart/MouseDrop_T(atom/dropping, mob/user)
|
||||
var/atom/movable/O = dropping
|
||||
/obj/structure/janitorialcart/mouse_drop_receive(atom/dropped, mob/user, params)
|
||||
var/atom/movable/O = dropped
|
||||
if (istype(O, /obj/structure/mopbucket) && !mybucket)
|
||||
O.forceMove(src)
|
||||
mybucket = O
|
||||
|
||||
@@ -166,8 +166,8 @@
|
||||
return
|
||||
return
|
||||
|
||||
/obj/structure/m_tray/MouseDrop_T(atom/dropping, mob/user)
|
||||
var/atom/movable/O = dropping
|
||||
/obj/structure/m_tray/mouse_drop_receive(atom/dropped, mob/user, params)
|
||||
var/atom/movable/O = dropped
|
||||
if(!istype(O, /atom/movable) || O.anchored || get_dist(user, src) > 1 || get_dist(user, O) > 1 || user.contents.Find(src) || user.contents.Find(O))
|
||||
return
|
||||
if(!ismob(O) && !istype(O, /obj/structure/closet/body_bag))
|
||||
|
||||
@@ -492,27 +492,27 @@
|
||||
update_icon()
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
|
||||
/obj/structure/bed/roller/MouseDrop(over_object, src_location, over_location)
|
||||
/obj/structure/bed/roller/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
|
||||
..()
|
||||
if(use_check(usr) || !Adjacent(usr))
|
||||
if(use_check(user) || !Adjacent(user))
|
||||
return
|
||||
if(!ishuman(usr) && (!isrobot(usr) || isDrone(usr))) //Humans and borgs can collapse, but not drones
|
||||
if(!ishuman(user) && (!isrobot(user) || isDrone(user))) //Humans and borgs can collapse, but not drones
|
||||
return
|
||||
if(over_object == buckled && beaker)
|
||||
if(over == buckled && beaker)
|
||||
if(iv_attached)
|
||||
detach_iv(buckled, usr)
|
||||
detach_iv(buckled, user)
|
||||
else
|
||||
attach_iv(buckled, usr)
|
||||
attach_iv(buckled, user)
|
||||
return
|
||||
if(usr != over_object && ishuman(over_object))
|
||||
if(user_buckle(over_object, usr))
|
||||
attach_iv(buckled, usr)
|
||||
if(user != over && ishuman(over))
|
||||
if(user_buckle(over, user))
|
||||
attach_iv(buckled, user)
|
||||
return
|
||||
if(beaker)
|
||||
remove_beaker(usr)
|
||||
remove_beaker(user)
|
||||
return
|
||||
if(vitals)
|
||||
remove_vitals(usr)
|
||||
remove_vitals(user)
|
||||
return
|
||||
if(buckled)
|
||||
return
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
if(buckled)
|
||||
buckled.set_dir(dir)
|
||||
|
||||
/obj/structure/bed/stool/chair/MouseDrop_T(atom/dropping, mob/user)
|
||||
if(dropping == user && user.loc != loc && (REVERSE_DIR(dir) & angle2dir(get_angle(src, user))))
|
||||
/obj/structure/bed/stool/chair/mouse_drop_receive(atom/dropped, mob/user, params)
|
||||
if(dropped == user && user.loc != loc && (REVERSE_DIR(dir) & angle2dir(get_angle(src, user))))
|
||||
user.visible_message("<b>[user]</b> starts climbing over the back of \the [src]...", SPAN_NOTICE("You start climbing over the back of \the [src]..."))
|
||||
if(do_after(user, 2 SECONDS, do_flags = DO_UNIQUE))
|
||||
user.forceMove(loc)
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
. = ..()
|
||||
can_buckle = FALSE // Some idiot decided can_buckle should be a list...
|
||||
|
||||
/obj/structure/bed/stool/MouseDrop(over_object, src_location, over_location)
|
||||
/obj/structure/bed/stool/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
|
||||
. = ..()
|
||||
if(over_object == usr && Adjacent(usr))
|
||||
if(!held_item || use_check_and_message(usr) || buckled || (anchored && padding_material)) // Make sure held_item = null if you don't want it to get picked up.
|
||||
if(over == user && Adjacent(user))
|
||||
if(!held_item || use_check_and_message(user) || buckled || (anchored && padding_material)) // Make sure held_item = null if you don't want it to get picked up.
|
||||
return
|
||||
usr.visible_message(SPAN_NOTICE("[usr] [withdraw_verb]s \the [src.name]."), SPAN_NOTICE("You [withdraw_verb] \the [src.name]."))
|
||||
user.visible_message(SPAN_NOTICE("[user] [withdraw_verb]s \the [src.name]."), SPAN_NOTICE("You [withdraw_verb] \the [src.name]."))
|
||||
var/obj/item/material/stool/S = new held_item(src.loc, material.name, padding_material?.name, painted_colour) // Handles all the material code so you don't have to.
|
||||
TransferComponents(S)
|
||||
if(material_alteration & MATERIAL_ALTERATION_COLOR) // For snowflakes like wood chairs.
|
||||
@@ -33,8 +33,8 @@
|
||||
S.blood_DNA |= blood_DNA // Transfer blood, if any.
|
||||
S.add_blood()
|
||||
S.dir = dir
|
||||
S.add_fingerprint(usr)
|
||||
usr.put_in_hands(S)
|
||||
S.add_fingerprint(user)
|
||||
user.put_in_hands(S)
|
||||
S.update_icon()
|
||||
qdel(src)
|
||||
|
||||
@@ -197,19 +197,20 @@
|
||||
/obj/item/material/stool/AltClick(mob/user)
|
||||
deploy(user)
|
||||
|
||||
/obj/item/material/stool/MouseDrop(mob/user)
|
||||
if((user && (!use_check(user))) && (user.contents.Find(src)) || in_range(src, user))
|
||||
if(!istype(user, /mob/living/carbon/slime) && !istype(user, /mob/living/simple_animal))
|
||||
if( !user.get_active_hand() ) //if active hand is empty
|
||||
/obj/item/material/stool/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
|
||||
if((over && (!use_check(over))) && (over.contents.Find(src)) || in_range(src, over))
|
||||
if(!istype(over, /mob/living/carbon/slime) && !istype(over, /mob/living/simple_animal))
|
||||
var/mob/mouse_dropped_over = over
|
||||
if( !mouse_dropped_over.get_active_hand() ) //if active hand is empty
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/item/organ/external/temp = H.organs_by_name["r_hand"]
|
||||
if (H.hand)
|
||||
temp = H.organs_by_name["l_hand"]
|
||||
if(temp && !temp.is_usable())
|
||||
to_chat(user, SPAN_NOTICE("You try to move your [temp.name], but cannot!"))
|
||||
to_chat(H, SPAN_NOTICE("You try to move your [temp.name], but cannot!"))
|
||||
return
|
||||
to_chat(user, SPAN_NOTICE("You pick up \the [src]."))
|
||||
user.put_in_hands(src)
|
||||
to_chat(H, SPAN_NOTICE("You pick up \the [src]."))
|
||||
H.put_in_hands(src)
|
||||
return
|
||||
|
||||
/obj/item/material/stool/apply_hit_effect(mob/living/target, mob/living/user, var/hit_zone)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
if(icon_state == initial(icon_state))
|
||||
icon_state = pick(icon_states(icon) - icon_state)
|
||||
|
||||
/obj/structure/trash_pile/MouseDrop_T(atom/dropping, mob/user)
|
||||
/obj/structure/trash_pile/mouse_drop_receive(atom/dropped, mob/user, params)
|
||||
if(!Adjacent(user) || use_check_and_message(user))
|
||||
return
|
||||
user.visible_message("<b>[user]</b> starts climbing into \the [src]...", SPAN_NOTICE("You start climbing into \the [src]..."))
|
||||
|
||||
@@ -790,8 +790,8 @@ ABSTRACT_TYPE(/obj/structure/stairs/urban/road_ramp)
|
||||
/obj/item/storage/toolbox/cash_register_storage
|
||||
name = "cash compartment"
|
||||
|
||||
/obj/structure/cash_register/MouseDrop(atom/over)
|
||||
if(usr == over && ishuman(over))
|
||||
/obj/structure/cash_register/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
|
||||
if(user == over && ishuman(over))
|
||||
var/mob/living/carbon/human/H = over
|
||||
storage_compartment.open(H)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user