Refactors move procs to support multitle objects (#59658)

Enter(), Entered(), Exit() and Exited() all passed the old loc forward, but everything except a single a case cared about the direction of the movement more than about the specific source.
Since moving multi-tile objects will have multiple sources of movement but a single direction, this change makes it easier to track their movement.

Cleaned up a lot of code around and made proc inputs compatible.

I'll add opacity support for multi-tile objects in a different PR after this is merged, as this has grown large enough and I don't want to compromise the reviewability.

Tested this locally and as expected it didn't impair movement nor produced any runtimes.
This commit is contained in:
Rohesie
2021-06-20 14:55:37 -07:00
committed by GitHub
parent 3f244b211d
commit e03cd1aada
83 changed files with 350 additions and 301 deletions
+7 -5
View File
@@ -39,16 +39,16 @@
else
RegisterSignal(get_turf(target), COMSIG_ATOM_ENTERED, .proc/on_entered)
/datum/element/caltrop/proc/on_entered(atom/caltrop, atom/movable/AM)
/datum/element/caltrop/proc/on_entered(datum/source, atom/movable/arrived, direction)
SIGNAL_HANDLER
if(!prob(probability))
return
if(!ishuman(AM))
if(!ishuman(arrived))
return
var/mob/living/carbon/human/H = AM
var/mob/living/carbon/human/H = arrived
if(HAS_TRAIT(H, TRAIT_PIERCEIMMUNE))
return
@@ -84,8 +84,10 @@
if(!(flags & CALTROP_SILENT) && !H.has_status_effect(/datum/status_effect/caltropped))
H.apply_status_effect(/datum/status_effect/caltropped)
H.visible_message(span_danger("[H] steps on [caltrop]."), \
span_userdanger("You step on [caltrop]!"))
H.visible_message(
span_danger("[H] steps on [source]."),
span_userdanger("You step on [source]!")
)
H.apply_damage(damage, BRUTE, picked_def_zone, wound_bonus = CANT_WOUND)
H.Paralyze(60)
+17 -11
View File
@@ -11,26 +11,32 @@
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/on_target_move)
var/atom/movable/movable_target = target
if(isturf(movable_target.loc))
var/turf/turf_loc = movable_target.loc
if(!isturf(movable_target.loc))
return
for(var/turf/turf_loc as anything in movable_target.locs)
turf_loc.add_opacity_source(target)
/datum/element/light_blocking/Detach(atom/movable/target)
/datum/element/light_blocking/Detach(datum/target)
. = ..()
UnregisterSignal(target, list(COMSIG_MOVABLE_MOVED))
var/atom/movable/movable_target = target
if(isturf(movable_target.loc))
var/turf/turf_loc = movable_target.loc
if(!isturf(movable_target.loc))
return
for(var/turf/turf_loc as anything in movable_target.locs)
turf_loc.remove_opacity_source(target)
///Updates old and new turf loc opacities.
/datum/element/light_blocking/proc/on_target_move(atom/movable/source, atom/OldLoc, Dir, Forced = FALSE)
/datum/element/light_blocking/proc/on_target_move(atom/movable/source, atom/old_loc, dir, forced, list/old_locs)
SIGNAL_HANDLER
if(isturf(OldLoc))
var/turf/old_turf = OldLoc
old_turf.remove_opacity_source(source)
if(isturf(old_loc))
if(old_locs)
for(var/turf/old_turf as anything in old_locs)
old_turf.remove_opacity_source(source)
else
var/turf/old_turf = old_loc
old_turf.remove_opacity_source(source)
if(isturf(source.loc))
var/turf/new_turf = source.loc
new_turf.add_opacity_source(source)
for(var/turf/new_turf as anything in source.locs)
new_turf.add_opacity_source(source)