Merge pull request #3282 from Citadel-Station-13/upstream-merge-31356

[MIRROR] Cleans up atmos unary machinery code
This commit is contained in:
LetterJay
2017-10-10 22:28:29 -04:00
committed by GitHub
7 changed files with 116 additions and 116 deletions

View File

@@ -20,7 +20,7 @@
var/sleep_factor = 750
var/unconscious_factor = 1000
var/heat_capacity = 20000
var/conduction_coefficient = 0.30
var/conduction_coefficient = 0.3
var/obj/item/reagent_containers/glass/beaker = null
var/reagent_transfer = 0
@@ -29,7 +29,7 @@
var/radio_key = /obj/item/device/encryptionkey/headset_med
var/radio_channel = "Medical"
var/running_bob_anim = FALSE
var/running_anim = FALSE
var/escape_in_progress = FALSE
var/message_cooldown
@@ -83,46 +83,51 @@
/obj/machinery/atmospherics/components/unary/cryo_cell/update_icon()
cut_overlays()
if(panel_open)
add_overlay("pod-panel")
if(state_open)
icon_state = "pod-open"
else if(occupant)
return
if(occupant)
var/image/occupant_overlay
if(ismonkey(occupant)) // Monkey
occupant_overlay = mutable_appearance(CRYOMOBS, "monkey")
else if(isalienadult(occupant))
if(isalienroyal(occupant)) // Queen and prae
occupant_overlay = image(CRYOMOBS, "alienq")
else if(isalienhunter(occupant)) // Hunter
occupant_overlay = image(CRYOMOBS, "alienh")
else if(isaliensentinel(occupant)) // Sentinel
occupant_overlay = image(CRYOMOBS, "aliens")
else // Drone (or any other alien that isn't any of the above)
occupant_overlay = image(CRYOMOBS, "aliend")
else if(ishuman(occupant) || islarva(occupant) || (isanimal(occupant) && !ismegafauna(occupant))) // Mobs that are smaller than cryotube
if(ishuman(occupant) || islarva(occupant) || (isanimal(occupant) && !ismegafauna(occupant))) // Mobs that are smaller than cryotube
occupant_overlay = image(occupant.icon, occupant.icon_state)
occupant_overlay.copy_overlays(occupant)
else // Anything else
else if(ismonkey(occupant)) // Monkey
occupant_overlay = image(CRYOMOBS, "monkey")
occupant_overlay.copy_overlays(occupant)
else if(!isalienadult(occupant))
occupant_overlay = image(CRYOMOBS, "generic")
else if(isalienroyal(occupant)) // Queen and prae
occupant_overlay = image(CRYOMOBS, "alienq")
else if(isalienhunter(occupant)) // Hunter
occupant_overlay = image(CRYOMOBS, "alienh")
else if(isaliensentinel(occupant)) // Sentinel
occupant_overlay = image(CRYOMOBS, "aliens")
else // Drone or other
occupant_overlay = image(CRYOMOBS, "aliend")
occupant_overlay.dir = SOUTH
occupant_overlay.pixel_y = 22
if(on && !running_bob_anim && is_operational())
if(on && !running_anim && is_operational())
icon_state = "pod-on"
running_bob_anim = TRUE
run_bob_anim(TRUE, occupant_overlay)
running_anim = TRUE
run_anim(TRUE, occupant_overlay)
else
icon_state = "pod-off"
add_overlay(occupant_overlay)
add_overlay("cover-off")
else if(on && is_operational())
icon_state = "pod-on"
add_overlay("cover-on")
@@ -130,12 +135,9 @@
icon_state = "pod-off"
add_overlay("cover-off")
if(panel_open)
add_overlay("pod-panel")
/obj/machinery/atmospherics/components/unary/cryo_cell/proc/run_bob_anim(anim_up, image/occupant_overlay)
/obj/machinery/atmospherics/components/unary/cryo_cell/proc/run_anim(anim_up, image/occupant_overlay)
if(!on || !occupant || !is_operational())
running_bob_anim = FALSE
running_anim = FALSE
return
cut_overlays()
if(occupant_overlay.pixel_y != 23) // Same effect as occupant_overlay.pixel_y == 22 || occupant_overlay.pixel_y == 24
@@ -146,7 +148,7 @@
occupant_overlay.pixel_y--
add_overlay(occupant_overlay)
add_overlay("cover-on")
addtimer(CALLBACK(src, .proc/run_bob_anim, anim_up, occupant_overlay), 7, TIMER_UNIQUE)
addtimer(CALLBACK(src, .proc/run_anim, anim_up, occupant_overlay), 7, TIMER_UNIQUE)
/obj/machinery/atmospherics/components/unary/cryo_cell/process()
..()
@@ -157,60 +159,65 @@
on = FALSE
update_icon()
return
var/datum/gas_mixture/air1 = AIR1
var/turf/T = get_turf(src)
if(occupant)
var/mob/living/mob_occupant = occupant
if(mob_occupant.health >= mob_occupant.getMaxHealth()) // Don't bother with fully healed people.
on = FALSE
update_icon()
playsound(T, 'sound/machines/cryo_warning.ogg', volume) // Bug the doctors.
radio.talk_into(src, "Patient fully restored", radio_channel, get_spans(), get_default_language())
if(autoeject) // Eject if configured.
radio.talk_into(src, "Auto ejecting patient now", radio_channel, get_spans(), get_default_language())
open_machine()
return
else if(mob_occupant.stat == DEAD) // We don't bother with dead people.
return
if(autoeject) // Eject if configured.
open_machine()
return
if(air1.gases.len)
if(mob_occupant.bodytemperature < T0C) // Sleepytime. Why? More cryo magic.
mob_occupant.Sleeping((mob_occupant.bodytemperature / sleep_factor) * 2000)
mob_occupant.Unconscious((mob_occupant.bodytemperature / unconscious_factor) * 2000)
if(!occupant)
return
var/mob/living/mob_occupant = occupant
if(mob_occupant.stat == DEAD) // We don't bother with dead people.
return
if(mob_occupant.health >= mob_occupant.getMaxHealth()) // Don't bother with fully healed people.
on = FALSE
update_icon()
playsound(src, 'sound/machines/cryo_warning.ogg', volume) // Bug the doctors.
radio.talk_into(src, "Patient fully restored", radio_channel, get_spans(), get_default_language())
if(autoeject) // Eject if configured.
radio.talk_into(src, "Auto ejecting patient now", radio_channel, get_spans(), get_default_language())
open_machine()
return
var/datum/gas_mixture/air1 = AIR1
if(air1.gases.len)
if(mob_occupant.bodytemperature < T0C) // Sleepytime. Why? More cryo magic.
mob_occupant.Sleeping((mob_occupant.bodytemperature / sleep_factor) * 2000)
mob_occupant.Unconscious((mob_occupant.bodytemperature / unconscious_factor) * 2000)
if(beaker)
if(reagent_transfer == 0) // Magically transfer reagents. Because cryo magic.
beaker.reagents.trans_to(occupant, 1, 10 * efficiency) // Transfer reagents, multiplied because cryo magic.
beaker.reagents.reaction(occupant, VAPOR)
air1.gases["o2"][MOLES] -= 2 / efficiency // Lets use gas for this.
if(++reagent_transfer >= 10 * efficiency) // Throttle reagent transfer (higher efficiency will transfer the same amount but consume less from the beaker).
reagent_transfer = 0
if(beaker)
if(reagent_transfer == 0) // Magically transfer reagents. Because cryo magic.
beaker.reagents.trans_to(occupant, 1, 10 * efficiency) // Transfer reagents, multiplied because cryo magic.
beaker.reagents.reaction(occupant, VAPOR)
air1.gases["o2"][MOLES] -= 2 / efficiency // Lets use gas for this.
if(++reagent_transfer >= 10 * efficiency) // Throttle reagent transfer (higher efficiency will transfer the same amount but consume less from the beaker).
reagent_transfer = 0
return 1
/obj/machinery/atmospherics/components/unary/cryo_cell/process_atmos()
..()
if(!on)
return
var/datum/gas_mixture/air1 = AIR1
if(!NODE1 || !AIR1 || !air1.gases.len || air1.gases["o2"][MOLES] < 5) // Turn off if the machine won't work.
on = FALSE
update_icon()
return
if(occupant)
var/mob/living/mob_occupant = occupant
var/cold_protection = 0
var/mob/living/carbon/human/H = occupant
if(istype(H))
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
cold_protection = H.get_cold_protection(air1.temperature)
var/temperature_delta = air1.temperature - mob_occupant.bodytemperature // The only semi-realistic thing here: share temperature between the cell and the occupant.
if(abs(temperature_delta) > 1)
var/air_heat_capacity = air1.heat_capacity()
var/heat = ((1 - cold_protection) / 10 + conduction_coefficient) \
* temperature_delta * \
(air_heat_capacity * heat_capacity / (air_heat_capacity + heat_capacity))
var/heat = ((1 - cold_protection) * 0.1 + conduction_coefficient) * temperature_delta * (1 / air_heat_capacity + 1 / heat_capacity)
air1.temperature = max(air1.temperature - heat / air_heat_capacity, TCMB)
mob_occupant.bodytemperature = max(mob_occupant.bodytemperature + heat / heat_capacity, TCMB)
@@ -248,7 +255,7 @@
user.visible_message("<span class='notice'>You see [user] kicking against the glass of [src]!</span>", \
"<span class='notice'>You struggle inside [src], kicking the release with your foot... (this will take about [DisplayTimeText(breakout_time)].)</span>", \
"<span class='italics'>You hear a thump from [src].</span>")
if(do_after(user,(breakout_time), target = src))
if(do_after(user, breakout_time, target = src))
if(!user || user.stat != CONSCIOUS || user.loc != src )
return
user.visible_message("<span class='warning'>[user] successfully broke out of [src]!</span>", \
@@ -284,16 +291,10 @@
var/reagentlist = pretty_string_from_reagent_list(I.reagents.reagent_list)
log_game("[key_name(user)] added an [I] to cyro containing [reagentlist]")
return
if(!on && !occupant && !state_open)
if(default_deconstruction_screwdriver(user, "pod-off", "pod-off", I))
return
if(exchange_parts(user, I))
return
if(default_change_direction_wrench(user, I))
return
if(default_pry_open(I))
return
if(default_deconstruction_crowbar(I))
if(!on && !occupant && !state_open && (default_deconstruction_screwdriver(user, "pod-o", "pod-off", I) || exchange_parts(user, I)) \
|| default_change_direction_wrench(user, I) \
|| default_pry_open(I) \
|| default_deconstruction_crowbar(I))
return
return ..()
@@ -384,16 +385,16 @@
update_icon()
/obj/machinery/atmospherics/components/unary/cryo_cell/update_remote_sight(mob/living/user)
return //we don't see the pipe network while inside cryo.
return // we don't see the pipe network while inside cryo.
/obj/machinery/atmospherics/components/unary/cryo_cell/get_remote_view_fullscreens(mob/user)
user.overlay_fullscreen("remote_view", /obj/screen/fullscreen/impaired, 1)
/obj/machinery/atmospherics/components/unary/cryo_cell/can_crawl_through()
return //can't ventcrawl in or out of cryo.
return // can't ventcrawl in or out of cryo.
/obj/machinery/atmospherics/components/unary/cryo_cell/can_see_pipes()
return 0 //you can't see the pipe network when inside a cryo cell.
return 0 // you can't see the pipe network when inside a cryo cell.
/obj/machinery/atmospherics/components/unary/cryo_cell/return_temperature()
var/datum/gas_mixture/G = AIR1

View File

@@ -45,6 +45,7 @@
/obj/machinery/atmospherics/components/unary/outlet_injector/process_atmos()
..()
injecting = 0
if(!on || !is_operational())
@@ -63,6 +64,7 @@
update_parents()
/obj/machinery/atmospherics/components/unary/outlet_injector/proc/inject()
if(on || injecting || !is_operational())
return
@@ -72,11 +74,8 @@
if(air_contents.temperature > 0)
var/transfer_moles = (air_contents.return_pressure())*volume_rate/(air_contents.temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = air_contents.remove(transfer_moles)
loc.assume_air(removed)
update_parents()
flick("inje_inject", src)
@@ -88,6 +87,7 @@
radio_connection = SSradio.add_object(src, frequency)
/obj/machinery/atmospherics/components/unary/outlet_injector/proc/broadcast_status()
if(!radio_connection)
return
@@ -112,6 +112,7 @@
..()
/obj/machinery/atmospherics/components/unary/outlet_injector/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return
@@ -137,6 +138,7 @@
spawn(2)
broadcast_status()
update_icon()

View File

@@ -33,7 +33,9 @@
AIR1 = air_contents
/obj/machinery/atmospherics/components/unary/oxygen_generator/process_atmos()
..()
if(!on)
return 0

View File

@@ -128,8 +128,10 @@
return data
/obj/machinery/atmospherics/components/unary/thermomachine/ui_act(action, params)
if(..())
return
switch(action)
if("power")
on = !on
@@ -141,7 +143,7 @@
var/adjust = text2num(params["adjust"])
if(target == "input")
target = input("Set new target ([min_temperature]-[max_temperature] K):", name, target_temperature) as num|null
if(!isnull(target) && !..())
if(!isnull(target))
. = TRUE
else if(adjust)
target = target_temperature + adjust
@@ -152,6 +154,7 @@
if(.)
target_temperature = Clamp(target, min_temperature, max_temperature)
investigate_log("was set to [target_temperature] K by [key_name(usr)]", INVESTIGATE_ATMOS)
update_icon()
/obj/machinery/atmospherics/components/unary/thermomachine/freezer

View File

@@ -7,14 +7,10 @@
/obj/machinery/atmospherics/components/unary/SetInitDirections()
initialize_directions = dir
/*
Iconnery
*/
/obj/machinery/atmospherics/components/unary/on_construction()
..()
update_icon()
/obj/machinery/atmospherics/components/unary/hide(intact)
update_icon()
..(intact)

View File

@@ -22,9 +22,9 @@
var/pressure_checks = EXT_BOUND
var/external_pressure_bound = ONE_ATMOSPHERE
var/internal_pressure_bound = 0
//EXT_BOUND: Do not pass external_pressure_bound
//INT_BOUND: Do not pass internal_pressure_bound
//NO_BOUND: Do not pass either
// EXT_BOUND: Do not pass external_pressure_bound
// INT_BOUND: Do not pass internal_pressure_bound
// NO_BOUND: Do not pass either
var/frequency = 1439
var/datum/radio_frequency/radio_connection
@@ -98,7 +98,7 @@
if(pump_direction & RELEASING)
icon_state = "vent_out"
else //pump_direction == SIPHONING
else // pump_direction == SIPHONING
icon_state = "vent_in"
/obj/machinery/atmospherics/components/unary/vent_pump/process_atmos()
@@ -114,7 +114,7 @@
var/datum/gas_mixture/environment = loc.return_air()
var/environment_pressure = environment.return_pressure()
if(pump_direction & RELEASING) //internal -> external
if(pump_direction & RELEASING) // internal -> external
var/pressure_delta = 10000
if(pressure_checks&EXT_BOUND)
@@ -131,23 +131,22 @@
loc.assume_air(removed)
air_update_turf()
else //external -> internal
else // external -> internal
var/pressure_delta = 10000
if(pressure_checks&EXT_BOUND)
pressure_delta = min(pressure_delta, (environment_pressure - external_pressure_bound))
if(pressure_checks&INT_BOUND)
pressure_delta = min(pressure_delta, (internal_pressure_bound - air_contents.return_pressure()))
if(pressure_delta > 0)
if(environment.temperature > 0)
var/transfer_moles = pressure_delta*air_contents.volume/(environment.temperature * R_IDEAL_GAS_EQUATION)
if(pressure_delta > 0 && environment.temperature > 0)
var/transfer_moles = pressure_delta * air_contents.volume / (environment.temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
if (isnull(removed)) //in space
return
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
if (isnull(removed)) // in space
return
air_contents.merge(removed)
air_update_turf()
air_contents.merge(removed)
air_update_turf()
update_parents()
//Radio remote control
@@ -163,7 +162,7 @@
return
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.transmission_method = 1 // radio signal
signal.source = src
signal.data = list(
@@ -200,7 +199,7 @@
/obj/machinery/atmospherics/components/unary/vent_pump/receive_signal(datum/signal/signal)
if(!is_operational())
return
//log_admin("DEBUG \[[world.timeofday]\]: /obj/machinery/atmospherics/components/unary/vent_pump/receive_signal([signal.debug_print()])")
// log_admin("DEBUG \[[world.timeofday]\]: /obj/machinery/atmospherics/components/unary/vent_pump/receive_signal([signal.debug_print()])")
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
return
@@ -248,20 +247,20 @@
if("status" in signal.data)
broadcast_status()
return //do not update_icon
return // do not update_icon
//log_admin("DEBUG \[[world.timeofday]\]: vent_pump/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
// log_admin("DEBUG \[[world.timeofday]\]: vent_pump/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
broadcast_status()
update_icon()
/obj/machinery/atmospherics/components/unary/vent_pump/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/weldingtool))
var/obj/item/weldingtool/WT = W
if (WT.remove_fuel(0,user))
if (WT.remove_fuel(0, user))
playsound(loc, WT.usesound, 40, 1)
to_chat(user, "<span class='notice'>You begin welding the vent...</span>")
if(do_after(user, 20*W.toolspeed, target = src))
if(!src || !WT.isOn())
if(do_after(user, W.toolspeed * 20, target = src))
if(!src || !WT.isOn())
return
playsound(src.loc, 'sound/items/welder2.ogg', 50, 1)
if(!welded)

View File

@@ -152,11 +152,10 @@
/obj/machinery/atmospherics/components/unary/vent_scrubber/process_atmos()
..()
if(!is_operational())
if(welded || !is_operational())
return FALSE
if(!NODE1)
if(!NODE1 || !on)
on = FALSE
if(!on || welded)
return FALSE
scrub(loc)
if(widenet)
@@ -257,7 +256,7 @@
//There is no easy way for an object to be notified of changes to atmos can pass flags_1
// So we check every machinery process (2 seconds)
/obj/machinery/atmospherics/components/unary/vent_scrubber/process()
if (widenet)
if(widenet)
check_turfs()
//we populate a list of turfs with nonatmos-blocked cardinal turfs AND
@@ -270,9 +269,7 @@
/obj/machinery/atmospherics/components/unary/vent_scrubber/receive_signal(datum/signal/signal)
if(!is_operational())
return
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
if(!is_operational() || !signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
return 0
if("power" in signal.data)