mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Omni-devices should no longer go and turn themselves off permanently in case of power failure.
This commit is contained in:
@@ -8,14 +8,14 @@
|
||||
var/list/filters = new()
|
||||
var/datum/omni_port/input
|
||||
var/datum/omni_port/output
|
||||
|
||||
|
||||
use_power = 1
|
||||
idle_power_usage = 150 //internal circuitry, friction losses and stuff
|
||||
active_power_usage = 7500 //This also doubles as a measure of how powerful the filter is, in Watts. 7500 W ~ 10 HP
|
||||
|
||||
|
||||
var/max_flow_rate = 200
|
||||
var/set_flow_rate = 200
|
||||
|
||||
|
||||
var/list/filtering_outputs = list() //maps gasids to gas_mixtures
|
||||
|
||||
/obj/machinery/atmospherics/omni/filter/New()
|
||||
@@ -58,32 +58,26 @@
|
||||
return 0
|
||||
|
||||
/obj/machinery/atmospherics/omni/filter/process()
|
||||
..()
|
||||
if(error_check())
|
||||
on = 0
|
||||
|
||||
if((stat & (NOPOWER|BROKEN)) || !on)
|
||||
update_use_power(0) //usually we get here because a player turned a pump off - definitely want to update.
|
||||
last_flow_rate = 0
|
||||
return
|
||||
|
||||
if(!..())
|
||||
return 0
|
||||
|
||||
var/datum/gas_mixture/output_air = output.air //BYOND doesn't like referencing "output.air.return_pressure()" so we need to make a direct reference
|
||||
var/datum/gas_mixture/input_air = input.air // it's completely happy with them if they're in a loop though i.e. "P.air.return_pressure()"... *shrug*
|
||||
|
||||
|
||||
//Figure out the amount of moles to transfer
|
||||
var/transfer_moles = (set_flow_rate/input_air.volume)*input_air.total_moles
|
||||
|
||||
|
||||
var/power_draw = -1
|
||||
if (transfer_moles > MINUMUM_MOLES_TO_FILTER)
|
||||
power_draw = filter_gas_multi(src, filtering_outputs, input_air, output_air, transfer_moles, active_power_usage)
|
||||
|
||||
|
||||
if (power_draw < 0)
|
||||
//update_use_power(0)
|
||||
use_power = 0 //don't force update - easier on CPU
|
||||
last_flow_rate = 0
|
||||
else
|
||||
handle_power_draw(power_draw)
|
||||
|
||||
|
||||
if(input.network)
|
||||
input.network.update = 1
|
||||
if(output.network)
|
||||
@@ -91,7 +85,7 @@
|
||||
for(var/datum/omni_port/P in filters)
|
||||
if(P.network)
|
||||
P.network.update = 1
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/omni/filter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
@@ -252,7 +246,7 @@
|
||||
P.mode = previous_mode
|
||||
if(P.mode != old_mode)
|
||||
handle_port_change(P)
|
||||
|
||||
|
||||
update_ports()
|
||||
|
||||
/obj/machinery/atmospherics/omni/filter/proc/rebuild_filtering_list()
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
var/tag_south_con
|
||||
var/tag_east_con
|
||||
var/tag_west_con
|
||||
|
||||
|
||||
var/max_flow_rate = 200
|
||||
var/set_flow_rate = 200
|
||||
|
||||
|
||||
var/list/mixing_inputs = list()
|
||||
|
||||
/obj/machinery/atmospherics/omni/mixer/New()
|
||||
@@ -45,7 +45,7 @@
|
||||
if(tag_west_con && tag_west == 1)
|
||||
P.concentration = tag_west_con
|
||||
con += max(0, tag_west_con)
|
||||
|
||||
|
||||
for(var/datum/omni_port/P in ports)
|
||||
P.air.volume = ATMOS_DEFAULT_VOLUME_MIXER
|
||||
|
||||
@@ -86,32 +86,26 @@
|
||||
return 1
|
||||
if(inputs.len < 2) //requires at least 2 inputs ~otherwise why are you using a mixer?
|
||||
return 1
|
||||
|
||||
|
||||
//concentration must add to 1
|
||||
var/total = 0
|
||||
for (var/datum/omni_port/P in inputs)
|
||||
total += P.concentration
|
||||
|
||||
|
||||
if (total != 1)
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
/obj/machinery/atmospherics/omni/mixer/process()
|
||||
..()
|
||||
if(error_check())
|
||||
on = 0
|
||||
|
||||
if((stat & (NOPOWER|BROKEN)) || !on)
|
||||
update_use_power(0) //usually we get here because a player turned a pump off - definitely want to update.
|
||||
last_flow_rate = 0
|
||||
return
|
||||
|
||||
if(!..())
|
||||
return 0
|
||||
|
||||
//Figure out the amount of moles to transfer
|
||||
var/transfer_moles = 0
|
||||
for (var/datum/omni_port/P in inputs)
|
||||
transfer_moles += (set_flow_rate*P.concentration/P.air.volume)*P.air.total_moles
|
||||
|
||||
|
||||
var/power_draw = -1
|
||||
if (transfer_moles > MINUMUM_MOLES_TO_FILTER)
|
||||
power_draw = mix_gas(src, mixing_inputs, output, transfer_moles, active_power_usage)
|
||||
@@ -122,14 +116,14 @@
|
||||
last_flow_rate = 0
|
||||
else
|
||||
handle_power_draw(power_draw)
|
||||
|
||||
|
||||
for(var/datum/omni_port/P in inputs)
|
||||
if(P.concentration && P.network)
|
||||
P.network.update = 1
|
||||
|
||||
if(output.network)
|
||||
output.network.update = 1
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/omni/mixer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
@@ -291,7 +285,7 @@
|
||||
P.concentration = new_con
|
||||
else if(!P.con_lock)
|
||||
P.concentration = remain_con
|
||||
|
||||
|
||||
rebuild_mixing_inputs()
|
||||
|
||||
/obj/machinery/atmospherics/omni/mixer/proc/rebuild_mixing_inputs()
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
/obj/machinery/atmospherics/omni/New()
|
||||
..()
|
||||
icon_state = "base"
|
||||
|
||||
|
||||
ports = new()
|
||||
for(var/d in cardinal)
|
||||
var/datum/omni_port/new_port = new(src, d)
|
||||
@@ -44,16 +44,14 @@
|
||||
if(new_port.mode > 0)
|
||||
initialize_directions |= d
|
||||
ports += new_port
|
||||
|
||||
|
||||
build_icons()
|
||||
|
||||
/obj/machinery/atmospherics/omni/update_icon()
|
||||
if(stat & NOPOWER)
|
||||
overlays = overlays_off
|
||||
on = 0
|
||||
else if(error_check())
|
||||
overlays = overlays_error
|
||||
on = 0
|
||||
else
|
||||
overlays = on ? (overlays_on) : (overlays_off)
|
||||
|
||||
@@ -64,6 +62,16 @@
|
||||
/obj/machinery/atmospherics/omni/proc/error_check()
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/omni/process()
|
||||
if(error_check())
|
||||
on = 0
|
||||
|
||||
if((stat & (NOPOWER|BROKEN)) || !on)
|
||||
update_use_power(0) //usually we get here because a player turned a pump off - definitely want to update.
|
||||
last_flow_rate = 0
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/omni/power_change()
|
||||
var/old_stat = stat
|
||||
..()
|
||||
@@ -173,7 +181,7 @@
|
||||
if(ATM_O2 to ATM_N2O)
|
||||
ic_on += "_filter"
|
||||
ic_off += "_out"
|
||||
|
||||
|
||||
ic_on = icon_manager.get_atmos_icon("omni", , , ic_on)
|
||||
ic_off = icon_manager.get_atmos_icon("omni", , , ic_off)
|
||||
|
||||
@@ -285,7 +293,7 @@
|
||||
P.node = null
|
||||
P.update = 1
|
||||
break
|
||||
|
||||
|
||||
update_ports()
|
||||
|
||||
return null
|
||||
Reference in New Issue
Block a user