[MIRROR] Refactors step_action to pure signals (#2800)

* Refactors step_action to pure signals (#56238)

For historical purposes, there was a `step_action()` proc on shoes,
which were called on every step. It normally triggers a signal, which
some components, like squeaky clown shoes use to hook on behaviour. But
there were a few remaining procs that still used the old format; they
now use signals.

This thus saves a proc call on nearly all Move() calls by humans, unless
their shoes have special behaviour, and also enables non-shoes being
able to hook into stepping behaviour.

* Refactors step_action to pure signals

Co-authored-by: coiax <yellowbounder@gmail.com>
This commit is contained in:
SkyratBot
2021-01-20 03:39:57 +01:00
committed by GitHub
parent a93664bc35
commit 2d87d491ae
5 changed files with 20 additions and 11 deletions
+4 -2
View File
@@ -18,9 +18,11 @@
AddElement(/datum/element/update_icon_updates_onmob)
AddComponent(/datum/component/material_container, list(/datum/material/bananium), 100 * MINERAL_MATERIAL_AMOUNT, MATCONTAINER_EXAMINE|MATCONTAINER_ANY_INTENT|MATCONTAINER_SILENT, allowed_items=/obj/item/stack)
AddComponent(/datum/component/squeak, list('sound/items/bikehorn.ogg'=1), 75, falloff_exponent = 20)
RegisterSignal(src, COMSIG_SHOES_STEP_ACTION, .proc/on_step)
/obj/item/clothing/shoes/clown_shoes/banana_shoes/proc/on_step()
SIGNAL_HANDLER
/obj/item/clothing/shoes/clown_shoes/banana_shoes/step_action()
. = ..()
var/mob/wearer = loc
var/datum/component/material_container/bananium = GetComponent(/datum/component/material_container)
if(on && istype(wearer))
+7 -4
View File
@@ -1,6 +1,3 @@
/obj/item/clothing/shoes/proc/step_action() //this was made to rewrite clown shoes squeaking
SEND_SIGNAL(src, COMSIG_SHOES_STEP_ACTION)
/obj/item/clothing/shoes/sneakers/mime
name = "mime shoes"
icon_state = "mime"
@@ -78,7 +75,13 @@
desc = "A pair of orange rubber boots, designed to prevent slipping on wet surfaces while also drying them."
icon_state = "galoshes_dry"
/obj/item/clothing/shoes/galoshes/dry/step_action()
/obj/item/clothing/shoes/galoshes/dry/Initialize()
. = ..()
RegisterSignal(src, COMSIG_SHOES_STEP_ACTION, .proc/on_step)
/obj/item/clothing/shoes/galoshes/dry/proc/on_step()
SIGNAL_HANDLER
var/turf/open/t_loc = get_turf(src)
SEND_SIGNAL(t_loc, COMSIG_TURF_MAKE_DRY, TURF_WET_WATER, TRUE, INFINITY)
@@ -46,8 +46,7 @@
/mob/living/carbon/human/Move(NewLoc, direct)
. = ..()
if(shoes && body_position == STANDING_UP && loc == NewLoc && has_gravity(loc))
var/obj/item/clothing/shoes/S = shoes
S.step_action()
SEND_SIGNAL(shoes, COMSIG_SHOES_STEP_ACTION)
/mob/living/carbon/human/Process_Spacemove(movement_dir = 0) //Temporary laziness thing. Will change to handles by species reee.
if(dna.species.space_move(src))
@@ -315,6 +315,10 @@ Difficulty: Extremely Hard
var/change_turf = /turf/open/floor/plating/ice/icemoon
var/duration = 6 SECONDS
/obj/item/clothing/shoes/winterboots/ice_boots/ice_trail/Initialize()
. = ..()
RegisterSignal(src, COMSIG_SHOES_STEP_ACTION, .proc/on_step)
/obj/item/clothing/shoes/winterboots/ice_boots/ice_trail/equipped(mob/user, slot)
. = ..()
if(slot == ITEM_SLOT_FEET)
@@ -333,8 +337,9 @@ Difficulty: Extremely Hard
. = ..()
. += "<span class='notice'>The shoes are [on ? "enabled" : "disabled"].</span>"
/obj/item/clothing/shoes/winterboots/ice_boots/ice_trail/step_action()
. = ..()
/obj/item/clothing/shoes/winterboots/ice_boots/ice_trail/proc/on_step()
SIGNAL_HANDLER
var/turf/T = get_turf(loc)
if(!on || istype(T, /turf/closed) || istype(T, change_turf))
return