Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plane when dead nested mobs merge with weeds #5180

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion code/datums/components/weed_food.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading