Merge pull request #582 from ArchieBeepBoop/newthings

More Atmos - Relief Valves & Passive Vents
This commit is contained in:
QuoteFox
2020-10-12 15:34:40 +01:00
committed by GitHub
11 changed files with 330 additions and 21 deletions

View File

@@ -19,12 +19,14 @@ GLOBAL_LIST_INIT(atmos_pipe_recipes, list(
new /datum/pipe_info/pipe("Manifold", /obj/machinery/atmospherics/pipe/manifold),
new /datum/pipe_info/pipe("Manual Valve", /obj/machinery/atmospherics/components/binary/valve),
new /datum/pipe_info/pipe("Digital Valve", /obj/machinery/atmospherics/components/binary/valve/digital),
new /datum/pipe_info/pipe("Relief Valve", /obj/machinery/atmospherics/components/binary/relief_valve),
new /datum/pipe_info/pipe("4-Way Manifold", /obj/machinery/atmospherics/pipe/manifold4w),
new /datum/pipe_info/pipe("Layer Manifold", /obj/machinery/atmospherics/pipe/layer_manifold),
),
"Devices" = list(
new /datum/pipe_info/pipe("Connector", /obj/machinery/atmospherics/components/unary/portables_connector),
new /datum/pipe_info/pipe("Unary Vent", /obj/machinery/atmospherics/components/unary/vent_pump),
new /datum/pipe_info/pipe("Relief Valve", /obj/machinery/atmospherics/components/unary/relief_valve),
new /datum/pipe_info/pipe("Gas Pump", /obj/machinery/atmospherics/components/binary/pump),
new /datum/pipe_info/pipe("Passive Gate", /obj/machinery/atmospherics/components/binary/passive_gate),
new /datum/pipe_info/pipe("Volume Pump", /obj/machinery/atmospherics/components/binary/volume_pump),
@@ -33,6 +35,7 @@ GLOBAL_LIST_INIT(atmos_pipe_recipes, list(
new /datum/pipe_info/meter("Meter"),
new /datum/pipe_info/pipe("Gas Filter", /obj/machinery/atmospherics/components/trinary/filter),
new /datum/pipe_info/pipe("Gas Mixer", /obj/machinery/atmospherics/components/trinary/mixer),
new /datum/pipe_info/pipe("Passive Vent", /obj/machinery/atmospherics/components/unary/passive_vent),
),
"Heat Exchange" = list(
new /datum/pipe_info/pipe("Pipe", /obj/machinery/atmospherics/pipe/heat_exchanging/simple),

View File

@@ -0,0 +1,111 @@
/obj/machinery/atmospherics/components/binary/relief_valve
name = "binary pressure relief valve"
desc = "Like a manual valve, but opens at a certain pressure rather than being toggleable."
icon = 'icons/obj/atmospherics/components/relief_valve.dmi'
icon_state = "relief_valve-t-map"
can_unwrench = TRUE
construction_type = /obj/item/pipe/binary
interaction_flags_machine = INTERACT_MACHINE_OFFLINE | INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_SET_MACHINE
var/opened = FALSE
var/open_pressure = ONE_ATMOSPHERE * 3
var/close_pressure = ONE_ATMOSPHERE
pipe_state = "relief_valve-t"
/obj/machinery/atmospherics/components/binary/relief_valve/layer1
piping_layer = PIPING_LAYER_MIN
pixel_x = -PIPING_LAYER_P_X
pixel_y = -PIPING_LAYER_P_Y
/obj/machinery/atmospherics/components/binary/relief_valve/layer3
piping_layer = PIPING_LAYER_MAX
pixel_x = PIPING_LAYER_P_X
pixel_y = PIPING_LAYER_P_Y
/obj/machinery/atmospherics/components/binary/relief_valve/update_icon_nopipes()
if(dir==SOUTH)
setDir(NORTH)
else if(dir==WEST)
setDir(EAST)
cut_overlays()
if(!nodes[1] || !opened || !is_operational())
icon_state = "relief_valve-t"
return
icon_state = "relief_valve-t-blown"
/obj/machinery/atmospherics/components/binary/relief_valve/proc/open()
opened = TRUE
update_icon_nopipes()
update_parents()
var/datum/pipeline/parent1 = parents[1]
parent1.reconcile_air()
/obj/machinery/atmospherics/components/binary/relief_valve/proc/close()
opened = FALSE
update_icon_nopipes()
/obj/machinery/atmospherics/components/binary/relief_valve/process_atmos()
..()
if(!is_operational())
return
var/datum/gas_mixture/air_one = airs[1]
var/datum/gas_mixture/air_two = airs[2]
var/air_one_pressure = air_one.return_pressure()
var/our_pressure = abs(air_one_pressure - air_two.return_pressure())
if(opened && air_one_pressure < close_pressure)
close()
else if(!opened && our_pressure >= open_pressure)
open()
/obj/machinery/atmospherics/components/binary/relief_valve/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_relief", name, 335, 115, master_ui, state)
ui.open()
/obj/machinery/atmospherics/components/binary/relief_valve/ui_data()
var/data = list()
data["open_pressure"] = round(open_pressure)
data["close_pressure"] = round(close_pressure)
data["max_pressure"] = round(50*ONE_ATMOSPHERE)
return data
/obj/machinery/atmospherics/components/binary/relief_valve/ui_act(action, params)
if(..())
return
switch(action)
if("open_pressure")
var/pressure = params["open_pressure"]
if(pressure == "max")
pressure = 50*ONE_ATMOSPHERE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure ([close_pressure]-[50*ONE_ATMOSPHERE] kPa):", name, open_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
open_pressure = CLAMP(pressure, close_pressure, 50*ONE_ATMOSPHERE)
investigate_log("open pressure was set to [open_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
if("close_pressure")
var/pressure = params["close_pressure"]
if(pressure == "max")
pressure = open_pressure
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[open_pressure] kPa):", name, close_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
close_pressure = CLAMP(pressure, 0, open_pressure)
investigate_log("close pressure was set to [close_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
update_icon()

View File

@@ -0,0 +1,63 @@
/obj/machinery/atmospherics/components/unary/passive_vent
icon_state = "passive_vent_map-2"
name = "passive vent"
desc = "It is an open vent."
can_unwrench = TRUE
level = 1
layer = GAS_SCRUBBER_LAYER
pipe_state = "pvent"
/obj/machinery/atmospherics/components/unary/passive_vent/update_icon_nopipes()
cut_overlays()
if(showpipe)
var/image/cap = getpipeimage(icon, "vent_cap", initialize_directions)
add_overlay(cap)
icon_state = "passive_vent"
/obj/machinery/atmospherics/components/unary/passive_vent/process_atmos()
..()
var/active = FALSE
var/datum/gas_mixture/external = loc.return_air()
var/datum/gas_mixture/internal = airs[1]
var/external_pressure = external.return_pressure()
var/internal_pressure = internal.return_pressure()
var/pressure_delta = abs(external_pressure - internal_pressure)
if(pressure_delta > 0.5)
if(external_pressure < internal_pressure)
var/air_temperature = (external.temperature > 0) ? external.temperature : internal.temperature
var/transfer_moles = (pressure_delta * external.volume) / (air_temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = internal.remove(transfer_moles)
external.merge(removed)
else
var/air_temperature = (internal.temperature > 0) ? internal.temperature : external.temperature
var/transfer_moles = (pressure_delta * internal.volume) / (air_temperature * R_IDEAL_GAS_EQUATION)
transfer_moles = min(transfer_moles, external.total_moles() * internal.volume / external.volume)
var/datum/gas_mixture/removed = external.remove(transfer_moles)
if(isnull(removed))
return
internal.merge(removed)
active = TRUE
active = internal.temperature_share(external, OPEN_HEAT_TRANSFER_COEFFICIENT) ? TRUE : active
if(active)
air_update_turf()
update_parents()
/obj/machinery/atmospherics/components/unary/passive_vent/can_crawl_through()
return TRUE
/obj/machinery/atmospherics/components/unary/passive_vent/layer1
piping_layer = PIPING_LAYER_MIN
icon_state = "passive_vent_map-1"
/obj/machinery/atmospherics/components/unary/passive_vent/layer3
piping_layer = PIPING_LAYER_MAX
icon_state = "passive_vent_map-3"

View File

@@ -0,0 +1,112 @@
/obj/machinery/atmospherics/components/unary/relief_valve
name = "pressure relief valve"
desc = "A valve that opens to the air at a certain pressure, then closes once it goes below another."
icon = 'icons/obj/atmospherics/components/relief_valve.dmi'
icon_state = "relief_valve-e-map"
can_unwrench = TRUE
interaction_flags_machine = INTERACT_MACHINE_OFFLINE | INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_SET_MACHINE
var/opened = FALSE
var/open_pressure = ONE_ATMOSPHERE * 3
var/close_pressure = ONE_ATMOSPHERE
pipe_state = "relief_valve-e"
/obj/machinery/atmospherics/components/unary/relief_valve/layer1
piping_layer = PIPING_LAYER_MIN
pixel_x = -PIPING_LAYER_P_X
pixel_y = -PIPING_LAYER_P_Y
/obj/machinery/atmospherics/components/unary/relief_valve/layer3
piping_layer = PIPING_LAYER_MAX
pixel_x = PIPING_LAYER_P_X
pixel_y = PIPING_LAYER_P_Y
/obj/machinery/atmospherics/components/unary/relief_valve/atmos
close_pressure = ONE_ATMOSPHERE * 2
/obj/machinery/atmospherics/components/unary/relief_valve/atmos/atmos_waste
name = "atmos waste relief valve"
/obj/machinery/atmospherics/components/unary/relief_valve/update_icon_nopipes()
cut_overlays()
if(!nodes[1] || !opened || !is_operational())
icon_state = "relief_valve-e"
return
icon_state = "relief_valve-e-blown"
/obj/machinery/atmospherics/components/unary/relief_valve/process_atmos()
..()
if(!is_operational())
return
var/datum/gas_mixture/air_contents = airs[1]
var/our_pressure = air_contents.return_pressure()
if(opened && our_pressure < close_pressure)
opened = FALSE
update_icon_nopipes()
else if(!opened && our_pressure >= open_pressure)
opened = TRUE
update_icon_nopipes()
if(opened && air_contents.temperature > 0)
var/datum/gas_mixture/environment = loc.return_air()
var/pressure_delta = our_pressure - environment.return_pressure()
var/transfer_moles = pressure_delta*200/(air_contents.temperature * R_IDEAL_GAS_EQUATION)
if(transfer_moles > 0)
var/datum/gas_mixture/removed = air_contents.remove(transfer_moles)
loc.assume_air(removed)
air_update_turf()
update_parents()
/obj/machinery/atmospherics/components/unary/relief_valve/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_relief", name, 335, 115, master_ui, state)
ui.open()
/obj/machinery/atmospherics/components/unary/relief_valve/ui_data()
var/data = list()
data["open_pressure"] = round(open_pressure)
data["close_pressure"] = round(close_pressure)
data["max_pressure"] = round(50*ONE_ATMOSPHERE)
return data
/obj/machinery/atmospherics/components/unary/relief_valve/ui_act(action, params)
if(..())
return
switch(action)
if("open_pressure")
var/pressure = params["open_pressure"]
if(pressure == "max")
pressure = 50*ONE_ATMOSPHERE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure ([close_pressure]-[50*ONE_ATMOSPHERE] kPa):", name, open_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
open_pressure = CLAMP(pressure, close_pressure, 50*ONE_ATMOSPHERE)
investigate_log("open pressure was set to [open_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
if("close_pressure")
var/pressure = params["close_pressure"]
if(pressure == "max")
pressure = open_pressure
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[open_pressure] kPa):", name, close_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
close_pressure = CLAMP(pressure, 0, open_pressure)
investigate_log("close pressure was set to [close_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
update_icon()

View File

@@ -227,6 +227,11 @@
if(V.on)
PL |= V.parents[1]
PL |= V.parents[2]
else if (istype(atmosmch,/obj/machinery/atmospherics/components/binary/relief_valve))
var/obj/machinery/atmospherics/components/binary/relief_valve/V = atmosmch
if(V.opened)
PL |= V.parents[1]
PL |= V.parents[2]
else if (istype(atmosmch, /obj/machinery/atmospherics/components/unary/portables_connector))
var/obj/machinery/atmospherics/components/unary/portables_connector/C = atmosmch
if(C.connected_device)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -1403,6 +1403,7 @@
#include "code\modules\atmospherics\machinery\components\binary_devices\dp_vent_pump.dm"
#include "code\modules\atmospherics\machinery\components\binary_devices\passive_gate.dm"
#include "code\modules\atmospherics\machinery\components\binary_devices\pump.dm"
#include "code\modules\atmospherics\machinery\components\binary_devices\relief_valve.dm"
#include "code\modules\atmospherics\machinery\components\binary_devices\valve.dm"
#include "code\modules\atmospherics\machinery\components\binary_devices\volume_pump.dm"
#include "code\modules\atmospherics\machinery\components\trinary_devices\filter.dm"
@@ -1411,7 +1412,9 @@
#include "code\modules\atmospherics\machinery\components\unary_devices\cryo.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\heat_exchanger.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\outlet_injector.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\passive_vent.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\portables_connector.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\relief_valve.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\tank.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\thermomachine.dm"
#include "code\modules\atmospherics\machinery\components\unary_devices\unary_devices.dm"

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
<ui-display>
<ui-section label='Open Pressure'>
<ui-button icon='pencil' action='open_pressure' params='{"open_pressure": "input"}'>Set</ui-button>
<ui-button icon='plus' state='{{data.open_pressure == data.max_pressure ? "disabled" : null}}' action='open_pressure' params='{"open_pressure": "max"}'>Max</ui-button>
<span>{{Math.round(adata.open_pressure)}} kPa</span>
</ui-section>
<ui-section label='Close Pressure'>
<ui-button icon='pencil' action='close_pressure' params='{"close_pressure": "input"}'>Set</ui-button>
<ui-button icon='plus' state='{{data.close_pressure == data.open_pressure ? "disabled" : null}}' action='close_pressure' params='{"close_pressure": "max"}'>Max</ui-button>
<span>{{Math.round(adata.close_pressure)}} kPa</span>
</ui-section>
</ui-display>