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:
Fluffy
2024-12-26 14:26:32 +00:00
committed by GitHub
parent a904e1d435
commit df014f9bc0
108 changed files with 860 additions and 485 deletions
+16 -16
View File
@@ -15,32 +15,32 @@
. = ..()
AddComponent(/datum/component/base_name, name)
/obj/item/evidencebag/MouseDrop(var/obj/item/I as obj)
if (!ishuman(usr))
/obj/item/evidencebag/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
var/mob/living/carbon/human/human_user = user
var/obj/item/I = over
if(!istype(human_user) || !istype(I))
return
var/mob/living/carbon/human/user = usr
if (!(user.l_hand == src || user.r_hand == src))
if (!(human_user.l_hand == src || human_user.r_hand == src))
return //bag must be in your hands to use
if (isturf(I.loc))
if (!user.Adjacent(I))
if (!human_user.Adjacent(I))
return
else
//If it isn't on the floor. Do some checks to see if it's in our hands or a box. Otherwise give up.
if(istype(I.loc,/obj/item/storage)) //in a container.
var/sdepth = I.storage_depth(user)
var/sdepth = I.storage_depth(human_user)
if (sdepth == -1 || sdepth > 1)
return //too deeply nested to access
var/obj/item/storage/U = I.loc
user.client.screen -= I
human_user.client.screen -= I
U.contents.Remove(I)
else if(user.l_hand == I) //in a hand
user.drop_l_hand()
else if(user.r_hand == I) //in a hand
user.drop_r_hand()
else if(human_user.l_hand == I) //in a hand
human_user.drop_l_hand()
else if(human_user.r_hand == I) //in a hand
human_user.drop_r_hand()
else
return
@@ -48,18 +48,18 @@
return
if(istype(I, /obj/item/evidencebag))
to_chat(user, SPAN_NOTICE("You find putting a plastic bag in another plastic bag to be slightly absurd and think better of it."))
to_chat(human_user, SPAN_NOTICE("You find putting a plastic bag in another plastic bag to be slightly absurd and think better of it."))
return
if(I.w_class > 3)
to_chat(user, SPAN_NOTICE("[I] won't fit in [src]."))
to_chat(human_user, SPAN_NOTICE("[I] won't fit in [src]."))
return
if(contents.len)
to_chat(user, SPAN_NOTICE("[src] already has something inside it."))
to_chat(human_user, SPAN_NOTICE("[src] already has something inside it."))
return
user.visible_message("<b>[user]</b> puts \the [I] into \the [src].", SPAN_NOTICE("You put \the [I] inside \the [src]."),\
human_user.visible_message("<b>[human_user]</b> puts \the [I] into \the [src].", SPAN_NOTICE("You put \the [I] inside \the [src]."),\
"You hear a rustle as someone puts something into a plastic bag.")
store_item(I)
@@ -189,10 +189,10 @@
return FALSE
. = ..()
/obj/item/forensics/sample_kit/MouseDrop(atom/over)
/obj/item/forensics/sample_kit/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
var/mob/M = loc
if(ismob(M) && (M.get_active_hand() == src || M.get_inactive_hand() == src))
afterattack(over, usr, TRUE)
afterattack(over, user, TRUE)
/obj/item/forensics/sample_kit/powder
name = "fingerprint powder"