Morgue tray now updates properly (#23109)

* Morgue tray now updates properly

* Return of the guard clause

* Send signal upon ghosting/reentering

* Correct source for reenter corpse signal

* Signals split up, now works with DNR

---------

Co-authored-by: Adrer <adrermail@gmail.com>
This commit is contained in:
Adrer
2023-11-03 19:22:47 +00:00
committed by GitHub
co-authored by Adrer
parent 1526f3b3ed
commit aa7ea39f48
4 changed files with 40 additions and 21 deletions
+7
View File
@@ -459,6 +459,13 @@
#define COMSIG_LIVING_FIRE_TICK "living_fire_tick"
//sent from living mobs when they are ahealed
#define COMSIG_LIVING_AHEAL "living_aheal"
//sent from mobs when they exit their body as a ghost
#define COMSIG_LIVING_GHOSTIZED "ghostized"
//sent from mobs when they re-enter their body as a ghost
#define COMSIG_LIVING_REENTERED_BODY "reentered_body"
//sent from a mob when they set themselves to DNR
#define COMSIG_LIVING_SET_DNR "set_dnr"
//ALL OF THESE DO NOT TAKE INTO ACCOUNT WHETHER AMOUNT IS 0 OR LOWER AND ARE SENT REGARDLESS!
// none of these are called as of right now, as there is nothing listening for them.
+29 -9
View File
@@ -43,16 +43,33 @@
update_icon(update_state())
set_light(1, LIGHTING_MINIMUM_POWER)
/obj/structure/morgue/proc/update_state()
. = UPDATE_OVERLAYS
/obj/structure/morgue/proc/get_revivable(closing)
var/mob/living/M = locate() in contents
var/obj/structure/closet/body_bag/B = locate() in contents
if(!M)
M = locate() in B
if(!M)
return
if(closing)
RegisterSignal(M, COMSIG_LIVING_GHOSTIZED, PROC_REF(update_state))
RegisterSignal(M, COMSIG_LIVING_REENTERED_BODY, PROC_REF(update_state))
RegisterSignal(M, COMSIG_LIVING_SET_DNR, PROC_REF(update_state))
else
UnregisterSignal(M, COMSIG_LIVING_GHOSTIZED)
UnregisterSignal(M, COMSIG_LIVING_REENTERED_BODY)
UnregisterSignal(M, COMSIG_LIVING_SET_DNR)
/obj/structure/morgue/proc/update_state()
if(connected)
status = EXTENDED_TRAY
return
return update_icon(UPDATE_OVERLAYS)
if(!length(contents))
status = EMPTY_MORGUE
return
return update_icon(UPDATE_OVERLAYS)
var/mob/living/M = locate() in contents
var/obj/structure/closet/body_bag/B = locate() in contents
@@ -62,20 +79,21 @@
if(!M)
status = NOT_BODY
return
return update_icon(UPDATE_OVERLAYS)
var/mob/dead/observer/G = M.get_ghost()
if(M.mind && !M.mind.suicided && !M.suiciding)
if(M.client)
status = REVIVABLE
return
return update_icon(UPDATE_OVERLAYS)
if(G && G.client) //There is a ghost and it is connected to the server
status = GHOST_CONNECTED
return
return update_icon(UPDATE_OVERLAYS)
status = UNREVIVABLE
update_icon(UPDATE_OVERLAYS)
/obj/structure/morgue/update_overlays()
. = ..()
@@ -120,16 +138,18 @@
/obj/structure/morgue/attack_hand(mob/user as mob)
if(connected)
for(var/atom/movable/A in connected.loc)
if(!( A.anchored ))
if(!(A.anchored))
A.forceMove(src)
get_revivable(TRUE)
playsound(loc, open_sound, 50, 1)
QDEL_NULL(connected)
else
playsound(loc, open_sound, 50, 1)
get_revivable(FALSE)
connect()
add_fingerprint(user)
update_icon(update_state())
update_state()
return
/obj/structure/morgue/attackby(P as obj, mob/user as mob, params)
@@ -241,13 +241,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
// Respawnable
ghostize(1)
// If mob in morgue tray, update tray
var/obj/structure/morgue/Morgue = locate() in M.loc
if(istype(M.loc, /obj/structure/morgue))
Morgue = M.loc
if(Morgue)
Morgue.update_state()
// If mob in cryopod, despawn mob
if(P)
if(!P.control_computer)
@@ -303,11 +296,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
mind.current.key = key
var/obj/structure/morgue/Morgue = locate() in mind.current.loc
if(istype(mind.current.loc,/obj/structure/morgue))
Morgue = mind.current.loc
if(Morgue)
Morgue.update_state()
SEND_SIGNAL(mind.current, COMSIG_LIVING_REENTERED_BODY)
return 1
@@ -410,6 +399,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
can_reenter_corpse = FALSE
if(!QDELETED(mind.current)) // Could change while they're choosing
mind.current.remove_status_effect(STATUS_EFFECT_REVIVABLE)
SEND_SIGNAL(mind.current, COMSIG_LIVING_SET_DNR)
/mob/dead/observer/proc/dead_tele()
set category = "Ghost"
+1
View File
@@ -59,6 +59,7 @@
if(.)
if(ranged_ability && prev_client)
ranged_ability.remove_mousepointer(prev_client)
SEND_SIGNAL(src, COMSIG_LIVING_GHOSTIZED)
/mob/living/proc/OpenCraftingMenu()
return