mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 12:07:27 +01:00
Refactors light switches, igniter switches, mass driver buttons, and crematoriums? (#18683)
* A mixed refactor * Re add link code * tweak * well thats embarassing * Apply suggestions from code review Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com> Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>
This commit is contained in:
@@ -27,12 +27,12 @@
|
||||
dir = EAST
|
||||
var/obj/structure/m_tray/connected = null
|
||||
var/static/status_descriptors = list(
|
||||
EXTENDED_TRAY = "The tray is currently extended.",
|
||||
EMPTY_MORGUE = "The tray is currently empty.",
|
||||
UNREVIVABLE = "The tray contains an unviable body.",
|
||||
REVIVABLE = "The tray contains a body that is responsive to revival techniques.",
|
||||
NOT_BODY = "The tray contains something that is not a body.",
|
||||
GHOST_CONNECTED = "The tray contains a body that might be responsive."
|
||||
EXTENDED_TRAY = "The tray is currently extended.",
|
||||
EMPTY_MORGUE = "The tray is currently empty.",
|
||||
UNREVIVABLE = "The tray contains an unviable body.",
|
||||
REVIVABLE = "The tray contains a body that is responsive to revival techniques.",
|
||||
NOT_BODY = "The tray contains something that is not a body.",
|
||||
GHOST_CONNECTED = "The tray contains a body that might be responsive."
|
||||
)
|
||||
anchored = TRUE
|
||||
var/open_sound = 'sound/items/deconstruct.ogg'
|
||||
@@ -45,35 +45,46 @@
|
||||
|
||||
/obj/structure/morgue/proc/update_state()
|
||||
. = UPDATE_OVERLAYS
|
||||
|
||||
if(connected)
|
||||
status = EXTENDED_TRAY
|
||||
return
|
||||
|
||||
if(!length(contents))
|
||||
status = EMPTY_MORGUE
|
||||
return
|
||||
|
||||
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)
|
||||
status = NOT_BODY
|
||||
return
|
||||
|
||||
var/mob/dead/observer/G = M.get_ghost()
|
||||
|
||||
if(M.mind && !M.mind.suicided)
|
||||
if(M.client)
|
||||
status = REVIVABLE
|
||||
return
|
||||
|
||||
if(G && G.client) //There is a ghost and it is connected to the server
|
||||
status = GHOST_CONNECTED
|
||||
return
|
||||
|
||||
status = UNREVIVABLE
|
||||
|
||||
/obj/structure/morgue/update_overlays()
|
||||
. = ..()
|
||||
underlays.Cut()
|
||||
|
||||
if(!connected)
|
||||
. += "morgue_[status]"
|
||||
underlays += emissive_appearance(icon, "morgue_[status]")
|
||||
|
||||
if(name != initial(name))
|
||||
. += "morgue_label"
|
||||
|
||||
@@ -89,6 +100,7 @@
|
||||
ex_act(severity)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
if(2.0)
|
||||
if(prob(50))
|
||||
for(var/atom/movable/A in src)
|
||||
@@ -96,6 +108,7 @@
|
||||
ex_act(severity)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
if(3.0)
|
||||
if(prob(5))
|
||||
for(var/atom/movable/A in src)
|
||||
@@ -103,7 +116,6 @@
|
||||
ex_act(severity)
|
||||
qdel(src)
|
||||
return
|
||||
return
|
||||
|
||||
/obj/structure/morgue/attack_hand(mob/user as mob)
|
||||
if(connected)
|
||||
@@ -115,6 +127,7 @@
|
||||
else
|
||||
playsound(loc, open_sound, 50, 1)
|
||||
connect()
|
||||
|
||||
add_fingerprint(user)
|
||||
update_icon(update_state())
|
||||
return
|
||||
@@ -122,11 +135,14 @@
|
||||
/obj/structure/morgue/attackby(P as obj, mob/user as mob, params)
|
||||
if(istype(P, /obj/item/pen))
|
||||
var/t = rename_interactive(user, P)
|
||||
|
||||
if(isnull(t))
|
||||
return
|
||||
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
add_fingerprint(user)
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/structure/morgue/wirecutter_act(mob/user)
|
||||
@@ -136,25 +152,29 @@
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
return TRUE
|
||||
|
||||
/obj/structure/morgue/relaymove(mob/user as mob)
|
||||
/obj/structure/morgue/relaymove(mob/user)
|
||||
if(user.stat)
|
||||
return
|
||||
connect()
|
||||
|
||||
/obj/structure/morgue/proc/connect()
|
||||
connected = new /obj/structure/m_tray( loc )
|
||||
connected = new /obj/structure/m_tray(loc)
|
||||
step(connected, dir)
|
||||
connected.layer = BELOW_OBJ_LAYER
|
||||
var/turf/T = get_step(src, dir)
|
||||
|
||||
if(T.contents.Find(connected))
|
||||
connected.connected = src
|
||||
|
||||
for(var/atom/movable/A in src)
|
||||
if(A.move_resist != INFINITY)
|
||||
A.forceMove(connected.loc)
|
||||
|
||||
connected.icon_state = "morgue_tray"
|
||||
connected.dir = dir
|
||||
else
|
||||
QDEL_NULL(connected)
|
||||
return
|
||||
|
||||
QDEL_NULL(connected)
|
||||
|
||||
/obj/structure/morgue/Destroy()
|
||||
if(!connected)
|
||||
@@ -163,12 +183,15 @@
|
||||
A.forceMove(T)
|
||||
else
|
||||
QDEL_NULL(connected)
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/structure/morgue/container_resist(mob/living/L)
|
||||
var/mob/living/carbon/CM = L
|
||||
|
||||
if(!istype(CM))
|
||||
return
|
||||
|
||||
if(CM.stat || CM.restrained())
|
||||
return
|
||||
|
||||
@@ -195,7 +218,6 @@
|
||||
pass_flags = LETPASSTHROW
|
||||
max_integrity = 350
|
||||
|
||||
|
||||
/obj/structure/m_tray/attack_hand(mob/user as mob)
|
||||
if(connected)
|
||||
for(var/atom/movable/A as mob|obj in loc)
|
||||
@@ -206,36 +228,40 @@
|
||||
add_fingerprint(user)
|
||||
qdel(src)
|
||||
return
|
||||
return
|
||||
|
||||
/obj/structure/m_tray/MouseDrop_T(atom/movable/O, mob/living/user)
|
||||
if((!( istype(O, /atom/movable) ) || O.anchored || get_dist(user, src) > 1 || get_dist(user, O) > 1 || user.contents.Find(src) || user.contents.Find(O)))
|
||||
if((!(istype(O, /atom/movable)) || O.anchored || get_dist(user, src) > 1 || get_dist(user, O) > 1 || user.contents.Find(src) || user.contents.Find(O)))
|
||||
return
|
||||
|
||||
if(!ismob(O) && !istype(O, /obj/structure/closet/body_bag))
|
||||
return
|
||||
|
||||
if(!ismob(user) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
|
||||
return
|
||||
|
||||
O.forceMove(loc)
|
||||
|
||||
if(user != O)
|
||||
user.visible_message("<span class='warning'>[user] stuffs [O] into [src]!</span>")
|
||||
return
|
||||
|
||||
|
||||
/obj/structure/m_tray/Destroy()
|
||||
if(connected && connected.connected == src)
|
||||
connected.connected = null
|
||||
|
||||
connected = null
|
||||
return ..()
|
||||
|
||||
/obj/structure/tray/m_tray/CanPass(atom/movable/mover, turf/target, height=0)
|
||||
if(height == 0)
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(istype(mover) && mover.checkpass(PASSTABLE))
|
||||
return 1
|
||||
return TRUE
|
||||
if(locate(/obj/structure/table) in get_turf(mover))
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
return TRUE
|
||||
|
||||
return FALSE
|
||||
|
||||
/obj/structure/tray/m_tray/CanAStarPass(ID, dir, caller)
|
||||
. = !density
|
||||
@@ -247,6 +273,9 @@
|
||||
* Crematorium
|
||||
*/
|
||||
|
||||
GLOBAL_LIST_EMPTY(crematoriums)
|
||||
// These have so much copypasted code from the above that they should really be made into subtypes
|
||||
// Someone please I beg
|
||||
/obj/structure/crematorium
|
||||
name = "crematorium"
|
||||
desc = "A human incinerator. Works well on barbeque nights."
|
||||
@@ -262,16 +291,20 @@
|
||||
|
||||
/obj/structure/crematorium/Initialize(mapload)
|
||||
. = ..()
|
||||
GLOB.crematoriums += src
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
/obj/structure/crematorium/update_overlays()
|
||||
. = ..()
|
||||
if(connected)
|
||||
return
|
||||
|
||||
. += "crema_closed"
|
||||
|
||||
if(cremating)
|
||||
. += "crema_active"
|
||||
return
|
||||
|
||||
if(length(contents))
|
||||
. += "crema_full"
|
||||
|
||||
@@ -283,6 +316,7 @@
|
||||
ex_act(severity)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
if(2.0)
|
||||
if(prob(50))
|
||||
for(var/atom/movable/A in src)
|
||||
@@ -290,6 +324,7 @@
|
||||
ex_act(severity)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
if(3.0)
|
||||
if(prob(5))
|
||||
for(var/atom/movable/A in src)
|
||||
@@ -297,21 +332,24 @@
|
||||
ex_act(severity)
|
||||
qdel(src)
|
||||
return
|
||||
return
|
||||
|
||||
/obj/structure/crematorium/attack_hand(mob/user as mob)
|
||||
if(cremating)
|
||||
to_chat(usr, "<span class='warning'>It's locked.</span>")
|
||||
return
|
||||
|
||||
if(connected && !locked)
|
||||
for(var/atom/movable/A in connected.loc)
|
||||
if(!(A.anchored) && A.move_resist != INFINITY)
|
||||
A.forceMove(src)
|
||||
|
||||
playsound(loc, open_sound, 50, 1)
|
||||
QDEL_NULL(connected)
|
||||
|
||||
else if(!locked)
|
||||
playsound(loc, open_sound, 50, 1)
|
||||
connect()
|
||||
|
||||
add_fingerprint(user)
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
@@ -320,75 +358,92 @@
|
||||
rename_interactive(user, P)
|
||||
add_fingerprint(user)
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/structure/crematorium/relaymove(mob/user as mob)
|
||||
if(user.stat || locked)
|
||||
return
|
||||
|
||||
connect()
|
||||
|
||||
|
||||
/obj/structure/crematorium/proc/connect()
|
||||
connected = new /obj/structure/c_tray( loc )
|
||||
connected = new /obj/structure/c_tray(loc)
|
||||
step(connected, SOUTH)
|
||||
connected.layer = BELOW_OBJ_LAYER
|
||||
|
||||
var/turf/T = get_step(src, SOUTH)
|
||||
|
||||
if(T.contents.Find(connected))
|
||||
connected.connected = src
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
for(var/atom/movable/A in src)
|
||||
A.forceMove(connected.loc)
|
||||
|
||||
connected.icon_state = "crema_tray"
|
||||
else
|
||||
QDEL_NULL(connected)
|
||||
return
|
||||
|
||||
QDEL_NULL(connected)
|
||||
|
||||
/obj/structure/crematorium/proc/cremate(mob/user as mob)
|
||||
if(cremating)
|
||||
return //don't let you cremate something twice or w/e
|
||||
|
||||
if(contents.len <= 0)
|
||||
if(!length(contents))
|
||||
for(var/mob/M in viewers(src))
|
||||
M.show_message("<span class='warning'>You hear a hollow crackle.</span>", 1)
|
||||
return
|
||||
M.show_message("<span class='warning'>You hear a hollow crackle.</span>", EMOTE_VISIBLE)
|
||||
|
||||
else
|
||||
for(var/mob/M in viewers(src))
|
||||
M.show_message("<span class='warning'>You hear a roar as the crematorium activates.</span>", 1)
|
||||
return
|
||||
|
||||
cremating = TRUE
|
||||
locked = TRUE
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
for(var/mob/living/M in search_contents_for(/mob/living))
|
||||
if(QDELETED(M))
|
||||
continue
|
||||
if(M.stat!=2)
|
||||
M.emote("scream")
|
||||
if(istype(user))
|
||||
add_attack_logs(user, M, "Cremated")
|
||||
M.death(1)
|
||||
if(QDELETED(M))
|
||||
continue // Re-check for mobs that delete themselves on death
|
||||
M.ghostize()
|
||||
qdel(M)
|
||||
for(var/mob/M in viewers(src))
|
||||
M.show_message("<span class='warning'>You hear a roar as the crematorium activates.</span>", EMOTE_VISIBLE)
|
||||
|
||||
for(var/obj/O in contents) //obj instead of obj/item so that bodybags and ashes get destroyed. We dont want tons and tons of ash piling up
|
||||
qdel(O)
|
||||
cremating = TRUE
|
||||
locked = TRUE
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
for(var/mob/living/M in search_contents_for(/mob/living))
|
||||
if(QDELETED(M))
|
||||
continue
|
||||
|
||||
if(M.stat != DEAD)
|
||||
M.emote("scream")
|
||||
|
||||
if(istype(user))
|
||||
add_attack_logs(user, M, "Cremated")
|
||||
|
||||
M.death(TRUE)
|
||||
|
||||
if(QDELETED(M))
|
||||
continue // Re-check for mobs that delete themselves on death
|
||||
|
||||
M.ghostize()
|
||||
qdel(M)
|
||||
|
||||
for(var/obj/O in contents) //obj instead of obj/item so that bodybags and ashes get destroyed. We dont want tons and tons of ash piling up
|
||||
qdel(O)
|
||||
|
||||
new /obj/effect/decal/cleanable/ash(src)
|
||||
sleep(30)
|
||||
cremating = FALSE
|
||||
locked = FALSE
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
playsound(loc, 'sound/machines/ding.ogg', 50, 1)
|
||||
|
||||
new /obj/effect/decal/cleanable/ash(src)
|
||||
sleep(30)
|
||||
cremating = FALSE
|
||||
locked = FALSE
|
||||
update_icon(UPDATE_OVERLAYS)
|
||||
playsound(loc, 'sound/machines/ding.ogg', 50, 1)
|
||||
return
|
||||
|
||||
/obj/structure/crematorium/Destroy()
|
||||
GLOB.crematoriums -= src
|
||||
|
||||
if(!connected)
|
||||
var/turf/T = loc
|
||||
for(var/atom/movable/A in src)
|
||||
A.forceMove(T)
|
||||
else
|
||||
QDEL_NULL(connected)
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/structure/crematorium/container_resist(mob/living/L)
|
||||
@@ -399,7 +454,7 @@
|
||||
return
|
||||
|
||||
to_chat(CM, "<span class='alert'>You attempt to slide yourself out of \the [src]...</span>")
|
||||
src.attack_hand(CM)
|
||||
attack_hand(CM)
|
||||
|
||||
/obj/structure/crematorium/get_remote_view_fullscreens(mob/user)
|
||||
if(user.stat == DEAD || !(user.sight & (SEEOBJS|SEEMOBS)))
|
||||
@@ -421,16 +476,15 @@
|
||||
|
||||
/obj/structure/c_tray/attack_hand(mob/user as mob)
|
||||
if(connected)
|
||||
for(var/atom/movable/A as mob|obj in loc)
|
||||
if(!( A.anchored ))
|
||||
for(var/atom/movable/A in loc)
|
||||
if(!A.anchored)
|
||||
A.forceMove(connected)
|
||||
//Foreach goto(26)
|
||||
|
||||
connected.connected = null
|
||||
connected.update_icon(UPDATE_OVERLAYS)
|
||||
add_fingerprint(user)
|
||||
qdel(src)
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
/obj/structure/c_tray/MouseDrop_T(atom/movable/O, mob/living/user)
|
||||
if((!( istype(O, /atom/movable) ) || O.anchored || get_dist(user, src) > 1 || get_dist(user, O) > 1 || user.contents.Find(src) || user.contents.Find(O)))
|
||||
@@ -463,9 +517,7 @@
|
||||
active_power_usage = 5000
|
||||
anchored = TRUE
|
||||
req_access = list(ACCESS_CREMATORIUM)
|
||||
var/on = FALSE
|
||||
var/area/area = null
|
||||
var/otherarea = null
|
||||
/// ID of the crematorium to hook into
|
||||
var/id = 1
|
||||
|
||||
/obj/machinery/crema_switch/attack_ghost(mob/user)
|
||||
@@ -473,17 +525,18 @@
|
||||
return attack_hand(user)
|
||||
|
||||
/obj/machinery/crema_switch/attack_hand(mob/user)
|
||||
if(powered(power_channel)) // Do we have power?
|
||||
if(allowed(usr) || user.can_advanced_admin_interact())
|
||||
use_power(400000)
|
||||
for(var/obj/structure/crematorium/C in world)
|
||||
if(C.id == id)
|
||||
if(!C.cremating)
|
||||
C.cremate(user)
|
||||
if(!powered(power_channel)) // Do we have power?
|
||||
return
|
||||
|
||||
if(!(allowed(usr) || user.can_advanced_admin_interact()))
|
||||
to_chat(usr, "<span class='warning'>Access denied.</span>")
|
||||
return
|
||||
|
||||
use_power(400000)
|
||||
for(var/obj/structure/crematorium/C in GLOB.crematoriums)
|
||||
if(C.id == id && !C.cremating)
|
||||
C.cremate(user)
|
||||
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>Access denied.</span>")
|
||||
|
||||
/mob/proc/update_morgue()
|
||||
if(stat == DEAD)
|
||||
|
||||
Reference in New Issue
Block a user