Skip to content

Commit

Permalink
Fix plane when dead nested mobs merge with weeds (#5180)
Browse files Browse the repository at this point in the history
# About the pull request

This PR fixes an issue where dead nested mobs get set to the floor plane
thus disappearing under the wall. The signal for nest deletion is simply
so we can set the plane to the floor plane when dropped to the ground
since it is intentional weeded mobs get set to the floor plane so they
layer under more things.

# Explain why it's good for the game

Visually corrects mobs that died while in a nest.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/c1370f51-05c8-4f43-b938-0e1ff6bfce2f)

</details>


# Changelog
:cl: Drathek
fix: Fix dead nested mobs disappearing when weeded
/:cl:
  • Loading branch information
Drulikar authored Dec 14, 2023
1 parent df903aa commit 64b4959
Showing 1 changed file with 24 additions and 1 deletion.
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

0 comments on commit 64b4959

Please sign in to comment.