Files
Bubberstation/code/datums/elements/cleaning.dm
Rohesie af65c90125 Mobility refactor: no more update_mobility() (#54183)
This is a pretty big change all around. The gist of it is that it moves the mobility_flags into traits or variables that can track the sources, and to which we can append code to react to the events, be it via signals or via on_event-like procs.

For example, MOBILITY_STAND could mean, depending on context, that the mob is either already standing or that it may be able to stand, and thus is lying down.

There was a lot of snowflakery and redefinitions on top of redefinitions, so this is bound to create bugs I'm willing to fix as I learn them.

The end-goal is for every living mob to use the same mobility system, for the traits to mean the same among them, and for no place to just mass-change settings without a way to trace it, such as with mobility_flags = NONE and mobility_flags = ALL

Fixes AIs being able to strip nearby people. They've lost their hands usage.
2020-10-09 16:04:30 -07:00

33 lines
948 B
Plaintext

/datum/element/cleaning/Attach(datum/target)
. = ..()
if(!ismovable(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/Clean)
/datum/element/cleaning/Detach(datum/target)
. = ..()
UnregisterSignal(target, COMSIG_MOVABLE_MOVED)
/datum/element/cleaning/proc/Clean(datum/source)
SIGNAL_HANDLER
var/atom/movable/AM = source
var/turf/tile = AM.loc
if(!isturf(tile))
return
tile.wash(CLEAN_SCRUB)
for(var/A in tile)
// Clean small items that are lying on the ground
if(isitem(A))
var/obj/item/I = A
if(I.w_class <= WEIGHT_CLASS_SMALL && !ismob(I.loc))
I.wash(CLEAN_SCRUB)
// Clean humans that are lying down
else if(ishuman(A))
var/mob/living/carbon/human/cleaned_human = A
if(cleaned_human.body_position == LYING_DOWN)
cleaned_human.wash(CLEAN_SCRUB)
cleaned_human.regenerate_icons()
to_chat(cleaned_human, "<span class='danger'>[AM] cleans your face!</span>")