From 093c3eed6e6d993e521deca3ee2fb606d7d70605 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Sun, 10 Dec 2023 03:31:05 -0800 Subject: [PATCH] Fix plane when nested mobs merge with weeds --- code/datums/components/weed_food.dm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/code/datums/components/weed_food.dm b/code/datums/components/weed_food.dm index 648478aa6140..296808fe5721 100644 --- a/code/datums/components/weed_food.dm +++ b/code/datums/components/weed_food.dm @@ -50,6 +50,8 @@ var/turf/parent_turf /// The obj that our parent is buckled to and we have registered a signal var/obj/parent_buckle + /// A nest our parent is buckled to and we have registered a signal + var/obj/structure/bed/nest/parent_nest /// The weeds that we are merging/merged with var/obj/effect/alien/weeds/absorbing_weeds /// The overlay image when merged @@ -78,6 +80,7 @@ QDEL_NULL(weed_appearance) parent_mob = null parent_turf = null + parent_buckle = null /datum/component/weed_food/RegisterWithParent() RegisterSignal(parent_mob, COMSIG_MOVABLE_MOVED, PROC_REF(on_move)) @@ -100,6 +103,8 @@ UnregisterSignal(parent_turf, COMSIG_WEEDNODE_GROWTH) if(parent_buckle) UnregisterSignal(parent_buckle, COSMIG_OBJ_AFTER_BUCKLE) + if(parent_nest) + UnregisterSignal(parent_nest, COMSIG_PARENT_QDELETING) /// SIGNAL_HANDLER for COMSIG_MOVABLE_MOVED /datum/component/weed_food/proc/on_move() @@ -160,6 +165,15 @@ unmerge_with_weeds() return +/// SIGNAL_HANDLER for COMSIG_PARENT_QDELETING of nest +/datum/component/weed_food/proc/on_nest_deletion() + SIGNAL_HANDLER + + if(merged) + parent_mob.plane = FLOOR_PLANE + UnregisterSignal(parent_nest, COMSIG_PARENT_QDELETING) + parent_nest = null + /** * Try to start the process to turn into weeds * Returns TRUE if started successfully @@ -243,6 +257,10 @@ parent_buckle = parent_mob.buckled RegisterSignal(parent_mob.buckled, COSMIG_OBJ_AFTER_BUCKLE, PROC_REF(on_after_buckle)) return FALSE + else + parent_nest = parent_mob.buckled + RegisterSignal(parent_nest, COMSIG_PARENT_QDELETING, PROC_REF(on_nest_deletion)) + if(parent_buckle) UnregisterSignal(parent_buckle, COSMIG_OBJ_AFTER_BUCKLE) parent_buckle = null @@ -263,7 +281,8 @@ 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 + if(!parent_nest) + parent_mob.plane = FLOOR_PLANE parent_mob.remove_from_all_mob_huds() if(!weed_appearance) // Make a new sprite if we aren't re-merging @@ -289,6 +308,10 @@ UnregisterSignal(absorbing_weeds, COMSIG_PARENT_QDELETING) absorbing_weeds = null + if(parent_nest) + UnregisterSignal(parent_nest, COMSIG_PARENT_QDELETING) + parent_nest = null + REMOVE_TRAIT(parent_mob, TRAIT_MERGED_WITH_WEEDS, XENO_WEED_TRAIT) parent_mob.anchored = FALSE parent_mob.mouse_opacity = MOUSE_OPACITY_ICON