157 lines
5.1 KiB
Plaintext
157 lines
5.1 KiB
Plaintext
#define PUMP_OUT "out"
|
|
#define PUMP_IN "in"
|
|
#define PUMP_MAX_PRESSURE (ONE_ATMOSPHERE * 25)
|
|
#define PUMP_MIN_PRESSURE (ONE_ATMOSPHERE / 10)
|
|
#define PUMP_DEFAULT_PRESSURE (ONE_ATMOSPHERE)
|
|
|
|
/obj/machinery/portable_atmospherics/pump
|
|
name = "portable air pump"
|
|
icon_state = "psiphon:0"
|
|
density = TRUE
|
|
|
|
var/on = FALSE
|
|
var/direction = PUMP_OUT
|
|
var/obj/machinery/atmospherics/components/binary/pump/pump
|
|
|
|
volume = 1000
|
|
|
|
/obj/machinery/portable_atmospherics/pump/Initialize()
|
|
. = ..()
|
|
pump = new(src, FALSE)
|
|
pump.on = TRUE
|
|
pump.stat = 0
|
|
pump.build_network()
|
|
|
|
/obj/machinery/portable_atmospherics/pump/Destroy()
|
|
var/turf/T = get_turf(src)
|
|
T.assume_air(air_contents)
|
|
air_update_turf()
|
|
QDEL_NULL(pump)
|
|
return ..()
|
|
|
|
/obj/machinery/portable_atmospherics/pump/update_icon()
|
|
icon_state = "psiphon:[on]"
|
|
|
|
cut_overlays()
|
|
if(holding)
|
|
add_overlay("siphon-open")
|
|
if(connected_port)
|
|
add_overlay("siphon-connector")
|
|
|
|
/obj/machinery/portable_atmospherics/pump/process_atmos()
|
|
..()
|
|
if(!on)
|
|
pump.airs[1] = null
|
|
pump.airs[2] = null
|
|
return
|
|
|
|
var/turf/T = get_turf(src)
|
|
if(direction == PUMP_OUT) // Hook up the internal pump.
|
|
pump.airs[1] = holding ? holding.air_contents : air_contents
|
|
pump.airs[2] = holding ? air_contents : T.return_air()
|
|
else
|
|
pump.airs[1] = holding ? air_contents : T.return_air()
|
|
pump.airs[2] = holding ? holding.air_contents : air_contents
|
|
|
|
pump.process_atmos() // Pump gas.
|
|
if(!holding)
|
|
air_update_turf() // Update the environment if needed.
|
|
|
|
/obj/machinery/portable_atmospherics/pump/emp_act(severity)
|
|
. = ..()
|
|
if(. & EMP_PROTECT_SELF)
|
|
return
|
|
if(is_operational())
|
|
if(prob(50 / severity))
|
|
on = !on
|
|
if(prob(100 / severity))
|
|
direction = PUMP_OUT
|
|
pump.target_pressure = rand(0, 100 * ONE_ATMOSPHERE)
|
|
update_icon()
|
|
|
|
/obj/machinery/portable_atmospherics/pump/replace_tank(mob/living/user, close_valve)
|
|
. = ..()
|
|
if(.)
|
|
if(close_valve)
|
|
if(on)
|
|
on = FALSE
|
|
update_icon()
|
|
else if(on && holding && direction == PUMP_OUT)
|
|
investigate_log("[key_name(user)] started a transfer into [holding].<br>", INVESTIGATE_ATMOS)
|
|
|
|
|
|
/obj/machinery/portable_atmospherics/pump/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \
|
|
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.physical_state)
|
|
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
|
if(!ui)
|
|
ui = new(user, src, ui_key, "portable_pump", name, 420, 415, master_ui, state)
|
|
ui.open()
|
|
|
|
/obj/machinery/portable_atmospherics/pump/ui_data()
|
|
var/data = list()
|
|
data["on"] = on
|
|
data["direction"] = direction
|
|
data["connected"] = connected_port ? 1 : 0
|
|
data["pressure"] = round(air_contents.return_pressure() ? air_contents.return_pressure() : 0)
|
|
data["target_pressure"] = round(pump.target_pressure ? pump.target_pressure : 0)
|
|
data["default_pressure"] = round(PUMP_DEFAULT_PRESSURE)
|
|
data["min_pressure"] = round(PUMP_MIN_PRESSURE)
|
|
data["max_pressure"] = round(PUMP_MAX_PRESSURE)
|
|
|
|
if(holding)
|
|
data["holding"] = list()
|
|
data["holding"]["name"] = holding.name
|
|
data["holding"]["pressure"] = round(holding.air_contents.return_pressure())
|
|
return data
|
|
|
|
/obj/machinery/portable_atmospherics/pump/ui_act(action, params)
|
|
if(..())
|
|
return
|
|
switch(action)
|
|
if("power")
|
|
on = !on
|
|
if(on && !holding)
|
|
var/plasma = air_contents.gases[/datum/gas/plasma]
|
|
var/n2o = air_contents.gases[/datum/gas/nitrous_oxide]
|
|
if(n2o || plasma)
|
|
message_admins("[ADMIN_LOOKUPFLW(usr)] turned on a pump that contains [n2o ? "N2O" : ""][n2o && plasma ? " & " : ""][plasma ? "Plasma" : ""] at [ADMIN_VERBOSEJMP(src)]")
|
|
log_admin("[key_name(usr)] turned on a pump that contains [n2o ? "N2O" : ""][n2o && plasma ? " & " : ""][plasma ? "Plasma" : ""] at [AREACOORD(src)]")
|
|
else if(on && direction == PUMP_OUT)
|
|
investigate_log("[key_name(usr)] started a transfer into [holding].<br>", INVESTIGATE_ATMOS)
|
|
. = TRUE
|
|
if("direction")
|
|
if(direction == PUMP_OUT)
|
|
direction = PUMP_IN
|
|
else
|
|
if(on && holding)
|
|
investigate_log("[key_name(usr)] started a transfer into [holding].<br>", INVESTIGATE_ATMOS)
|
|
direction = PUMP_OUT
|
|
. = TRUE
|
|
if("pressure")
|
|
var/pressure = params["pressure"]
|
|
if(pressure == "reset")
|
|
pressure = PUMP_DEFAULT_PRESSURE
|
|
. = TRUE
|
|
else if(pressure == "min")
|
|
pressure = PUMP_MIN_PRESSURE
|
|
. = TRUE
|
|
else if(pressure == "max")
|
|
pressure = PUMP_MAX_PRESSURE
|
|
. = TRUE
|
|
else if(pressure == "input")
|
|
pressure = input("New release pressure ([PUMP_MIN_PRESSURE]-[PUMP_MAX_PRESSURE] kPa):", name, pump.target_pressure) as num|null
|
|
if(!isnull(pressure) && !..())
|
|
. = TRUE
|
|
else if(text2num(pressure) != null)
|
|
pressure = text2num(pressure)
|
|
. = TRUE
|
|
if(.)
|
|
pump.target_pressure = CLAMP(round(pressure), PUMP_MIN_PRESSURE, PUMP_MAX_PRESSURE)
|
|
investigate_log("was set to [pump.target_pressure] kPa by [key_name(usr)].", INVESTIGATE_ATMOS)
|
|
if("eject")
|
|
if(holding)
|
|
holding.forceMove(drop_location())
|
|
holding = null
|
|
. = TRUE
|
|
update_icon()
|