mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
Everything that called turf.assume_air and turf.remove_air was already updating turfs, and all that not tying the two together did was add more boiler plate, and break things when people forgot about it. This shouldn't add any overhead outside of hotspots, but I think that's trivial
225 lines
7.1 KiB
Plaintext
225 lines
7.1 KiB
Plaintext
// Every cycle, the pump uses the air in air_in to try and make air_out the perfect pressure.
|
|
//
|
|
// node1, air1, network1 correspond to input
|
|
// node2, air2, network2 correspond to output
|
|
//
|
|
// Thus, the two variables affect pump operation are set in New():
|
|
// air1.volume
|
|
// This is the volume of gas available to the pump that may be transfered to the output
|
|
// air2.volume
|
|
// Higher quantities of this cause more air to be perfected later
|
|
// but overall network volume is also increased as this increases...
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump
|
|
icon_state = "volpump_map-3"
|
|
name = "volumetric gas pump"
|
|
desc = "A pump that moves gas by volume."
|
|
can_unwrench = TRUE
|
|
shift_underlay_only = FALSE
|
|
construction_type = /obj/item/pipe/directional
|
|
pipe_state = "volumepump"
|
|
vent_movement = NONE
|
|
///Transfer rate of the component in L/s
|
|
var/transfer_rate = MAX_TRANSFER_RATE
|
|
///Check if the component has been overclocked
|
|
var/overclocked = FALSE
|
|
///Frequency for radio signaling
|
|
var/frequency = 0
|
|
///ID for radio signaling
|
|
var/id = null
|
|
///Connection to the radio processing
|
|
var/datum/radio_frequency/radio_connection
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/CtrlClick(mob/user)
|
|
if(can_interact(user))
|
|
on = !on
|
|
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", INVESTIGATE_ATMOS)
|
|
update_appearance()
|
|
return ..()
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/AltClick(mob/user)
|
|
if(can_interact(user))
|
|
transfer_rate = MAX_TRANSFER_RATE
|
|
investigate_log("was set to [transfer_rate] L/s by [key_name(user)]", INVESTIGATE_ATMOS)
|
|
to_chat(user, "<span class='notice'>You maximize the volume output on [src] to [transfer_rate] L/s.</span>")
|
|
update_appearance()
|
|
return ..()
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/Destroy()
|
|
SSradio.remove_object(src,frequency)
|
|
return ..()
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/update_icon_nopipes()
|
|
icon_state = on && is_operational ? "volpump_on-[set_overlay_offset(piping_layer)]" : "volpump_off-[set_overlay_offset(piping_layer)]"
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/process_atmos()
|
|
if(!on || !is_operational)
|
|
return
|
|
|
|
var/datum/gas_mixture/air1 = airs[1]
|
|
var/datum/gas_mixture/air2 = airs[2]
|
|
|
|
// Pump mechanism just won't do anything if the pressure is too high/too low unless you overclock it.
|
|
|
|
var/input_starting_pressure = air1.return_pressure()
|
|
var/output_starting_pressure = air2.return_pressure()
|
|
|
|
if((input_starting_pressure < 0.01) || ((output_starting_pressure > 9000))&&!overclocked)
|
|
return
|
|
|
|
if(overclocked && (output_starting_pressure-input_starting_pressure > 1000))//Overclocked pumps can only force gas a certain amount.
|
|
return
|
|
|
|
|
|
var/transfer_ratio = transfer_rate / air1.volume
|
|
|
|
var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio)
|
|
|
|
if(!removed.total_moles())
|
|
return
|
|
|
|
if(overclocked)//Some of the gas from the mixture leaks to the environment when overclocked
|
|
var/turf/open/T = loc
|
|
if(istype(T))
|
|
var/datum/gas_mixture/leaked = removed.remove_ratio(VOLUME_PUMP_LEAK_AMOUNT)
|
|
T.assume_air(leaked)
|
|
|
|
air2.merge(removed)
|
|
|
|
update_parents()
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/examine(mob/user)
|
|
. = ..()
|
|
if(overclocked)
|
|
. += "Its warning light is on[on ? " and it's spewing gas!" : "."]"
|
|
|
|
/**
|
|
* Called in atmosinit(), used to change or remove the radio frequency from the component
|
|
* Arguments:
|
|
* * -new_frequency: the frequency that should be used for the radio to attach to the component, use 0 to remove the radio
|
|
*/
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/proc/set_frequency(new_frequency)
|
|
SSradio.remove_object(src, frequency)
|
|
frequency = new_frequency
|
|
if(frequency)
|
|
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
|
|
|
|
/**
|
|
* Called in atmosinit(), send the component status to the radio device connected
|
|
*/
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/proc/broadcast_status()
|
|
if(!radio_connection)
|
|
return
|
|
|
|
var/datum/signal/signal = new(list(
|
|
"tag" = id,
|
|
"device" = "APV",
|
|
"power" = on,
|
|
"transfer_rate" = transfer_rate,
|
|
"sigtype" = "status"
|
|
))
|
|
radio_connection.post_signal(src, signal)
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "AtmosPump", name)
|
|
ui.open()
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/ui_data()
|
|
var/data = list()
|
|
data["on"] = on
|
|
data["rate"] = round(transfer_rate)
|
|
data["max_rate"] = round(MAX_TRANSFER_RATE)
|
|
return data
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/atmosinit()
|
|
. = ..()
|
|
|
|
set_frequency(frequency)
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/ui_act(action, params)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
switch(action)
|
|
if("power")
|
|
on = !on
|
|
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", INVESTIGATE_ATMOS)
|
|
. = TRUE
|
|
if("rate")
|
|
var/rate = params["rate"]
|
|
if(rate == "max")
|
|
rate = MAX_TRANSFER_RATE
|
|
. = TRUE
|
|
else if(text2num(rate) != null)
|
|
rate = text2num(rate)
|
|
. = TRUE
|
|
if(.)
|
|
transfer_rate = clamp(rate, 0, MAX_TRANSFER_RATE)
|
|
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", INVESTIGATE_ATMOS)
|
|
update_appearance()
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/receive_signal(datum/signal/signal)
|
|
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
|
|
return
|
|
|
|
var/old_on = on //for logging
|
|
|
|
if("power" in signal.data)
|
|
on = text2num(signal.data["power"])
|
|
|
|
if("power_toggle" in signal.data)
|
|
on = !on
|
|
|
|
if("set_transfer_rate" in signal.data)
|
|
var/datum/gas_mixture/air1 = airs[1]
|
|
transfer_rate = clamp(text2num(signal.data["set_transfer_rate"]),0,air1.volume)
|
|
|
|
if(on != old_on)
|
|
investigate_log("was turned [on ? "on" : "off"] by a remote signal", INVESTIGATE_ATMOS)
|
|
|
|
if("status" in signal.data)
|
|
broadcast_status()
|
|
return //do not update_appearance
|
|
|
|
broadcast_status()
|
|
update_appearance()
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/can_unwrench(mob/user)
|
|
. = ..()
|
|
if(. && on && is_operational)
|
|
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
|
|
return FALSE
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/multitool_act(mob/living/user, obj/item/I)
|
|
if(!overclocked)
|
|
overclocked = TRUE
|
|
to_chat(user, "The pump makes a grinding noise and air starts to hiss out as you disable its pressure limits.")
|
|
else
|
|
overclocked = FALSE
|
|
to_chat(user, "The pump quiets down as you turn its limiters back on.")
|
|
return TRUE
|
|
|
|
// mapping
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/layer2
|
|
piping_layer = 2
|
|
icon_state = "volpump_map-2"
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/layer2
|
|
piping_layer = 2
|
|
icon_state = "volpump_map-2"
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/on
|
|
on = TRUE
|
|
icon_state = "volpump_on_map"
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/on/layer2
|
|
piping_layer = 2
|
|
icon_state = "volpump_map-2"
|
|
|
|
/obj/machinery/atmospherics/components/binary/volume_pump/on/layer4
|
|
piping_layer = 4
|
|
icon_state = "volpump_map-4"
|