From fb3edaff872942064d1403f53798d80e1fd688ae Mon Sep 17 00:00:00 2001 From: Drulikar Date: Tue, 21 Nov 2023 05:30:02 -0800 Subject: [PATCH 1/3] Resin doors not close on mob/living if they are merged with the weeds --- code/modules/cm_aliens/XenoStructures.dm | 26 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/code/modules/cm_aliens/XenoStructures.dm b/code/modules/cm_aliens/XenoStructures.dm index 73ced8099427..0a08153449a6 100644 --- a/code/modules/cm_aliens/XenoStructures.dm +++ b/code/modules/cm_aliens/XenoStructures.dm @@ -422,14 +422,22 @@ if(!isSwitchingStates && state == 1) Close() +/obj/structure/mineral_door/resin/proc/close_blocked() + for(var/turf/turf in locs) + for(var/mob/living/living_mob in turf) + var/datum/component/weed_food/weed = living_mob.GetComponent(/datum/component/weed_food) + if(!weed?.merged) + return TRUE + return FALSE + /obj/structure/mineral_door/resin/Close() if(!state || !loc) return //already closed //Can't close if someone is blocking it - for(var/turf/turf in locs) - if(locate(/mob/living) in turf) - spawn (close_delay) - Close() - return + if(close_blocked()) + spawn(close_delay) + Close() + return + isSwitchingStates = 1 playsound(loc, "alien_resin_move", 25) flick("[mineralType]closing",src) @@ -440,10 +448,10 @@ update_icon() isSwitchingStates = 0 layer = DOOR_CLOSED_LAYER - for(var/turf/turf in locs) - if(locate(/mob/living) in turf) - Open() - return + + if(close_blocked()) + Open() + return /obj/structure/mineral_door/resin/Dismantle(devastated = 0) qdel(src) From 593ed8cdb550f6c41662f24e054d43c5f75c7c3c Mon Sep 17 00:00:00 2001 From: Drulikar Date: Tue, 21 Nov 2023 07:06:05 -0800 Subject: [PATCH 2/3] Merged with weeds trait --- code/__DEFINES/traits.dm | 2 ++ code/datums/components/weed_food.dm | 2 ++ code/modules/cm_aliens/XenoStructures.dm | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index af8af22ca707..7f69a4acc4d6 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -147,6 +147,8 @@ #define TRAIT_IMMOBILIZED "immobilized" /// Apply this to make a mob not dense, and remove it when you want it to no longer make them undense, other sorces of undesity will still apply. Always define a unique source when adding a new instance of this! #define TRAIT_UNDENSE "undense" +/// Apply this to identify a mob as merged with weeds +#define TRAIT_MERGED_WITH_WEEDS "merged_with_weeds" // SPECIES TRAITS /// Knowledge of Yautja technology diff --git a/code/datums/components/weed_food.dm b/code/datums/components/weed_food.dm index 16be8665f55b..648478aa6140 100644 --- a/code/datums/components/weed_food.dm +++ b/code/datums/components/weed_food.dm @@ -260,6 +260,7 @@ merged = TRUE ADD_TRAIT(parent_mob, TRAIT_UNDENSE, XENO_WEED_TRAIT) + ADD_TRAIT(parent_mob, TRAIT_MERGED_WITH_WEEDS, XENO_WEED_TRAIT) parent_mob.anchored = TRUE parent_mob.mouse_opacity = MOUSE_OPACITY_TRANSPARENT parent_mob.plane = FLOOR_PLANE @@ -288,6 +289,7 @@ UnregisterSignal(absorbing_weeds, COMSIG_PARENT_QDELETING) absorbing_weeds = null + REMOVE_TRAIT(parent_mob, TRAIT_MERGED_WITH_WEEDS, XENO_WEED_TRAIT) parent_mob.anchored = FALSE parent_mob.mouse_opacity = MOUSE_OPACITY_ICON parent_mob.plane = GAME_PLANE diff --git a/code/modules/cm_aliens/XenoStructures.dm b/code/modules/cm_aliens/XenoStructures.dm index 0a08153449a6..3f08cb93d569 100644 --- a/code/modules/cm_aliens/XenoStructures.dm +++ b/code/modules/cm_aliens/XenoStructures.dm @@ -425,8 +425,7 @@ /obj/structure/mineral_door/resin/proc/close_blocked() for(var/turf/turf in locs) for(var/mob/living/living_mob in turf) - var/datum/component/weed_food/weed = living_mob.GetComponent(/datum/component/weed_food) - if(!weed?.merged) + if(!HAS_TRAIT(living_mob, TRAIT_MERGED_WITH_WEEDS)) return TRUE return FALSE From a0e508eaa5377647e4936f1eb6840d004408c37a Mon Sep 17 00:00:00 2001 From: Drulikar Date: Tue, 21 Nov 2023 07:06:42 -0800 Subject: [PATCH 3/3] Refactor spawns to unique timers: Fixes doors sometimes closing almost instantly. --- code/modules/cm_aliens/XenoStructures.dm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/code/modules/cm_aliens/XenoStructures.dm b/code/modules/cm_aliens/XenoStructures.dm index 3f08cb93d569..211f53a0ec7a 100644 --- a/code/modules/cm_aliens/XenoStructures.dm +++ b/code/modules/cm_aliens/XenoStructures.dm @@ -418,9 +418,7 @@ update_icon() isSwitchingStates = 0 layer = DOOR_OPEN_LAYER - spawn(close_delay) - if(!isSwitchingStates && state == 1) - Close() + addtimer(CALLBACK(src, PROC_REF(Close)), close_delay, TIMER_UNIQUE|TIMER_OVERRIDE) /obj/structure/mineral_door/resin/proc/close_blocked() for(var/turf/turf in locs) @@ -430,11 +428,11 @@ return FALSE /obj/structure/mineral_door/resin/Close() - if(!state || !loc) return //already closed + if(!state || !loc || isSwitchingStates) + return //already closed or changing //Can't close if someone is blocking it if(close_blocked()) - spawn(close_delay) - Close() + addtimer(CALLBACK(src, PROC_REF(Close)), close_delay, TIMER_UNIQUE|TIMER_OVERRIDE) return isSwitchingStates = 1