Merge pull request #48859 from Archanial/master

Fixes stasis beds not working with operation computers
This commit is contained in:
skoglol
2020-01-20 10:23:11 +01:00
committed by GitHub
3 changed files with 97 additions and 59 deletions
+73 -59
View File
@@ -12,10 +12,10 @@
var/mob/living/carbon/human/patient
var/obj/structure/table/optable/table
var/obj/machinery/stasis/sbed
var/list/advanced_surgeries = list()
var/datum/techweb/linked_techweb
light_color = LIGHT_COLOR_BLUE
var/list/linked_stasisbeds
/obj/machinery/computer/operating/Initialize()
. = ..()
@@ -23,10 +23,15 @@
find_table()
/obj/machinery/computer/operating/Destroy()
for(var/i in linked_stasisbeds)
var/obj/machinery/stasis/SB = i
SB.op_computer = null
..()
for(var/direction in GLOB.cardinals)
table = locate(/obj/structure/table/optable, get_step(src, direction))
if(table && table.computer == src)
table.computer = null
else
sbed = locate(/obj/machinery/stasis, get_step(src, direction))
if(sbed && sbed.op_computer == src)
sbed.op_computer = null
. = ..()
/obj/machinery/computer/operating/attackby(obj/item/O, mob/user, params)
if(istype(O, /obj/item/disk/surgery))
@@ -52,14 +57,11 @@
if(table)
table.computer = src
break
if(!linked_stasisbeds)
linked_stasisbeds = list()
for(var/obj/machinery/stasis/SB in view(7,src))
if(SB.op_computer)
continue
linked_stasisbeds |= SB
SB.op_computer = src
else
sbed = locate(/obj/machinery/stasis, get_step(src, direction))
if(sbed)
sbed.op_computer = src
break
/obj/machinery/computer/operating/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.not_incapacitated_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
@@ -69,8 +71,6 @@
/obj/machinery/computer/operating/ui_data(mob/user)
var/list/data = list()
data["table"] = table
var/list/surgeries = list()
for(var/X in advanced_surgeries)
var/datum/surgery/S = X
@@ -79,56 +79,70 @@
surgery["desc"] = initial(S.desc)
surgeries += list(surgery)
data["surgeries"] = surgeries
data["patient"] = null
if(table)
if(table.check_patient())
data["table"] = table
if(!table.check_patient())
return data
data["patient"] = list()
patient = table.patient
else
if(sbed)
data["table"] = sbed
if(!sbed.check_patient())
return data
data["patient"] = list()
patient = table.patient
switch(patient.stat)
if(CONSCIOUS)
data["patient"]["stat"] = "Conscious"
data["patient"]["statstate"] = "good"
if(SOFT_CRIT)
data["patient"]["stat"] = "Conscious"
data["patient"]["statstate"] = "average"
if(UNCONSCIOUS)
data["patient"]["stat"] = "Unconscious"
data["patient"]["statstate"] = "average"
if(DEAD)
data["patient"]["stat"] = "Dead"
data["patient"]["statstate"] = "bad"
data["patient"]["health"] = patient.health
data["patient"]["blood_type"] = patient.dna.blood_type
data["patient"]["maxHealth"] = patient.maxHealth
data["patient"]["minHealth"] = HEALTH_THRESHOLD_DEAD
data["patient"]["bruteLoss"] = patient.getBruteLoss()
data["patient"]["fireLoss"] = patient.getFireLoss()
data["patient"]["toxLoss"] = patient.getToxLoss()
data["patient"]["oxyLoss"] = patient.getOxyLoss()
if(patient.surgeries.len)
data["procedures"] = list()
for(var/datum/surgery/procedure in patient.surgeries)
var/datum/surgery_step/surgery_step = procedure.get_surgery_step()
var/chems_needed = surgery_step.get_chem_list()
var/alternative_step
var/alt_chems_needed = ""
if(surgery_step.repeatable)
var/datum/surgery_step/next_step = procedure.get_surgery_next_step()
if(next_step)
alternative_step = capitalize(next_step.name)
alt_chems_needed = next_step.get_chem_list()
else
alternative_step = "Finish operation"
data["procedures"] += list(list(
"name" = capitalize("[parse_zone(procedure.location)] [procedure.name]"),
"next_step" = capitalize(surgery_step.name),
"chems_needed" = chems_needed,
"alternative_step" = alternative_step,
"alt_chems_needed" = alt_chems_needed
))
patient = sbed.occupant
else
data["patient"] = null
return data
switch(patient.stat)
if(CONSCIOUS)
data["patient"]["stat"] = "Conscious"
data["patient"]["statstate"] = "good"
if(SOFT_CRIT)
data["patient"]["stat"] = "Conscious"
data["patient"]["statstate"] = "average"
if(UNCONSCIOUS)
data["patient"]["stat"] = "Unconscious"
data["patient"]["statstate"] = "average"
if(DEAD)
data["patient"]["stat"] = "Dead"
data["patient"]["statstate"] = "bad"
data["patient"]["health"] = patient.health
data["patient"]["blood_type"] = patient.dna.blood_type
data["patient"]["maxHealth"] = patient.maxHealth
data["patient"]["minHealth"] = HEALTH_THRESHOLD_DEAD
data["patient"]["bruteLoss"] = patient.getBruteLoss()
data["patient"]["fireLoss"] = patient.getFireLoss()
data["patient"]["toxLoss"] = patient.getToxLoss()
data["patient"]["oxyLoss"] = patient.getOxyLoss()
if(patient.surgeries.len)
data["procedures"] = list()
for(var/datum/surgery/procedure in patient.surgeries)
var/datum/surgery_step/surgery_step = procedure.get_surgery_step()
var/chems_needed = surgery_step.get_chem_list()
var/alternative_step
var/alt_chems_needed = ""
if(surgery_step.repeatable)
var/datum/surgery_step/next_step = procedure.get_surgery_next_step()
if(next_step)
alternative_step = capitalize(next_step.name)
alt_chems_needed = next_step.get_chem_list()
else
alternative_step = "Finish operation"
data["procedures"] += list(list(
"name" = capitalize("[parse_zone(procedure.location)] [procedure.name]"),
"next_step" = capitalize(surgery_step.name),
"chems_needed" = chems_needed,
"alternative_step" = alternative_step,
"alt_chems_needed" = alt_chems_needed
))
return data
/obj/machinery/computer/operating/ui_act(action, params)
if(..())
return
+19
View File
@@ -19,6 +19,19 @@
var/obj/effect/overlay/vis/mattress_on
var/obj/machinery/computer/operating/op_computer
/obj/machinery/stasis/Initialize()
. = ..()
for(var/direction in GLOB.cardinals)
op_computer = locate(/obj/machinery/computer/operating, get_step(src, direction))
if(op_computer)
op_computer.sbed = src
break
/obj/machinery/stasis/Destroy()
. = ..()
if(op_computer && op_computer.sbed == src)
op_computer.sbed = null
/obj/machinery/stasis/examine(mob/user)
. = ..()
. += "<span class='notice'>Alt-click to [stasis_enabled ? "turn off" : "turn on"] the machine.</span>"
@@ -110,6 +123,12 @@
chill_out(L)
update_icon()
/obj/machinery/stasis/proc/check_patient()
if(occupant)
return TRUE
else
return FALSE
/obj/machinery/stasis/post_unbuckle_mob(mob/living/L)
thaw_them(L)
if(L == occupant)
@@ -468,6 +468,11 @@
computer.table = src
break
/obj/structure/table/optable/Destroy()
. = ..()
if(computer && computer.table == src)
computer.table = null
/obj/structure/table/optable/tablepush(mob/living/user, mob/living/pushed_mob)
pushed_mob.forceMove(loc)
pushed_mob.set_resting(TRUE, TRUE)