mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-17 11:05:16 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
231 lines
8.2 KiB
Plaintext
231 lines
8.2 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 transferred 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/pump
|
|
icon_state = "pump_map-3"
|
|
name = "gas pump"
|
|
desc = "A pump that moves gas by pressure."
|
|
can_unwrench = TRUE
|
|
shift_underlay_only = FALSE
|
|
construction_type = /obj/item/pipe/directional
|
|
pipe_state = "pump"
|
|
vent_movement = NONE
|
|
///Pressure that the pump will reach when on
|
|
var/target_pressure = ONE_ATMOSPHERE
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/Initialize(mapload)
|
|
. = ..()
|
|
AddComponent(/datum/component/usb_port, typecacheof(list(/obj/item/circuit_component/atmos_pump), only_root_path = TRUE))
|
|
register_context()
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/add_context(atom/source, list/context, obj/item/held_item, mob/user)
|
|
. = ..()
|
|
context[SCREENTIP_CONTEXT_CTRL_LMB] = "Turn [on ? "off" : "on"]"
|
|
context[SCREENTIP_CONTEXT_ALT_LMB] = "Maximize target pressure"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/click_ctrl(mob/user)
|
|
if(is_operational)
|
|
set_on(!on)
|
|
balloon_alert(user, "turned [on ? "on" : "off"]")
|
|
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", INVESTIGATE_ATMOS)
|
|
return CLICK_ACTION_SUCCESS
|
|
return CLICK_ACTION_BLOCKING
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/click_alt(mob/user)
|
|
if(target_pressure == MAX_OUTPUT_PRESSURE)
|
|
return CLICK_ACTION_BLOCKING
|
|
|
|
target_pressure = MAX_OUTPUT_PRESSURE
|
|
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", INVESTIGATE_ATMOS)
|
|
balloon_alert(user, "pressure output set to [target_pressure] kPa")
|
|
update_appearance(UPDATE_ICON)
|
|
return CLICK_ACTION_SUCCESS
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/update_icon_nopipes()
|
|
icon_state = (on && is_operational) ? "pump_on-[set_overlay_offset(piping_layer)]" : "pump_off-[set_overlay_offset(piping_layer)]"
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/process_atmos()
|
|
if(!on || !is_operational)
|
|
return
|
|
|
|
var/datum/gas_mixture/input_air = airs[1]
|
|
var/datum/gas_mixture/output_air = airs[2]
|
|
var/datum/gas_mixture/output_pipenet_air = parents[2].air
|
|
|
|
if(input_air.pump_gas_to(output_air, target_pressure, output_pipenet_air = output_pipenet_air))
|
|
update_parents()
|
|
|
|
/obj/machinery/atmospherics/components/binary/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/pump/ui_data()
|
|
var/data = list()
|
|
data["on"] = on
|
|
data["pressure"] = round(target_pressure)
|
|
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
|
return data
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
switch(action)
|
|
if("power")
|
|
set_on(!on)
|
|
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", INVESTIGATE_ATMOS)
|
|
. = TRUE
|
|
if("pressure")
|
|
var/pressure = params["pressure"]
|
|
if(pressure == "max")
|
|
pressure = MAX_OUTPUT_PRESSURE
|
|
. = TRUE
|
|
else if(text2num(pressure) != null)
|
|
pressure = text2num(pressure)
|
|
. = TRUE
|
|
if(.)
|
|
target_pressure = clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
|
|
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
|
|
update_appearance(UPDATE_ICON)
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/can_unwrench(mob/user)
|
|
. = ..()
|
|
if(. && on && is_operational)
|
|
to_chat(user, span_warning("You cannot unwrench [src], turn it off first!"))
|
|
return FALSE
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/layer2
|
|
piping_layer = 2
|
|
icon_state= "pump_map-2"
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/layer4
|
|
piping_layer = 4
|
|
icon_state= "pump_map-4"
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/on
|
|
on = TRUE
|
|
icon_state = "pump_on_map-3"
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/on/layer2
|
|
piping_layer = 2
|
|
icon_state= "pump_on_map-2"
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/on/layer4
|
|
piping_layer = 4
|
|
icon_state= "pump_on_map-4"
|
|
|
|
/obj/machinery/atmospherics/components/binary/pump/on/layer5
|
|
piping_layer = 5
|
|
icon_state = "pump_on_map-5"
|
|
|
|
/obj/item/circuit_component/atmos_pump
|
|
display_name = "Atmospheric Binary Pump"
|
|
desc = "The interface for communicating with a pump."
|
|
|
|
///Set the target pressure of the pump
|
|
var/datum/port/input/pressure_value
|
|
///Activate the pump
|
|
var/datum/port/input/on
|
|
///Deactivate the pump
|
|
var/datum/port/input/off
|
|
///Signals the circuit to retrieve the pump's current pressure and temperature
|
|
var/datum/port/input/request_data
|
|
|
|
///Pressure of the input port
|
|
var/datum/port/output/input_pressure
|
|
///Pressure of the output port
|
|
var/datum/port/output/output_pressure
|
|
///Temperature of the input port
|
|
var/datum/port/output/input_temperature
|
|
///Temperature of the output port
|
|
var/datum/port/output/output_temperature
|
|
|
|
///Whether the pump is currently active
|
|
var/datum/port/output/is_active
|
|
///Send a signal when the pump is turned on
|
|
var/datum/port/output/turned_on
|
|
///Send a signal when the pump is turned off
|
|
var/datum/port/output/turned_off
|
|
|
|
///The component parent object
|
|
var/obj/machinery/atmospherics/components/binary/pump/connected_pump
|
|
|
|
/obj/item/circuit_component/atmos_pump/populate_ports()
|
|
pressure_value = add_input_port("New Pressure", PORT_TYPE_NUMBER, trigger = PROC_REF(set_pump_pressure))
|
|
on = add_input_port("Turn On", PORT_TYPE_SIGNAL, trigger = PROC_REF(set_pump_on))
|
|
off = add_input_port("Turn Off", PORT_TYPE_SIGNAL, trigger = PROC_REF(set_pump_off))
|
|
request_data = add_input_port("Request Port Data", PORT_TYPE_SIGNAL, trigger = PROC_REF(request_pump_data))
|
|
|
|
input_pressure = add_output_port("Input Pressure", PORT_TYPE_NUMBER)
|
|
output_pressure = add_output_port("Output Pressure", PORT_TYPE_NUMBER)
|
|
input_temperature = add_output_port("Input Temperature", PORT_TYPE_NUMBER)
|
|
output_temperature = add_output_port("Output Temperature", PORT_TYPE_NUMBER)
|
|
|
|
is_active = add_output_port("Active", PORT_TYPE_BOOLEAN)
|
|
turned_on = add_output_port("Turned On", PORT_TYPE_SIGNAL)
|
|
turned_off = add_output_port("Turned Off", PORT_TYPE_SIGNAL)
|
|
|
|
/obj/item/circuit_component/atmos_pump/register_usb_parent(atom/movable/shell)
|
|
. = ..()
|
|
if(istype(shell, /obj/machinery/atmospherics/components/binary/pump))
|
|
connected_pump = shell
|
|
RegisterSignal(connected_pump, COMSIG_ATMOS_MACHINE_SET_ON, PROC_REF(handle_pump_activation))
|
|
|
|
/obj/item/circuit_component/atmos_pump/unregister_usb_parent(atom/movable/shell)
|
|
UnregisterSignal(connected_pump, COMSIG_ATMOS_MACHINE_SET_ON)
|
|
connected_pump = null
|
|
return ..()
|
|
|
|
/obj/item/circuit_component/atmos_pump/pre_input_received(datum/port/input/port)
|
|
pressure_value.set_value(clamp(pressure_value.value, 0, MAX_OUTPUT_PRESSURE))
|
|
|
|
/obj/item/circuit_component/atmos_pump/proc/handle_pump_activation(datum/source, active)
|
|
SIGNAL_HANDLER
|
|
is_active.set_output(active)
|
|
if(active)
|
|
turned_on.set_output(COMPONENT_SIGNAL)
|
|
else
|
|
turned_off.set_output(COMPONENT_SIGNAL)
|
|
|
|
/obj/item/circuit_component/atmos_pump/proc/set_pump_pressure()
|
|
CIRCUIT_TRIGGER
|
|
if(!connected_pump)
|
|
return
|
|
connected_pump.target_pressure = pressure_value.value
|
|
|
|
/obj/item/circuit_component/atmos_pump/proc/set_pump_on()
|
|
CIRCUIT_TRIGGER
|
|
if(!connected_pump)
|
|
return
|
|
connected_pump.set_on(TRUE)
|
|
|
|
/obj/item/circuit_component/atmos_pump/proc/set_pump_off()
|
|
CIRCUIT_TRIGGER
|
|
if(!connected_pump)
|
|
return
|
|
connected_pump.set_on(FALSE)
|
|
connected_pump.update_appearance(UPDATE_ICON)
|
|
|
|
/obj/item/circuit_component/atmos_pump/proc/request_pump_data()
|
|
CIRCUIT_TRIGGER
|
|
if(!connected_pump)
|
|
return
|
|
var/datum/gas_mixture/air_input = connected_pump.airs[1]
|
|
var/datum/gas_mixture/air_output = connected_pump.airs[2]
|
|
input_pressure.set_output(air_input.return_pressure())
|
|
output_pressure.set_output(air_output.return_pressure())
|
|
input_temperature.set_output(air_input.return_temperature())
|
|
output_temperature.set_output(air_output.return_temperature())
|