diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm
index b2feaa27107..28841e9c0e3 100644
--- a/code/__DEFINES/dcs/signals.dm
+++ b/code/__DEFINES/dcs/signals.dm
@@ -477,6 +477,13 @@
#define COMSIG_MACHINERY_POWER_LOST "machinery_power_lost"
///from base power_change() when power is restored
#define COMSIG_MACHINERY_POWER_RESTORED "machinery_power_restored"
+///from /obj/machinery/set_occupant(atom/movable/O): (new_occupant)
+#define COMSIG_MACHINERY_SET_OCCUPANT "machinery_set_occupant"
+
+// /obj/machinery/atmospherics/components/unary/cryo_cell signals
+
+/// from /obj/machinery/atmospherics/components/unary/cryo_cell/set_on(bool): (on)
+#define COMSIG_CRYO_SET_ON "cryo_set_on"
// /obj/machinery/door/airlock signals
diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm
index 459737fd1cc..c67cd5c3d4c 100644
--- a/code/game/machinery/Sleeper.dm
+++ b/code/game/machinery/Sleeper.dm
@@ -83,7 +83,7 @@
..(user)
var/mob/living/mob_occupant = occupant
if(mob_occupant && mob_occupant.stat != DEAD)
- to_chat(occupant, "[enter_message]")
+ to_chat(mob_occupant, "[enter_message]")
/obj/machinery/sleeper/emp_act(severity)
. = ..()
diff --git a/code/game/machinery/_machinery.dm b/code/game/machinery/_machinery.dm
index 197ee705acc..f734b081096 100644
--- a/code/game/machinery/_machinery.dm
+++ b/code/game/machinery/_machinery.dm
@@ -146,6 +146,12 @@ Class Procs:
return INITIALIZE_HINT_LATELOAD
+/obj/machinery/proc/set_occupant(atom/movable/new_occupant)
+ SHOULD_CALL_PARENT(TRUE)
+
+ SEND_SIGNAL(src, COMSIG_MACHINERY_SET_OCCUPANT, new_occupant)
+ occupant = new_occupant
+
/// Helper proc for telling a machine to start processing with the subsystem type that is located in its `subsystem_type` var.
/obj/machinery/proc/begin_processing()
var/datum/controller/subsystem/processing/subsystem = locate(subsystem_type) in Master.subsystems
@@ -232,7 +238,7 @@ Class Procs:
movable_atom.forceMove(this_turf)
// We'll have dropped the occupant, circuit and component parts as part of this.
- occupant = null
+ set_occupant(null)
circuit = null
LAZYCLEARLIST(component_parts)
@@ -256,7 +262,7 @@ Class Procs:
movable_atom.forceMove(this_turf)
if(occupant == movable_atom)
- occupant = null
+ set_occupant(null)
/**
* Puts passed object in to user's hand
@@ -295,7 +301,7 @@ Class Procs:
var/mob/living/mobtarget = target
if(target && !target.has_buckled_mobs() && (!isliving(target) || !mobtarget.buckled))
- occupant = target
+ set_occupant(target)
target.forceMove(src)
updateUsrDialog()
update_icon()
@@ -372,19 +378,19 @@ Class Procs:
var/datum/bank_account/insurance = I.registered_account
if(!insurance)
say("[market_verb] NAP Violation: No bank account found.")
- nap_violation(occupant)
+ nap_violation(H)
return FALSE
else
if(!insurance.adjust_money(-fair_market_price))
say("[market_verb] NAP Violation: Unable to pay.")
- nap_violation(occupant)
+ nap_violation(H)
return FALSE
var/datum/bank_account/D = SSeconomy.get_dep_account(payment_department)
if(D)
D.adjust_money(fair_market_price)
else
say("[market_verb] NAP Violation: No ID card found.")
- nap_violation(occupant)
+ nap_violation(H)
return FALSE
return TRUE
@@ -509,12 +515,11 @@ Class Procs:
return TRUE
/obj/machinery/contents_explosion(severity, target)
- if(occupant)
- occupant.ex_act(severity, target)
+ occupant?.ex_act(severity, target)
/obj/machinery/handle_atom_del(atom/A)
if(A == occupant)
- occupant = null
+ set_occupant(null)
update_icon()
updateUsrDialog()
return ..()
@@ -682,7 +687,7 @@ Class Procs:
/obj/machinery/Exited(atom/movable/AM, atom/newloc)
. = ..()
if(AM == occupant)
- occupant = null
+ set_occupant(null)
if(AM == circuit)
circuit = null
@@ -697,6 +702,13 @@ Class Procs:
/obj/machinery/rust_heretic_act()
take_damage(500, BRUTE, MELEE, 1)
+/obj/machinery/vv_edit_var(vname, vval)
+ if(vname == "occupant")
+ set_occupant(vval)
+ datum_flags |= DF_VAR_EDITED
+ return TRUE
+ return ..()
+
/**
* Generate a name devices
*
diff --git a/code/game/machinery/computer/Operating.dm b/code/game/machinery/computer/Operating.dm
index a32bad6006c..f32dae6fb02 100644
--- a/code/game/machinery/computer/Operating.dm
+++ b/code/game/machinery/computer/Operating.dm
@@ -90,7 +90,7 @@
else
if(sbed)
data["table"] = sbed
- if(!ishuman(sbed.occupant) && !ismonkey(sbed.occupant))
+ if(!ishuman(sbed.occupant) && !ismonkey(sbed.occupant))
return data
data["patient"] = list()
patient = sbed.occupant
diff --git a/code/game/machinery/fat_sucker.dm b/code/game/machinery/fat_sucker.dm
index 668506d5eeb..da779eaccbc 100644
--- a/code/game/machinery/fat_sucker.dm
+++ b/code/game/machinery/fat_sucker.dm
@@ -55,7 +55,7 @@
if(occupant)
if(!iscarbon(occupant))
occupant.forceMove(drop_location())
- occupant = null
+ set_occupant(null)
return
to_chat(occupant, "You enter [src].")
addtimer(CALLBACK(src, .proc/start_extracting), 20, TIMER_OVERRIDE|TIMER_UNIQUE)
diff --git a/code/game/machinery/hypnochair.dm b/code/game/machinery/hypnochair.dm
index 7cf233e950b..82f4a52a98a 100644
--- a/code/game/machinery/hypnochair.dm
+++ b/code/game/machinery/hypnochair.dm
@@ -40,13 +40,14 @@
/obj/machinery/hypnochair/ui_data()
var/list/data = list()
- data["occupied"] = occupant ? 1 : 0
+ var/mob/living/mob_occupant = occupant
+
+ data["occupied"] = mob_occupant ? 1 : 0
data["open"] = state_open
data["interrogating"] = interrogating
data["occupant"] = list()
- if(occupant)
- var/mob/living/mob_occupant = occupant
+ if(mob_occupant)
data["occupant"]["name"] = mob_occupant.name
data["occupant"]["stat"] = mob_occupant.stat
diff --git a/code/game/machinery/stasis.dm b/code/game/machinery/stasis.dm
index 91dc556fefb..55dc4e531d5 100644
--- a/code/game/machinery/stasis.dm
+++ b/code/game/machinery/stasis.dm
@@ -123,7 +123,7 @@
/obj/machinery/stasis/post_buckle_mob(mob/living/L)
if(!can_be_occupant(L))
return
- occupant = L
+ set_occupant(L)
if(stasis_running() && check_nap_violations())
chill_out(L)
update_icon()
@@ -131,7 +131,7 @@
/obj/machinery/stasis/post_unbuckle_mob(mob/living/L)
thaw_them(L)
if(L == occupant)
- occupant = null
+ set_occupant(null)
update_icon()
/obj/machinery/stasis/process()
diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm
index dd799bf2838..88e023eb028 100644
--- a/code/game/machinery/suit_storage_unit.dm
+++ b/code/game/machinery/suit_storage_unit.dm
@@ -196,7 +196,7 @@
suit = null
mask = null
storage = null
- occupant = null
+ set_occupant(null)
/obj/machinery/suit_storage_unit/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
@@ -353,7 +353,7 @@
uv = TRUE
locked = TRUE
update_icon()
- if(occupant)
+ if(mob_occupant)
if(uv_super)
mob_occupant.adjustFireLoss(rand(20, 36))
else
@@ -380,7 +380,7 @@
// The wires get damaged too.
wires.cut_all()
else
- if(!occupant)
+ if(!mob_occupant)
visible_message("[src]'s door slides open. The glowing yellow lights dim to a gentle green.")
else
visible_message("[src]'s door slides open, barraging you with the nauseating smell of charred flesh.")
@@ -399,14 +399,14 @@
if(storage)
things_to_clear += storage
things_to_clear += storage.GetAllContents()
- if(occupant)
- things_to_clear += occupant
- things_to_clear += occupant.GetAllContents()
+ if(mob_occupant)
+ things_to_clear += mob_occupant
+ things_to_clear += mob_occupant.GetAllContents()
for(var/am in things_to_clear) //Scorches away blood and forensic evidence, although the SSU itself is unaffected
var/atom/movable/dirty_movable = am
dirty_movable.wash(CLEAN_ALL)
open_machine(FALSE)
- if(occupant)
+ if(mob_occupant)
dump_inventory_contents()
/obj/machinery/suit_storage_unit/process(delta_time)
diff --git a/code/game/objects/items/implants/implantchair.dm b/code/game/objects/items/implants/implantchair.dm
index 12e32a9c55e..bc670815307 100644
--- a/code/game/objects/items/implants/implantchair.dm
+++ b/code/game/objects/items/implants/implantchair.dm
@@ -37,12 +37,13 @@
/obj/machinery/implantchair/ui_data()
var/list/data = list()
- data["occupied"] = occupant ? 1 : 0
+ var/mob/living/mob_occupant = occupant
+
+ data["occupied"] = mob_occupant ? 1 : 0
data["open"] = state_open
data["occupant"] = list()
- if(occupant)
- var/mob/living/mob_occupant = occupant
+ if(mob_occupant)
data["occupant"]["name"] = mob_occupant.name
data["occupant"]["stat"] = mob_occupant.stat
@@ -65,7 +66,7 @@
open_machine()
. = TRUE
if("implant")
- implant(occupant,usr)
+ implant(occupant, usr)
. = TRUE
/obj/machinery/implantchair/proc/implant(mob/living/M,mob/user)
diff --git a/code/modules/antagonists/abductor/machinery/experiment.dm b/code/modules/antagonists/abductor/machinery/experiment.dm
index 07d09f41b1e..bb5eb99a028 100644
--- a/code/modules/antagonists/abductor/machinery/experiment.dm
+++ b/code/modules/antagonists/abductor/machinery/experiment.dm
@@ -99,7 +99,7 @@
var/mob/living/mob_occupant = occupant
if(mob_occupant.stat == DEAD)
return
- flash = experiment(occupant, params["experiment_type"], usr)
+ flash = experiment(mob_occupant, params["experiment_type"], usr)
return TRUE
/**
diff --git a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm
index b3643e67434..d7546653534 100644
--- a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm
+++ b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm
@@ -11,15 +11,32 @@
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
pixel_y = 22
appearance_flags = KEEP_TOGETHER
+ /// The current occupant being presented
+ var/mob/living/occupant
-/atom/movable/visual/cryo_occupant/Initialize()
+/atom/movable/visual/cryo_occupant/Initialize(mapload, obj/machinery/atmospherics/components/unary/cryo_cell/parent)
. = ..()
// Alpha masking
// It will follow this as the animation goes, but that's no problem as the "mask" icon state
// already accounts for this.
add_filter("alpha_mask", 1, list("type" = "alpha", "icon" = icon('icons/obj/cryogenics.dmi', "mask"), "y" = -22))
+ RegisterSignal(parent, COMSIG_MACHINERY_SET_OCCUPANT, .proc/on_set_occupant)
+ RegisterSignal(parent, COMSIG_CRYO_SET_ON, .proc/on_set_on)
+
+/// COMSIG_MACHINERY_SET_OCCUPANT callback
+/atom/movable/visual/cryo_occupant/proc/on_set_occupant(datum/source, mob/living/new_occupant)
+ SIGNAL_HANDLER
+
+ if(occupant)
+ vis_contents -= occupant
+ REMOVE_TRAIT(occupant, TRAIT_IMMOBILIZED, CRYO_TRAIT)
+ if(occupant.resting || HAS_TRAIT(occupant, TRAIT_FLOORED))
+ occupant.set_lying_down()
+
+ occupant = new_occupant
+ if(!occupant)
+ return
-/atom/movable/visual/cryo_occupant/proc/on_occupant_enter(mob/living/occupant)
occupant.setDir(SOUTH)
vis_contents += occupant
pixel_y = 22
@@ -27,18 +44,15 @@
occupant.set_body_position(STANDING_UP)
occupant.set_lying_angle(0)
-/atom/movable/visual/cryo_occupant/proc/on_occupant_exit(mob/living/occupant)
- vis_contents -= occupant
- REMOVE_TRAIT(occupant, TRAIT_IMMOBILIZED, CRYO_TRAIT)
- if(occupant.resting || HAS_TRAIT(occupant, TRAIT_FLOORED))
- occupant.set_lying_down()
+/// COMSIG_CRYO_SET_ON callback
+/atom/movable/visual/cryo_occupant/proc/on_set_on(datum/source, on)
+ SIGNAL_HANDLER
-/atom/movable/visual/cryo_occupant/proc/on_toggle_on()
- animate(src, pixel_y = 24, time = 20, loop = -1)
- animate(pixel_y = 22, time = 20)
-
-/atom/movable/visual/cryo_occupant/proc/on_toggle_off()
- animate(src)
+ if(on)
+ animate(src, pixel_y = 24, time = 20, loop = -1)
+ animate(pixel_y = 22, time = 20)
+ else
+ animate(src)
/// Cryo cell
/obj/machinery/atmospherics/components/unary/cryo_cell
@@ -97,15 +111,12 @@
radio.canhear_range = 0
radio.recalculateChannels()
- occupant_vis = new(null)
+ occupant_vis = new(null, src)
vis_contents += occupant_vis
-/obj/machinery/atmospherics/components/unary/cryo_cell/Exited(atom/movable/AM, atom/newloc)
- var/mob/living/oldoccupant = occupant
- . = ..() // Parent proc takes care of removing occupant if necessary
- if (oldoccupant && istype(oldoccupant) && AM == oldoccupant)
- update_icon()
- occupant_vis.on_occupant_exit(oldoccupant)
+/obj/machinery/atmospherics/components/unary/cryo_cell/set_occupant(atom/movable/new_occupant)
+ . = ..()
+ update_icon()
/obj/machinery/atmospherics/components/unary/cryo_cell/on_construction()
..(dir, dir)
@@ -192,13 +203,10 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics
/obj/machinery/atmospherics/components/unary/cryo_cell/proc/set_on(new_value)
if(on == new_value)
return
+ SEND_SIGNAL(src, COMSIG_CRYO_SET_ON, new_value)
. = on
on = new_value
update_icon()
- if(on)
- occupant_vis.on_toggle_on()
- else
- occupant_vis.on_toggle_off()
/obj/machinery/atmospherics/components/unary/cryo_cell/on_set_is_operational(old_value)
if(old_value) //Turned off
@@ -279,8 +287,8 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics
var/cold_protection = 0
var/temperature_delta = air1.temperature - mob_occupant.bodytemperature // The only semi-realistic thing here: share temperature between the cell and the occupant.
- if(ishuman(occupant))
- var/mob/living/carbon/human/H = occupant
+ if(ishuman(mob_occupant))
+ var/mob/living/carbon/human/H = mob_occupant
cold_protection = H.get_cold_protection(air1.temperature)
if(abs(temperature_delta) > 1)
@@ -307,7 +315,7 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics
set_on(FALSE)
for(var/mob/M in contents) //only drop mobs
M.forceMove(get_turf(src))
- occupant = null
+ set_occupant(null)
flick("pod-open-anim", src)
reagent_transfer = efficiency * 10 - 5 // wait before injecting the next occupant
..()
@@ -317,8 +325,6 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics
if((isnull(user) || istype(user)) && state_open && !panel_open)
flick("pod-close-anim", src)
..(user)
- if(isliving(occupant))
- occupant_vis.on_occupant_enter(occupant)
return occupant
/obj/machinery/atmospherics/components/unary/cryo_cell/container_resist_act(mob/living/user)
@@ -452,7 +458,6 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics
set_on(FALSE)
else if(!state_open)
set_on(TRUE)
- update_icon()
. = TRUE
if("door")
if(state_open)
diff --git a/code/modules/food_and_drinks/kitchen_machinery/gibber.dm b/code/modules/food_and_drinks/kitchen_machinery/gibber.dm
index 1af39f4691f..bbdfed7ebc9 100644
--- a/code/modules/food_and_drinks/kitchen_machinery/gibber.dm
+++ b/code/modules/food_and_drinks/kitchen_machinery/gibber.dm
@@ -98,7 +98,7 @@
if(C && user.pulling == C && !C.buckled && !C.has_buckled_mobs() && !occupant)
user.visible_message("[user] stuffs [C] into the gibber!")
C.forceMove(src)
- occupant = C
+ set_occupant(C)
update_icon()
else
startgibbing(user)
@@ -136,14 +136,14 @@
update_icon()
/obj/machinery/gibber/proc/startgibbing(mob/user)
- if(src.operating)
+ if(operating)
return
- if(!src.occupant)
+ if(!occupant)
audible_message("You hear a loud metallic grinding sound.")
return
use_power(1000)
audible_message("You hear a loud squelchy grinding sound.")
- playsound(src.loc, 'sound/machines/juicer.ogg', 50, TRUE)
+ playsound(loc, 'sound/machines/juicer.ogg', 50, TRUE)
operating = TRUE
update_icon()
@@ -199,7 +199,8 @@
log_combat(user, occupant, "gibbed")
mob_occupant.death(1)
mob_occupant.ghostize()
- qdel(src.occupant)
+ set_occupant(null)
+ qdel(mob_occupant)
addtimer(CALLBACK(src, .proc/make_meat, skin, allmeat, meat_produced, gibtype, diseases), gibtime)
/obj/machinery/gibber/proc/make_meat(obj/item/stack/sheet/animalhide/skin, list/obj/item/food/meat/slab/allmeat, meat_produced, gibtype, list/datum/disease/diseases)
diff --git a/code/modules/library/skill_learning/skill_station.dm b/code/modules/library/skill_learning/skill_station.dm
index b21085944ca..d38f8300050 100644
--- a/code/modules/library/skill_learning/skill_station.dm
+++ b/code/modules/library/skill_learning/skill_station.dm
@@ -124,9 +124,9 @@
var/mob/living/carbon/carbon_occupant = occupant
var/implant_msg = carbon_occupant.implant_skillchip(inserted_skillchip, FALSE)
if(implant_msg)
- to_chat(occupant,"Operation failed! [implant_msg]")
+ to_chat(carbon_occupant,"Operation failed! [implant_msg]")
else
- to_chat(occupant,"Operation complete!")
+ to_chat(carbon_occupant,"Operation complete!")
inserted_skillchip = null
update_icon()