From dec01b62e30aa2b4848aee4651eb5d1a802f3b73 Mon Sep 17 00:00:00 2001 From: SteelSlayer Date: Fri, 3 Sep 2021 08:47:30 -0500 Subject: [PATCH] robot move refactor --- .../modules/mob/living/silicon/robot/robot.dm | 59 ++++--------------- .../mob/living/silicon/robot/robot_modules.dm | 37 ++++++++++++ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 21d9e75db90..5748775558a 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -1147,55 +1147,18 @@ GLOBAL_LIST_INIT(robot_verbs_default, list( cell = null qdel(src) -#define BORG_CAMERA_BUFFER 30 -/mob/living/silicon/robot/Move(a, b, flag) - var/oldLoc = src.loc +#define BORG_CAMERA_BUFFER 3 SECONDS + +/mob/living/silicon/robot/Move(atom/newloc, direct, movetime) + var/oldLoc = loc . = ..() - if(.) - if(src.camera) - if(!updating) - updating = 1 - spawn(BORG_CAMERA_BUFFER) - if(camera && oldLoc != src.loc) - GLOB.cameranet.updatePortableCamera(src.camera) - updating = 0 - if(module) - if(module.type == /obj/item/robot_module/janitor) - var/turf/tile = loc - if(stat != DEAD && isturf(tile)) - var/floor_only = TRUE - for(var/A in tile) - if(istype(A, /obj/effect)) - var/obj/effect/E = A - if(E.is_cleanable()) - var/obj/effect/decal/cleanable/blood/B = E - if(istype(B) && B.off_floor) - floor_only = FALSE - else - qdel(E) - else if(istype(A, /obj/item)) - var/obj/item/cleaned_item = A - cleaned_item.clean_blood() - else if(istype(A, /mob/living/carbon/human)) - 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() - to_chat(cleaned_human, "[src] cleans your face!") - if(floor_only) - tile.clean_blood() - return + if(. && !updating && camera) + updating = TRUE + spawn(BORG_CAMERA_BUFFER) + if(camera && oldLoc != loc) + GLOB.cameranet.updatePortableCamera(camera) + updating = FALSE + #undef BORG_CAMERA_BUFFER /mob/living/silicon/robot/proc/self_destruct() diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index 8554068dce8..8a43a2a011e 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -447,6 +447,43 @@ /obj/item/extinguisher/mini ) +/obj/item/robot_module/janitor/Initialize(mapload) + . = ..() + var/mob/living/silicon/robot/R = loc + RegisterSignal(R, COMSIG_MOVABLE_MOVED, .proc/on_cyborg_move) + +/** + * Proc called after the janitor cyborg has moved, in order to clean atoms at it's new location. + * + * Arguments: + * * mob/living/silicon/robot/R - The cyborg who moved. + */ +/obj/item/robot_module/janitor/proc/on_cyborg_move(mob/living/silicon/robot/R) + SIGNAL_HANDLER + + if(R.stat == DEAD || !isturf(R.loc)) + return + var/turf/tile = R.loc + for(var/A in tile) + if(iseffect(A)) + var/obj/effect/E = A + if(!E.is_cleanable()) + continue + var/obj/effect/decal/cleanable/blood/B = E + if(istype(B) && B.off_floor) + tile.clean_blood() + else + qdel(E) + else if(isitem(A)) + var/obj/item/I = A + I.clean_blood() + else if(ishuman(A)) + var/mob/living/carbon/human/cleaned_human = A + if(!cleaned_human.lying) + continue + cleaned_human.clean_blood() + to_chat(cleaned_human, "[src] cleans your face!") + /obj/item/reagent_containers/spray/cyborg_lube name = "Lube spray" list_reagents = list("lube" = 250)