Files
+37 21b4095dfd [MDB IGNORE] [IDB IGNORE] Upstream Sync - 04/17/2026 (#5453)
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>
2026-05-16 00:56:00 +02:00

194 lines
6.5 KiB
Plaintext

/*
It's like a regular ol' straight pipe, but you can turn it on and off.
*/
#define MANUAL_VALVE "m"
#define DIGITAL_VALVE "d"
/obj/machinery/atmospherics/components/binary/valve
icon_state = "mvalve_map-3"
name = "manual valve"
desc = "A pipe with a valve that can be used to disable flow of gas through it."
can_unwrench = TRUE
shift_underlay_only = FALSE
interaction_flags_machine = INTERACT_MACHINE_OFFLINE | INTERACT_MACHINE_OPEN //Intentionally no allow_silicon flag
pipe_flags = PIPING_CARDINAL_AUTONORMALIZE | PIPING_BRIDGE
construction_type = /obj/item/pipe/binary
pipe_state = "mvalve"
custom_reconcilation = TRUE
use_power = NO_POWER_USE
///Type of valve (manual or digital), used to set the icon of the component in update_icon_nopipes()
var/valve_type = MANUAL_VALVE
///Bool to stop interactions while the opening/closing animation is going
var/switching = FALSE
/obj/machinery/atmospherics/components/binary/valve/update_icon_nopipes(animation = FALSE)
normalize_cardinal_directions()
if(animation)
flick("[valve_type]valve_[on][!on]-[set_overlay_offset(piping_layer)]", src)
playsound(src, 'sound/effects/valve_opening.ogg', 50)
icon_state = "[valve_type]valve_[on ? "on" : "off"]-[set_overlay_offset(piping_layer)]"
/**
* Called by finish_interact(), switch between open and closed, reconcile the air between two pipelines
*/
/obj/machinery/atmospherics/components/binary/valve/proc/set_open(to_open)
if(on == to_open)
return
SEND_SIGNAL(src, COMSIG_VALVE_SET_OPEN, to_open)
. = on
set_on(to_open)
if(on)
playsound(src, 'sound/effects/gas_hissing.ogg', 50)
update_parents()
var/datum/pipeline/parent1 = parents[1]
parent1.reconcile_air()
investigate_log("was opened by [usr ? key_name(usr) : "a remote signal"]", INVESTIGATE_ATMOS)
balloon_alert_to_viewers("valve opened")
vent_movement |= VENTCRAWL_ALLOWED
else
investigate_log("was closed by [usr ? key_name(usr) : "a remote signal"]", INVESTIGATE_ATMOS)
balloon_alert_to_viewers("valve closed")
vent_movement &= ~VENTCRAWL_ALLOWED
// This is what handles the actual functionality of combining 2 pipenets when the valve is open
// Basically when a pipenet updates it will consider both sides to be the same for the purpose of the gas update
/obj/machinery/atmospherics/components/binary/valve/return_pipenets_for_reconcilation(datum/pipeline/requester)
. = ..()
if(!on)
return
. |= parents[1]
. |= parents[2]
/obj/machinery/atmospherics/components/binary/valve/interact(mob/user)
add_fingerprint(usr)
if(switching)
return
update_icon_nopipes(TRUE)
switching = TRUE
addtimer(CALLBACK(src, PROC_REF(finish_interact)), 1 SECONDS)
/**
* Called by iteract() after a 1 second timer, calls toggle(), allows another interaction with the component.
*/
/obj/machinery/atmospherics/components/binary/valve/proc/finish_interact()
set_open(!on)
switching = FALSE
/obj/machinery/atmospherics/components/binary/valve/digital // can be controlled by AI
icon_state = "dvalve_map-3"
name = "digital valve"
desc = "A digitally controlled valve."
valve_type = DIGITAL_VALVE
pipe_state = "dvalve"
interaction_flags_machine = INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OFFLINE | INTERACT_MACHINE_OPEN | INTERACT_MACHINE_OPEN_SILICON
/obj/machinery/atmospherics/components/binary/valve/digital/Initialize(mapload)
. = ..()
AddComponent(/datum/component/usb_port, typecacheof(list(/obj/item/circuit_component/digital_valve), only_root_path = TRUE))
/obj/item/circuit_component/digital_valve
display_name = "Digital Valve"
desc = "The interface for communicating with a digital valve."
var/obj/machinery/atmospherics/components/binary/valve/digital/attached_valve
/// Opens the digital valve
var/datum/port/input/open
/// Closes the digital valve
var/datum/port/input/close
/// Whether the valve is currently open
var/datum/port/output/is_open
/// Sent when the valve is opened
var/datum/port/output/opened
/// Sent when the valve is closed
var/datum/port/output/closed
/obj/item/circuit_component/digital_valve/populate_ports()
open = add_input_port("Open", PORT_TYPE_SIGNAL)
close = add_input_port("Close", PORT_TYPE_SIGNAL)
is_open = add_output_port("Is Open", PORT_TYPE_BOOLEAN)
opened = add_output_port("Opened", PORT_TYPE_SIGNAL)
closed = add_output_port("Closed", PORT_TYPE_SIGNAL)
/obj/item/circuit_component/digital_valve/register_usb_parent(atom/movable/shell)
. = ..()
if(istype(shell, /obj/machinery/atmospherics/components/binary/valve/digital))
attached_valve = shell
RegisterSignal(attached_valve, COMSIG_VALVE_SET_OPEN, PROC_REF(handle_valve_toggled))
/obj/item/circuit_component/digital_valve/unregister_usb_parent(atom/movable/shell)
UnregisterSignal(attached_valve, COMSIG_VALVE_SET_OPEN)
attached_valve = null
return ..()
/obj/item/circuit_component/digital_valve/proc/handle_valve_toggled(datum/source, on)
SIGNAL_HANDLER
is_open.set_output(on)
if(on)
opened.set_output(COMPONENT_SIGNAL)
else
closed.set_output(COMPONENT_SIGNAL)
/obj/item/circuit_component/digital_valve/input_received(datum/port/input/port)
if(!attached_valve)
return
if(COMPONENT_TRIGGERED_BY(open, port) && !attached_valve.on)
attached_valve.set_open(TRUE)
if(COMPONENT_TRIGGERED_BY(close, port) && attached_valve.on)
attached_valve.set_open(FALSE)
/obj/machinery/atmospherics/components/binary/valve/digital/update_icon_nopipes(animation)
if(!is_operational)
normalize_cardinal_directions()
icon_state = "dvalve_nopower-[set_overlay_offset(piping_layer)]"
return
return..()
/obj/machinery/atmospherics/components/binary/valve/layer2
piping_layer = 2
icon_state = "mvalve_map-2"
/obj/machinery/atmospherics/components/binary/valve/layer4
piping_layer = 4
icon_state = "mvalve_map-4"
/obj/machinery/atmospherics/components/binary/valve/on
on = TRUE
/obj/machinery/atmospherics/components/binary/valve/on/layer2
piping_layer = 2
icon_state = "mvalve_map-2"
/obj/machinery/atmospherics/components/binary/valve/on/layer4
piping_layer = 4
icon_state = "mvalve_map-4"
/obj/machinery/atmospherics/components/binary/valve/digital/layer2
piping_layer = 2
icon_state = "dvalve_map-2"
/obj/machinery/atmospherics/components/binary/valve/digital/layer4
piping_layer = 4
icon_state = "dvalve_map-4"
/obj/machinery/atmospherics/components/binary/valve/digital/on
on = TRUE
/obj/machinery/atmospherics/components/binary/valve/digital/on/layer2
piping_layer = 2
icon_state = "dvalve_map-2"
/obj/machinery/atmospherics/components/binary/valve/digital/on/layer4
piping_layer = 4
icon_state = "dvalve_map-4"
#undef MANUAL_VALVE
#undef DIGITAL_VALVE