[MIRROR] Standardizes attack chain signal returns and fixes a tk bug (#1409)

* Standardizes attack chain signal returns and fixes a tk bug (#54475)

The attack chain is a bit of a mess, and the introduction of signals hasn't helped in simplifying it.

In order to take a step into untangling this, I re-ordered the attack signals to no longer be by source type and instead to be grouped more modularly, as they are all members of the attack chain and function similarly. They all share the trait of potentially ending the attack chain via a return, but had several different names for it. I joined it into one.

Additionally, fixed a tk bug reported by @ Timberpoes by adding a signal return check at the base of /mob/proc/RangedAttack

Lastly, removed the async call of /datum/mutation/human/telekinesis/proc/on_ranged_attack, which was added as a lazy patch to appease the linter complaining about a sleep on a signal handler (namely in /obj/singularity/attack_tk). Fixed the problem using timers.

Also cleaned some code here and there.

* Standardizes attack chain signal returns and fixes a tk bug

Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
SkyratBot
2020-10-21 07:39:32 +02:00
committed by GitHub
co-authored by Rohesie
parent fcad7bb4c2
commit 6ecaa9a994
45 changed files with 327 additions and 198 deletions
@@ -71,7 +71,7 @@
"<span class='notice'>You start to insert the [inserted_item.name] into \the [parent].</span>")
INVOKE_ASYNC(src, .proc/insert_item, inserted_item, user)
return COMPONENT_ITEM_NO_ATTACK
return COMPONENT_CANCEL_ATTACK_CHAIN
/** Begins the process of attempting to remove the stored item.
*
@@ -93,7 +93,7 @@
"<span class='notice'>You start to rip into \the [parent].</span>")
INVOKE_ASYNC(src, .proc/begin_remove_item, user)
return COMPONENT_ITEM_NO_ATTACK
return COMPONENT_CANCEL_ATTACK_CHAIN
/** Inserts the item into the food, after a do_after.
*
+7 -5
View File
@@ -195,7 +195,7 @@
if(!isitem(O) || !click_gather || SEND_SIGNAL(O, COMSIG_CONTAINS_STORAGE))
return FALSE
. = COMPONENT_NO_ATTACK
. = COMPONENT_CANCEL_ATTACK_CHAIN
if(locked)
to_chat(M, "<span class='warning'>[parent] seems to be locked!</span>")
return FALSE
@@ -771,6 +771,7 @@
return TRUE
return TRUE
/datum/component/storage/proc/on_attack_hand(datum/source, mob/user)
SIGNAL_HANDLER_DOES_SLEEP
@@ -780,7 +781,7 @@
if(user.active_storage == src && A.loc == user) //if you're already looking inside the storage item
user.active_storage.close(user)
close(user)
. = COMPONENT_NO_ATTACK_HAND
. = COMPONENT_CANCEL_ATTACK_CHAIN
return
if(rustle_sound)
@@ -789,23 +790,24 @@
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.l_store == A && !H.get_active_held_item()) //Prevents opening if it's in a pocket.
. = COMPONENT_NO_ATTACK_HAND
. = COMPONENT_CANCEL_ATTACK_CHAIN
H.put_in_hands(A)
H.l_store = null
return
if(H.r_store == A && !H.get_active_held_item())
. = COMPONENT_NO_ATTACK_HAND
. = COMPONENT_CANCEL_ATTACK_CHAIN
H.put_in_hands(A)
H.r_store = null
return
if(A.loc == user)
. = COMPONENT_NO_ATTACK_HAND
. = COMPONENT_CANCEL_ATTACK_CHAIN
if(locked)
to_chat(user, "<span class='warning'>[parent] seems to be locked!</span>")
else
show_to(user)
/datum/component/storage/proc/signal_on_pickup(datum/source, mob/user)
SIGNAL_HANDLER