From af1f13e114cd84be04c28aa9dbd5f434b1f5dad3 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 23 Dec 2017 09:35:34 -0500 Subject: [PATCH] Merge pull request #33306 from coiax/replace-clean-flag-with-component Replaces CLEAN_ON_MOVE_1 flag with cleaning component --- code/__DEFINES/flags.dm | 2 +- code/datums/components/cleaning.dm | 40 +++++++++++++++++++ code/game/atoms_movable.dm | 32 --------------- .../modules/mob/living/silicon/robot/robot.dm | 4 +- code/modules/vehicles/pimpin_ride.dm | 5 ++- tgstation.dme | 1 + 6 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 code/datums/components/cleaning.dm diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index 965ee51502..8b3e74b96e 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -22,7 +22,7 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define ON_BORDER_1 512 // item has priority to check when entering or leaving #define NOSLIP_1 1024 //prevents from slipping on wet floors, in space etc -#define CLEAN_ON_MOVE_1 2048 +#define _UNUSED_1 2048 // BLOCK_GAS_SMOKE_EFFECT_1 only used in masks at the moment. #define BLOCK_GAS_SMOKE_EFFECT_1 4096 // blocks the effect that chemical clouds would have on a mob --glasses, mask and helmets ONLY! diff --git a/code/datums/components/cleaning.dm b/code/datums/components/cleaning.dm new file mode 100644 index 0000000000..5d9d5992e2 --- /dev/null +++ b/code/datums/components/cleaning.dm @@ -0,0 +1,40 @@ +/datum/component/cleaning + dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS + +/datum/component/cleaning/Initialize() + if(!ismovableatom(parent)) + . = COMPONENT_INCOMPATIBLE + CRASH("[type] added to a [parent.type]") + RegisterSignal(list(COMSIG_MOVABLE_MOVED), .proc/Clean) + +/datum/component/cleaning/proc/Clean() + var/atom/movable/AM = parent + var/turf/tile = AM.loc + if(!isturf(tile)) + return + + tile.clean_blood() + for(var/A in tile) + if(is_cleanable(A)) + qdel(A) + else if(istype(A, /obj/item)) + var/obj/item/cleaned_item = A + cleaned_item.clean_blood() + else if(ishuman(A)) + var/mob/living/carbon/human/cleaned_human = A + if(cleaned_human.lying) + if(cleaned_human.head) + cleaned_human.head.clean_blood() + cleaned_human.update_inv_head() + if(cleaned_human.wear_suit) + cleaned_human.wear_suit.clean_blood() + cleaned_human.update_inv_wear_suit() + else if(cleaned_human.w_uniform) + cleaned_human.w_uniform.clean_blood() + cleaned_human.update_inv_w_uniform() + if(cleaned_human.shoes) + cleaned_human.shoes.clean_blood() + cleaned_human.update_inv_shoes() + cleaned_human.clean_blood() + cleaned_human.wash_cream() + to_chat(cleaned_human, "[AM] cleans your face!") diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index ddb768488a..08568660fd 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -132,44 +132,12 @@ if (orbiting) orbiting.Check() - if(flags_1 & CLEAN_ON_MOVE_1) - clean_on_move() - var/datum/proximity_monitor/proximity_monitor = src.proximity_monitor if(proximity_monitor) proximity_monitor.HandleMove() return 1 -/atom/movable/proc/clean_on_move() - var/turf/tile = loc - if(isturf(tile)) - tile.clean_blood() - for(var/A in tile) - if(is_cleanable(A)) - qdel(A) - else if(istype(A, /obj/item)) - var/obj/item/cleaned_item = A - cleaned_item.clean_blood() - else if(ishuman(A)) - var/mob/living/carbon/human/cleaned_human = A - if(cleaned_human.lying) - if(cleaned_human.head) - cleaned_human.head.clean_blood() - cleaned_human.update_inv_head() - if(cleaned_human.wear_suit) - cleaned_human.wear_suit.clean_blood() - cleaned_human.update_inv_wear_suit() - else if(cleaned_human.w_uniform) - cleaned_human.w_uniform.clean_blood() - cleaned_human.update_inv_w_uniform() - if(cleaned_human.shoes) - cleaned_human.shoes.clean_blood() - cleaned_human.update_inv_shoes() - cleaned_human.clean_blood() - cleaned_human.wash_cream() - to_chat(cleaned_human, "[src] cleans your face!") - /atom/movable/Destroy(force) var/inform_admins = (flags_2 & INFORM_ADMINS_ON_RELOCATE_2) var/stationloving = (flags_2 & STATIONLOVING_2) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index db10f4a81c..2788413ee9 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -1029,9 +1029,9 @@ status_flags &= ~CANPUSH if(module.clean_on_move) - flags_1 |= CLEAN_ON_MOVE_1 + AddComponent(/datum/component/cleaning) else - flags_1 &= ~CLEAN_ON_MOVE_1 + qdel(GetComponent(/datum/component/cleaning)) hat_offset = module.hat_offset diff --git a/code/modules/vehicles/pimpin_ride.dm b/code/modules/vehicles/pimpin_ride.dm index 3925b863ff..88524366a6 100644 --- a/code/modules/vehicles/pimpin_ride.dm +++ b/code/modules/vehicles/pimpin_ride.dm @@ -13,6 +13,9 @@ var/datum/component/riding/D = LoadComponent(/datum/component/riding) D.set_riding_offsets(RIDING_OFFSET_ALL, list(TEXT_NORTH = list(0, 4), TEXT_SOUTH = list(0, 7), TEXT_EAST = list(-12, 7), TEXT_WEST = list( 12, 7))) + if(floorbuffer) + AddComponent(/datum/component/cleaning) + /obj/vehicle/ridden/janicart/Destroy() if(mybag) qdel(mybag) @@ -47,7 +50,7 @@ floorbuffer = TRUE qdel(I) to_chat(user, "You upgrade [src] with the floor buffer.") - flags_1 |= CLEAN_ON_MOVE_1 + AddComponent(/datum/component/cleaning) update_icon() else return ..() diff --git a/tgstation.dme b/tgstation.dme index aadf2bf1b8..4b6ba31e8b 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -345,6 +345,7 @@ #include "code\datums\components\archaeology.dm" #include "code\datums\components\caltrop.dm" #include "code\datums\components\chasm.dm" +#include "code\datums\components\cleaning.dm" #include "code\datums\components\decal.dm" #include "code\datums\components\infective.dm" #include "code\datums\components\jousting.dm"