Moar whitespace normalization [MDB IGNORE] (#7750)

Co-authored-by: Raeschen <rycoop29@gmail.com>
This commit is contained in:
Drathek
2024-02-16 01:54:47 -08:00
committed by GitHub
parent eecf6bbff9
commit 3995338290
1177 changed files with 550902 additions and 550902 deletions

View File

@@ -1,129 +1,129 @@
/obj/machinery/atmospherics/binary
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = USE_POWER_IDLE
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/datum/pipe_network/network1
var/datum/pipe_network/network2
/obj/machinery/atmospherics/binary/New()
..()
air1 = new
air2 = new
air1.volume = 200
air2.volume = 200
/obj/machinery/atmospherics/binary/init_dir()
switch(dir)
if(NORTH)
initialize_directions = NORTH|SOUTH
if(SOUTH)
initialize_directions = NORTH|SOUTH
if(EAST)
initialize_directions = EAST|WEST
if(WEST)
initialize_directions = EAST|WEST
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/binary/get_neighbor_nodes_for_init()
return list(node1, node2)
/obj/machinery/atmospherics/binary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
else if(reference == node2)
network2 = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/binary/Destroy()
. = ..()
if(node1)
node1.disconnect(src)
qdel(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
node1 = null
node2 = null
/obj/machinery/atmospherics/binary/atmos_init()
if(node1 && node2)
return
var/node2_connect = dir
var/node1_connect = turn(dir, 180)
STANDARD_ATMOS_CHOOSE_NODE(1, node1_connect)
STANDARD_ATMOS_CHOOSE_NODE(2, node2_connect)
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/build_network()
if(!network1 && node1)
network1 = new /datum/pipe_network()
network1.normal_members += src
network1.build_network(node1, src)
if(!network2 && node2)
network2 = new /datum/pipe_network()
network2.normal_members += src
network2.build_network(node2, src)
/obj/machinery/atmospherics/binary/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node1)
return network1
if(reference==node2)
return network2
return null
/obj/machinery/atmospherics/binary/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network1 == old_network)
network1 = new_network
if(network2 == old_network)
network2 = new_network
return 1
/obj/machinery/atmospherics/binary/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(network1 == reference)
results += air1
if(network2 == reference)
results += air2
return results
/obj/machinery/atmospherics/binary/disconnect(obj/machinery/atmospherics/reference)
if(reference==node1)
qdel(network1)
node1 = null
else if(reference==node2)
qdel(network2)
node2 = null
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = USE_POWER_IDLE
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/datum/pipe_network/network1
var/datum/pipe_network/network2
/obj/machinery/atmospherics/binary/New()
..()
air1 = new
air2 = new
air1.volume = 200
air2.volume = 200
/obj/machinery/atmospherics/binary/init_dir()
switch(dir)
if(NORTH)
initialize_directions = NORTH|SOUTH
if(SOUTH)
initialize_directions = NORTH|SOUTH
if(EAST)
initialize_directions = EAST|WEST
if(WEST)
initialize_directions = EAST|WEST
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/binary/get_neighbor_nodes_for_init()
return list(node1, node2)
/obj/machinery/atmospherics/binary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
else if(reference == node2)
network2 = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/binary/Destroy()
. = ..()
if(node1)
node1.disconnect(src)
qdel(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
node1 = null
node2 = null
/obj/machinery/atmospherics/binary/atmos_init()
if(node1 && node2)
return
var/node2_connect = dir
var/node1_connect = turn(dir, 180)
STANDARD_ATMOS_CHOOSE_NODE(1, node1_connect)
STANDARD_ATMOS_CHOOSE_NODE(2, node2_connect)
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/build_network()
if(!network1 && node1)
network1 = new /datum/pipe_network()
network1.normal_members += src
network1.build_network(node1, src)
if(!network2 && node2)
network2 = new /datum/pipe_network()
network2.normal_members += src
network2.build_network(node2, src)
/obj/machinery/atmospherics/binary/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node1)
return network1
if(reference==node2)
return network2
return null
/obj/machinery/atmospherics/binary/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network1 == old_network)
network1 = new_network
if(network2 == old_network)
network2 = new_network
return 1
/obj/machinery/atmospherics/binary/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(network1 == reference)
results += air1
if(network2 == reference)
results += air2
return results
/obj/machinery/atmospherics/binary/disconnect(obj/machinery/atmospherics/reference)
if(reference==node1)
qdel(network1)
node1 = null
else if(reference==node2)
qdel(network2)
node2 = null
update_icon()
update_underlays()
return null

View File

@@ -1,152 +1,152 @@
//node1, air1, network1 correspond to input
//node2, air2, network2 correspond to output
/obj/machinery/atmospherics/binary/circulator
name = "circulator"
desc = "A gas circulator turbine and heat exchanger."
icon = 'icons/obj/power.dmi'
icon_state = "circ-unassembled"
anchored = FALSE
unacidable = TRUE
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/kinetic_efficiency = 0.04 //combined kinetic and kinetic-to-electric efficiency
var/volume_ratio = 0.2
var/recent_moles_transferred = 0
var/last_heat_capacity = 0
var/last_temperature = 0
var/last_pressure_delta = 0
var/last_worldtime_transfer = 0
var/last_stored_energy_transferred = 0
var/volume_capacity_used = 0
var/stored_energy = 0
var/temperature_overlay
density = TRUE
/obj/machinery/atmospherics/binary/circulator/New()
..()
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
air1.volume = 400
/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
var/datum/gas_mixture/removed
if(anchored && !(stat&BROKEN) && network1)
var/input_starting_pressure = air1.return_pressure()
var/output_starting_pressure = air2.return_pressure()
last_pressure_delta = max(input_starting_pressure - output_starting_pressure - 5, 0)
//only circulate air if there is a pressure difference (plus 5kPa kinetic, 10kPa static friction)
if(air1.temperature > 0 && last_pressure_delta > 5)
//Calculate necessary moles to transfer using PV = nRT
recent_moles_transferred = (last_pressure_delta*network1.volume/(air1.temperature * R_IDEAL_GAS_EQUATION))/3 //uses the volume of the whole network, not just itself
volume_capacity_used = min( (last_pressure_delta*network1.volume/3)/(input_starting_pressure*air1.volume) , 1) //how much of the gas in the input air volume is consumed
//Calculate energy generated from kinetic turbine
stored_energy += 1/ADIABATIC_EXPONENT * min(last_pressure_delta * network1.volume , input_starting_pressure*air1.volume) * (1 - volume_ratio**ADIABATIC_EXPONENT) * kinetic_efficiency
//Actually transfer the gas
removed = air1.remove(recent_moles_transferred)
if(removed)
last_heat_capacity = removed.heat_capacity()
last_temperature = removed.temperature
//Update the gas networks.
network1.update = 1
last_worldtime_transfer = world.time
else
recent_moles_transferred = 0
update_icon()
return removed
/obj/machinery/atmospherics/binary/circulator/proc/return_stored_energy()
last_stored_energy_transferred = stored_energy
stored_energy = 0
return last_stored_energy_transferred
/obj/machinery/atmospherics/binary/circulator/process()
..()
if(last_worldtime_transfer < world.time - 50)
recent_moles_transferred = 0
update_icon()
/obj/machinery/atmospherics/binary/circulator/update_icon()
icon_state = anchored ? "circ-assembled" : "circ-unassembled"
cut_overlays()
if (stat & (BROKEN|NOPOWER) || !anchored)
return 1
if (last_pressure_delta > 0 && recent_moles_transferred > 0)
if (temperature_overlay)
add_overlay(temperature_overlay)
if (last_pressure_delta > 5*ONE_ATMOSPHERE)
add_overlay("circ-run")
else
add_overlay("circ-slow")
else
add_overlay("circ-off")
return 1
/obj/machinery/atmospherics/binary/circulator/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(W.has_tool_quality(TOOL_WRENCH))
playsound(src, W.usesound, 75, 1)
anchored = !anchored
user.visible_message("[user.name] [anchored ? "secures" : "unsecures"] the bolts holding [src.name] to the floor.", \
"You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.", \
"You hear a ratchet.")
if(anchored)
temperature_overlay = null
if(dir & (NORTH|SOUTH))
initialize_directions = NORTH|SOUTH
else if(dir & (EAST|WEST))
initialize_directions = EAST|WEST
atmos_init()
build_network()
if (node1)
node1.atmos_init()
node1.build_network()
if (node2)
node2.atmos_init()
node2.build_network()
else
if(node1)
node1.disconnect(src)
qdel(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
node1 = null
node2 = null
else
..()
/obj/machinery/atmospherics/binary/circulator/verb/rotate_clockwise()
set name = "Rotate Circulator Clockwise"
set category = "Object"
set src in view(1)
if (usr.stat || usr.restrained() || anchored)
return
src.set_dir(turn(src.dir, 270))
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
/obj/machinery/atmospherics/binary/circulator/verb/rotate_counterclockwise()
set name = "Rotate Circulator Counterclockwise"
set category = "Object"
set src in view(1)
if (usr.stat || usr.restrained() || anchored)
return
src.set_dir(turn(src.dir, 90))
//node1, air1, network1 correspond to input
//node2, air2, network2 correspond to output
/obj/machinery/atmospherics/binary/circulator
name = "circulator"
desc = "A gas circulator turbine and heat exchanger."
icon = 'icons/obj/power.dmi'
icon_state = "circ-unassembled"
anchored = FALSE
unacidable = TRUE
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/kinetic_efficiency = 0.04 //combined kinetic and kinetic-to-electric efficiency
var/volume_ratio = 0.2
var/recent_moles_transferred = 0
var/last_heat_capacity = 0
var/last_temperature = 0
var/last_pressure_delta = 0
var/last_worldtime_transfer = 0
var/last_stored_energy_transferred = 0
var/volume_capacity_used = 0
var/stored_energy = 0
var/temperature_overlay
density = TRUE
/obj/machinery/atmospherics/binary/circulator/New()
..()
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
air1.volume = 400
/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
var/datum/gas_mixture/removed
if(anchored && !(stat&BROKEN) && network1)
var/input_starting_pressure = air1.return_pressure()
var/output_starting_pressure = air2.return_pressure()
last_pressure_delta = max(input_starting_pressure - output_starting_pressure - 5, 0)
//only circulate air if there is a pressure difference (plus 5kPa kinetic, 10kPa static friction)
if(air1.temperature > 0 && last_pressure_delta > 5)
//Calculate necessary moles to transfer using PV = nRT
recent_moles_transferred = (last_pressure_delta*network1.volume/(air1.temperature * R_IDEAL_GAS_EQUATION))/3 //uses the volume of the whole network, not just itself
volume_capacity_used = min( (last_pressure_delta*network1.volume/3)/(input_starting_pressure*air1.volume) , 1) //how much of the gas in the input air volume is consumed
//Calculate energy generated from kinetic turbine
stored_energy += 1/ADIABATIC_EXPONENT * min(last_pressure_delta * network1.volume , input_starting_pressure*air1.volume) * (1 - volume_ratio**ADIABATIC_EXPONENT) * kinetic_efficiency
//Actually transfer the gas
removed = air1.remove(recent_moles_transferred)
if(removed)
last_heat_capacity = removed.heat_capacity()
last_temperature = removed.temperature
//Update the gas networks.
network1.update = 1
last_worldtime_transfer = world.time
else
recent_moles_transferred = 0
update_icon()
return removed
/obj/machinery/atmospherics/binary/circulator/proc/return_stored_energy()
last_stored_energy_transferred = stored_energy
stored_energy = 0
return last_stored_energy_transferred
/obj/machinery/atmospherics/binary/circulator/process()
..()
if(last_worldtime_transfer < world.time - 50)
recent_moles_transferred = 0
update_icon()
/obj/machinery/atmospherics/binary/circulator/update_icon()
icon_state = anchored ? "circ-assembled" : "circ-unassembled"
cut_overlays()
if (stat & (BROKEN|NOPOWER) || !anchored)
return 1
if (last_pressure_delta > 0 && recent_moles_transferred > 0)
if (temperature_overlay)
add_overlay(temperature_overlay)
if (last_pressure_delta > 5*ONE_ATMOSPHERE)
add_overlay("circ-run")
else
add_overlay("circ-slow")
else
add_overlay("circ-off")
return 1
/obj/machinery/atmospherics/binary/circulator/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(W.has_tool_quality(TOOL_WRENCH))
playsound(src, W.usesound, 75, 1)
anchored = !anchored
user.visible_message("[user.name] [anchored ? "secures" : "unsecures"] the bolts holding [src.name] to the floor.", \
"You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.", \
"You hear a ratchet.")
if(anchored)
temperature_overlay = null
if(dir & (NORTH|SOUTH))
initialize_directions = NORTH|SOUTH
else if(dir & (EAST|WEST))
initialize_directions = EAST|WEST
atmos_init()
build_network()
if (node1)
node1.atmos_init()
node1.build_network()
if (node2)
node2.atmos_init()
node2.build_network()
else
if(node1)
node1.disconnect(src)
qdel(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
node1 = null
node2 = null
else
..()
/obj/machinery/atmospherics/binary/circulator/verb/rotate_clockwise()
set name = "Rotate Circulator Clockwise"
set category = "Object"
set src in view(1)
if (usr.stat || usr.restrained() || anchored)
return
src.set_dir(turn(src.dir, 270))
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
/obj/machinery/atmospherics/binary/circulator/verb/rotate_counterclockwise()
set name = "Rotate Circulator Counterclockwise"
set category = "Object"
set src in view(1)
if (usr.stat || usr.restrained() || anchored)
return
src.set_dir(turn(src.dir, 90))
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."

View File

@@ -1,263 +1,263 @@
#define DEFAULT_PRESSURE_DELTA 10000
#define EXTERNAL_PRESSURE_BOUND ONE_ATMOSPHERE
#define INTERNAL_PRESSURE_BOUND 0
#define PRESSURE_CHECKS 1
#define PRESSURE_CHECK_EXTERNAL 1
#define PRESSURE_CHECK_INPUT 2
#define PRESSURE_CHECK_OUTPUT 4
/obj/machinery/atmospherics/binary/dp_vent_pump
icon = 'icons/atmos/vent_pump.dmi'
icon_state = "map_dp_vent"
//node2 is output port
//node1 is input port
name = "Dual Port Air Vent"
desc = "Has a valve and pump attached to it. There are two ports."
level = 1
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //7500 W ~ 10 HP
pipe_flags = PIPING_ALL_LAYER
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER //connects to regular, supply and scrubbers pipes
var/pump_direction = 1 //0 = siphoning, 1 = releasing
var/external_pressure_bound = EXTERNAL_PRESSURE_BOUND
var/input_pressure_min = INTERNAL_PRESSURE_BOUND
var/output_pressure_max = DEFAULT_PRESSURE_DELTA
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
var/pressure_checks = PRESSURE_CHECK_EXTERNAL
//1: Do not pass external_pressure_bound
//2: Do not pass input_pressure_min
//4: Do not pass output_pressure_max
/obj/machinery/atmospherics/binary/dp_vent_pump/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP
icon = null
/obj/machinery/atmospherics/binary/dp_vent_pump/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume
name = "Large Dual Port Air Vent"
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP + 800
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP + 800
/obj/machinery/atmospherics/binary/dp_vent_pump/update_icon(var/safety = 0)
if(!check_icon_cache())
return
cut_overlays()
var/vent_icon = "vent"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node1 && node2 && node1.level == 1 && node2.level == 1 && istype(node1, /obj/machinery/atmospherics/pipe) && istype(node2, /obj/machinery/atmospherics/pipe))
vent_icon += "h"
if(!powered())
vent_icon += "off"
else
vent_icon += "[use_power ? "[pump_direction ? "out" : "in"]" : "off"]"
add_overlay(icon_manager.get_atmos_icon("device", , , vent_icon))
/obj/machinery/atmospherics/binary/dp_vent_pump/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node1 && node2 && node1.level == 1 && node2.level == 1 && istype(node1, /obj/machinery/atmospherics/pipe) && istype(node2, /obj/machinery/atmospherics/pipe))
return
else
if (node1)
add_underlay(T, node1, turn(dir, -180), node1.icon_connect_type)
else
add_underlay(T, node1, turn(dir, -180))
if (node2)
add_underlay(T, node2, dir, node2.icon_connect_type)
else
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/dp_vent_pump/hide(var/i)
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/dp_vent_pump/process()
..()
last_power_draw = 0
last_flow_rate = 0
if(stat & (NOPOWER|BROKEN) || !use_power)
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/power_draw = -1
//Figure out the target pressure difference
var/pressure_delta = get_pressure_delta(environment)
if(pressure_delta > 0.5)
if(pump_direction) //internal -> external
if (node1 && (environment.temperature || air1.temperature))
var/transfer_moles = calculate_transfer_moles(air1, environment, pressure_delta)
power_draw = pump_gas(src, air1, environment, transfer_moles, power_rating)
if(power_draw >= 0 && network1)
network1.update = 1
else //external -> internal
if (node2 && (environment.temperature || air2.temperature))
var/transfer_moles = calculate_transfer_moles(environment, air2, pressure_delta, (network2)? network2.volume : 0)
//limit flow rate from turfs
transfer_moles = min(transfer_moles, environment.total_moles*air2.volume/environment.volume) //group_multiplier gets divided out here
power_draw = pump_gas(src, environment, air2, transfer_moles, power_rating)
if(power_draw >= 0 && network2)
network2.update = 1
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
return 1
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/get_pressure_delta(datum/gas_mixture/environment)
var/pressure_delta = DEFAULT_PRESSURE_DELTA
var/environment_pressure = environment.return_pressure()
if(pump_direction) //internal -> external
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, external_pressure_bound - environment_pressure) //increasing the pressure here
if(pressure_checks & PRESSURE_CHECK_INPUT)
pressure_delta = min(pressure_delta, air1.return_pressure() - input_pressure_min) //decreasing the pressure here
else //external -> internal
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, environment_pressure - external_pressure_bound) //decreasing the pressure here
if(pressure_checks & PRESSURE_CHECK_OUTPUT)
pressure_delta = min(pressure_delta, output_pressure_max - air2.return_pressure()) //increasing the pressure here
return pressure_delta
//Radio remote control
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, radio_filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "ADVP",
"power" = use_power,
"direction" = pump_direction?("release"):("siphon"),
"checks" = pressure_checks,
"input" = input_pressure_min,
"output" = output_pressure_max,
"external" = external_pressure_bound,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, radio_filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/dp_vent_pump/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/dp_vent_pump/examine(mob/user)
. = ..()
if(Adjacent(user))
. += "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
/obj/machinery/atmospherics/unary/vent_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/dp_vent_pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"])
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"])
update_use_power(!use_power)
if(signal.data["direction"])
pump_direction = text2num(signal.data["direction"])
if(signal.data["checks"])
pressure_checks = text2num(signal.data["checks"])
if(signal.data["purge"])
pressure_checks &= ~1
pump_direction = 0
if(signal.data["stabalize"])
pressure_checks |= 1
pump_direction = 1
if(signal.data["set_input_pressure"])
input_pressure_min = between(0, text2num(signal.data["set_input_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["set_output_pressure"])
output_pressure_max = between(0, text2num(signal.data["set_output_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["set_external_pressure"])
external_pressure_bound = between(0, text2num(signal.data["set_external_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
#undef DEFAULT_PRESSURE_DELTA
#undef EXTERNAL_PRESSURE_BOUND
#undef INTERNAL_PRESSURE_BOUND
#undef PRESSURE_CHECKS
#undef PRESSURE_CHECK_EXTERNAL
#undef PRESSURE_CHECK_INPUT
#undef PRESSURE_CHECK_OUTPUT
#define DEFAULT_PRESSURE_DELTA 10000
#define EXTERNAL_PRESSURE_BOUND ONE_ATMOSPHERE
#define INTERNAL_PRESSURE_BOUND 0
#define PRESSURE_CHECKS 1
#define PRESSURE_CHECK_EXTERNAL 1
#define PRESSURE_CHECK_INPUT 2
#define PRESSURE_CHECK_OUTPUT 4
/obj/machinery/atmospherics/binary/dp_vent_pump
icon = 'icons/atmos/vent_pump.dmi'
icon_state = "map_dp_vent"
//node2 is output port
//node1 is input port
name = "Dual Port Air Vent"
desc = "Has a valve and pump attached to it. There are two ports."
level = 1
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //7500 W ~ 10 HP
pipe_flags = PIPING_ALL_LAYER
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER //connects to regular, supply and scrubbers pipes
var/pump_direction = 1 //0 = siphoning, 1 = releasing
var/external_pressure_bound = EXTERNAL_PRESSURE_BOUND
var/input_pressure_min = INTERNAL_PRESSURE_BOUND
var/output_pressure_max = DEFAULT_PRESSURE_DELTA
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
var/pressure_checks = PRESSURE_CHECK_EXTERNAL
//1: Do not pass external_pressure_bound
//2: Do not pass input_pressure_min
//4: Do not pass output_pressure_max
/obj/machinery/atmospherics/binary/dp_vent_pump/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP
icon = null
/obj/machinery/atmospherics/binary/dp_vent_pump/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume
name = "Large Dual Port Air Vent"
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP + 800
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP + 800
/obj/machinery/atmospherics/binary/dp_vent_pump/update_icon(var/safety = 0)
if(!check_icon_cache())
return
cut_overlays()
var/vent_icon = "vent"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node1 && node2 && node1.level == 1 && node2.level == 1 && istype(node1, /obj/machinery/atmospherics/pipe) && istype(node2, /obj/machinery/atmospherics/pipe))
vent_icon += "h"
if(!powered())
vent_icon += "off"
else
vent_icon += "[use_power ? "[pump_direction ? "out" : "in"]" : "off"]"
add_overlay(icon_manager.get_atmos_icon("device", , , vent_icon))
/obj/machinery/atmospherics/binary/dp_vent_pump/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node1 && node2 && node1.level == 1 && node2.level == 1 && istype(node1, /obj/machinery/atmospherics/pipe) && istype(node2, /obj/machinery/atmospherics/pipe))
return
else
if (node1)
add_underlay(T, node1, turn(dir, -180), node1.icon_connect_type)
else
add_underlay(T, node1, turn(dir, -180))
if (node2)
add_underlay(T, node2, dir, node2.icon_connect_type)
else
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/dp_vent_pump/hide(var/i)
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/dp_vent_pump/process()
..()
last_power_draw = 0
last_flow_rate = 0
if(stat & (NOPOWER|BROKEN) || !use_power)
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/power_draw = -1
//Figure out the target pressure difference
var/pressure_delta = get_pressure_delta(environment)
if(pressure_delta > 0.5)
if(pump_direction) //internal -> external
if (node1 && (environment.temperature || air1.temperature))
var/transfer_moles = calculate_transfer_moles(air1, environment, pressure_delta)
power_draw = pump_gas(src, air1, environment, transfer_moles, power_rating)
if(power_draw >= 0 && network1)
network1.update = 1
else //external -> internal
if (node2 && (environment.temperature || air2.temperature))
var/transfer_moles = calculate_transfer_moles(environment, air2, pressure_delta, (network2)? network2.volume : 0)
//limit flow rate from turfs
transfer_moles = min(transfer_moles, environment.total_moles*air2.volume/environment.volume) //group_multiplier gets divided out here
power_draw = pump_gas(src, environment, air2, transfer_moles, power_rating)
if(power_draw >= 0 && network2)
network2.update = 1
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
return 1
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/get_pressure_delta(datum/gas_mixture/environment)
var/pressure_delta = DEFAULT_PRESSURE_DELTA
var/environment_pressure = environment.return_pressure()
if(pump_direction) //internal -> external
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, external_pressure_bound - environment_pressure) //increasing the pressure here
if(pressure_checks & PRESSURE_CHECK_INPUT)
pressure_delta = min(pressure_delta, air1.return_pressure() - input_pressure_min) //decreasing the pressure here
else //external -> internal
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, environment_pressure - external_pressure_bound) //decreasing the pressure here
if(pressure_checks & PRESSURE_CHECK_OUTPUT)
pressure_delta = min(pressure_delta, output_pressure_max - air2.return_pressure()) //increasing the pressure here
return pressure_delta
//Radio remote control
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, radio_filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "ADVP",
"power" = use_power,
"direction" = pump_direction?("release"):("siphon"),
"checks" = pressure_checks,
"input" = input_pressure_min,
"output" = output_pressure_max,
"external" = external_pressure_bound,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, radio_filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/dp_vent_pump/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/dp_vent_pump/examine(mob/user)
. = ..()
if(Adjacent(user))
. += "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
/obj/machinery/atmospherics/unary/vent_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/dp_vent_pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"])
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"])
update_use_power(!use_power)
if(signal.data["direction"])
pump_direction = text2num(signal.data["direction"])
if(signal.data["checks"])
pressure_checks = text2num(signal.data["checks"])
if(signal.data["purge"])
pressure_checks &= ~1
pump_direction = 0
if(signal.data["stabalize"])
pressure_checks |= 1
pump_direction = 1
if(signal.data["set_input_pressure"])
input_pressure_min = between(0, text2num(signal.data["set_input_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["set_output_pressure"])
output_pressure_max = between(0, text2num(signal.data["set_output_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["set_external_pressure"])
external_pressure_bound = between(0, text2num(signal.data["set_external_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
#undef DEFAULT_PRESSURE_DELTA
#undef EXTERNAL_PRESSURE_BOUND
#undef INTERNAL_PRESSURE_BOUND
#undef PRESSURE_CHECKS
#undef PRESSURE_CHECK_EXTERNAL
#undef PRESSURE_CHECK_INPUT
#undef PRESSURE_CHECK_OUTPUT

View File

@@ -1,302 +1,302 @@
#define REGULATE_NONE 0
#define REGULATE_INPUT 1 //shuts off when input side is below the target pressure
#define REGULATE_OUTPUT 2 //shuts off when output side is above the target pressure
/obj/machinery/atmospherics/binary/passive_gate
icon = 'icons/atmos/passive_gate.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/directional
pipe_state = "passivegate"
level = 1
name = "pressure regulator"
desc = "A one-way air valve that can be used to regulate input or output pressure, and flow rate. Does not require power."
use_power = USE_POWER_OFF
interact_offline = TRUE
var/unlocked = 0 //If 0, then the valve is locked closed, otherwise it is open(-able, it's a one-way valve so it closes if gas would flow backwards).
var/target_pressure = ONE_ATMOSPHERE
var/max_pressure_setting = 15000 //kPa
var/set_flow_rate = ATMOS_DEFAULT_VOLUME_PUMP * 2.5
var/regulate_mode = REGULATE_OUTPUT
var/flowing = 0 //for icons - becomes zero if the valve closes itself due to regulation mode
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/passive_gate/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP * 2.5
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP * 2.5
/obj/machinery/atmospherics/binary/passive_gate/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/binary/passive_gate/update_icon()
icon_state = (unlocked && flowing)? "on" : "off"
/obj/machinery/atmospherics/binary/passive_gate/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, 180))
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/passive_gate/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/binary/passive_gate/process()
..()
last_flow_rate = 0
if(!unlocked)
return 0
var/output_starting_pressure = air2.return_pressure()
var/input_starting_pressure = air1.return_pressure()
var/pressure_delta
switch (regulate_mode)
if (REGULATE_INPUT)
pressure_delta = input_starting_pressure - target_pressure
if (REGULATE_OUTPUT)
pressure_delta = target_pressure - output_starting_pressure
if (REGULATE_NONE)
pressure_delta = input_starting_pressure - output_starting_pressure
//-1 if pump_gas() did not move any gas, >= 0 otherwise
var/returnval = -1
if((regulate_mode == REGULATE_NONE || pressure_delta > 0.01) && (air1.temperature > 0 || air2.temperature > 0)) //since it's basically a valve, it makes sense to check both temperatures
flowing = 1
//flow rate limit
var/transfer_moles = (set_flow_rate/air1.volume)*air1.total_moles
//Figure out how much gas to transfer to meet the target pressure.
switch (regulate_mode)
if (REGULATE_INPUT)
transfer_moles = min(transfer_moles, calculate_transfer_moles(air2, air1, pressure_delta, (network1)? network1.volume : 0))
if (REGULATE_OUTPUT)
transfer_moles = min(transfer_moles, calculate_transfer_moles(air1, air2, pressure_delta, (network2)? network2.volume : 0))
if (REGULATE_NONE)
var/source = air1
var/sink = air2
// If node1 is a network of more than 1 pipe, we want to transfer from that whole network, otw use just node1, as current
if(istype(node1, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node1
if(istype(p.parent, /datum/pipeline)) // Nested if-blocks to avoid the mystical :
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
source = l.air
// If node2 is a network of more than 1 pipe, we want to transfer to that whole network, otw use just node2, as current
if(istype(node2, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node2
if(istype(p.parent, /datum/pipeline))
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
sink = l.air
transfer_moles = max(0, calculate_equalize_moles(source, sink)) // Not regulated, don't care about flow rate
//pump_gas() will return a negative number if no flow occurred
if(regulate_mode == REGULATE_NONE) // ACTUALLY move gases from the whole network, not just the immediate pipes
var/source = air1
var/sink = air2
// If node1 is a network of more than 1 pipe, we want to transfer from that whole network, otw use just node1, as current
if(istype(node1, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node1
if(istype(p.parent, /datum/pipeline)) // Nested if-blocks to avoid the mystical :
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
source = l.air
// If node2 is a network of more than 1 pipe, we want to transfer to that whole network, otw use just node2, as current
if(istype(node2, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node2
if(istype(p.parent, /datum/pipeline))
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
sink = l.air
returnval = pump_gas_passive(src, source, sink, transfer_moles)
else
returnval = pump_gas_passive(src, air1, air2, transfer_moles)
if (returnval >= 0)
if(network1)
network1.update = 1
if(network2)
network2.update = 1
if (last_flow_rate)
flowing = 1
update_icon()
//Radio remote control
/obj/machinery/atmospherics/binary/passive_gate/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, radio_filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/passive_gate/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = unlocked,
"target_output" = target_pressure,
"regulate_mode" = regulate_mode,
"set_flow_rate" = set_flow_rate,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, radio_filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/passive_gate/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/passive_gate/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if("power" in signal.data)
unlocked = text2num(signal.data["power"])
if("power_toggle" in signal.data)
unlocked = !unlocked
if("set_target_pressure" in signal.data)
target_pressure = between(0, text2num(signal.data["set_target_pressure"]), max_pressure_setting)
if("set_regulate_mode" in signal.data)
regulate_mode = text2num(signal.data["set_regulate_mode"])
if("set_flow_rate" in signal.data)
regulate_mode = text2num(signal.data["set_flow_rate"])
if("status" in signal.data)
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/binary/passive_gate/attack_hand(user as mob)
if(..())
return
add_fingerprint(usr)
if(!allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
tgui_interact(user)
/obj/machinery/atmospherics/binary/passive_gate/tgui_interact(mob/user, datum/tgui/ui)
if(stat & BROKEN)
return FALSE
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "PressureRegulator", name)
ui.open()
/obj/machinery/atmospherics/binary/passive_gate/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data = list(
"on" = unlocked,
"pressure_set" = round(target_pressure*100), //Nano UI can't handle rounded non-integers, apparently.
"max_pressure" = max_pressure_setting,
"input_pressure" = round(air1.return_pressure()*100),
"output_pressure" = round(air2.return_pressure()*100),
"regulate_mode" = regulate_mode,
"set_flow_rate" = round(set_flow_rate*10),
"last_flow_rate" = round(last_flow_rate*10),
)
return data
/obj/machinery/atmospherics/binary/passive_gate/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("toggle_valve")
. = TRUE
unlocked = !unlocked
if("regulate_mode")
. = TRUE
switch(params["mode"])
if("off") regulate_mode = REGULATE_NONE
if("input") regulate_mode = REGULATE_INPUT
if("output") regulate_mode = REGULATE_OUTPUT
if("set_press")
. = TRUE
switch(params["press"])
if("min")
target_pressure = 0
if("max")
target_pressure = max_pressure_setting
if("set")
var/new_pressure = tgui_input_number(usr,"Enter new output pressure (0-[max_pressure_setting]kPa)","Pressure Control",src.target_pressure,max_pressure_setting,0)
src.target_pressure = between(0, new_pressure, max_pressure_setting)
if("set_flow_rate")
. = TRUE
switch(params["press"])
if("min")
set_flow_rate = 0
if("max")
set_flow_rate = air1.volume
if("set")
var/new_flow_rate = tgui_input_number(usr,"Enter new flow rate limit (0-[air1.volume]L/s)","Flow Rate Control",src.set_flow_rate,air1.volume,0)
src.set_flow_rate = between(0, new_flow_rate, air1.volume)
update_icon()
add_fingerprint(usr)
/obj/machinery/atmospherics/binary/passive_gate/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (unlocked)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
deconstruct()
#undef REGULATE_NONE
#undef REGULATE_INPUT
#undef REGULATE_OUTPUT
#define REGULATE_NONE 0
#define REGULATE_INPUT 1 //shuts off when input side is below the target pressure
#define REGULATE_OUTPUT 2 //shuts off when output side is above the target pressure
/obj/machinery/atmospherics/binary/passive_gate
icon = 'icons/atmos/passive_gate.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/directional
pipe_state = "passivegate"
level = 1
name = "pressure regulator"
desc = "A one-way air valve that can be used to regulate input or output pressure, and flow rate. Does not require power."
use_power = USE_POWER_OFF
interact_offline = TRUE
var/unlocked = 0 //If 0, then the valve is locked closed, otherwise it is open(-able, it's a one-way valve so it closes if gas would flow backwards).
var/target_pressure = ONE_ATMOSPHERE
var/max_pressure_setting = 15000 //kPa
var/set_flow_rate = ATMOS_DEFAULT_VOLUME_PUMP * 2.5
var/regulate_mode = REGULATE_OUTPUT
var/flowing = 0 //for icons - becomes zero if the valve closes itself due to regulation mode
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/passive_gate/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP * 2.5
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP * 2.5
/obj/machinery/atmospherics/binary/passive_gate/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/binary/passive_gate/update_icon()
icon_state = (unlocked && flowing)? "on" : "off"
/obj/machinery/atmospherics/binary/passive_gate/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, 180))
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/passive_gate/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/binary/passive_gate/process()
..()
last_flow_rate = 0
if(!unlocked)
return 0
var/output_starting_pressure = air2.return_pressure()
var/input_starting_pressure = air1.return_pressure()
var/pressure_delta
switch (regulate_mode)
if (REGULATE_INPUT)
pressure_delta = input_starting_pressure - target_pressure
if (REGULATE_OUTPUT)
pressure_delta = target_pressure - output_starting_pressure
if (REGULATE_NONE)
pressure_delta = input_starting_pressure - output_starting_pressure
//-1 if pump_gas() did not move any gas, >= 0 otherwise
var/returnval = -1
if((regulate_mode == REGULATE_NONE || pressure_delta > 0.01) && (air1.temperature > 0 || air2.temperature > 0)) //since it's basically a valve, it makes sense to check both temperatures
flowing = 1
//flow rate limit
var/transfer_moles = (set_flow_rate/air1.volume)*air1.total_moles
//Figure out how much gas to transfer to meet the target pressure.
switch (regulate_mode)
if (REGULATE_INPUT)
transfer_moles = min(transfer_moles, calculate_transfer_moles(air2, air1, pressure_delta, (network1)? network1.volume : 0))
if (REGULATE_OUTPUT)
transfer_moles = min(transfer_moles, calculate_transfer_moles(air1, air2, pressure_delta, (network2)? network2.volume : 0))
if (REGULATE_NONE)
var/source = air1
var/sink = air2
// If node1 is a network of more than 1 pipe, we want to transfer from that whole network, otw use just node1, as current
if(istype(node1, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node1
if(istype(p.parent, /datum/pipeline)) // Nested if-blocks to avoid the mystical :
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
source = l.air
// If node2 is a network of more than 1 pipe, we want to transfer to that whole network, otw use just node2, as current
if(istype(node2, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node2
if(istype(p.parent, /datum/pipeline))
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
sink = l.air
transfer_moles = max(0, calculate_equalize_moles(source, sink)) // Not regulated, don't care about flow rate
//pump_gas() will return a negative number if no flow occurred
if(regulate_mode == REGULATE_NONE) // ACTUALLY move gases from the whole network, not just the immediate pipes
var/source = air1
var/sink = air2
// If node1 is a network of more than 1 pipe, we want to transfer from that whole network, otw use just node1, as current
if(istype(node1, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node1
if(istype(p.parent, /datum/pipeline)) // Nested if-blocks to avoid the mystical :
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
source = l.air
// If node2 is a network of more than 1 pipe, we want to transfer to that whole network, otw use just node2, as current
if(istype(node2, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/p = node2
if(istype(p.parent, /datum/pipeline))
var/datum/pipeline/l = p.parent
if(istype(l.air, /datum/gas_mixture))
sink = l.air
returnval = pump_gas_passive(src, source, sink, transfer_moles)
else
returnval = pump_gas_passive(src, air1, air2, transfer_moles)
if (returnval >= 0)
if(network1)
network1.update = 1
if(network2)
network2.update = 1
if (last_flow_rate)
flowing = 1
update_icon()
//Radio remote control
/obj/machinery/atmospherics/binary/passive_gate/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, radio_filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/passive_gate/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = unlocked,
"target_output" = target_pressure,
"regulate_mode" = regulate_mode,
"set_flow_rate" = set_flow_rate,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, radio_filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/passive_gate/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/passive_gate/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if("power" in signal.data)
unlocked = text2num(signal.data["power"])
if("power_toggle" in signal.data)
unlocked = !unlocked
if("set_target_pressure" in signal.data)
target_pressure = between(0, text2num(signal.data["set_target_pressure"]), max_pressure_setting)
if("set_regulate_mode" in signal.data)
regulate_mode = text2num(signal.data["set_regulate_mode"])
if("set_flow_rate" in signal.data)
regulate_mode = text2num(signal.data["set_flow_rate"])
if("status" in signal.data)
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/binary/passive_gate/attack_hand(user as mob)
if(..())
return
add_fingerprint(usr)
if(!allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
tgui_interact(user)
/obj/machinery/atmospherics/binary/passive_gate/tgui_interact(mob/user, datum/tgui/ui)
if(stat & BROKEN)
return FALSE
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "PressureRegulator", name)
ui.open()
/obj/machinery/atmospherics/binary/passive_gate/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data = list(
"on" = unlocked,
"pressure_set" = round(target_pressure*100), //Nano UI can't handle rounded non-integers, apparently.
"max_pressure" = max_pressure_setting,
"input_pressure" = round(air1.return_pressure()*100),
"output_pressure" = round(air2.return_pressure()*100),
"regulate_mode" = regulate_mode,
"set_flow_rate" = round(set_flow_rate*10),
"last_flow_rate" = round(last_flow_rate*10),
)
return data
/obj/machinery/atmospherics/binary/passive_gate/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("toggle_valve")
. = TRUE
unlocked = !unlocked
if("regulate_mode")
. = TRUE
switch(params["mode"])
if("off") regulate_mode = REGULATE_NONE
if("input") regulate_mode = REGULATE_INPUT
if("output") regulate_mode = REGULATE_OUTPUT
if("set_press")
. = TRUE
switch(params["press"])
if("min")
target_pressure = 0
if("max")
target_pressure = max_pressure_setting
if("set")
var/new_pressure = tgui_input_number(usr,"Enter new output pressure (0-[max_pressure_setting]kPa)","Pressure Control",src.target_pressure,max_pressure_setting,0)
src.target_pressure = between(0, new_pressure, max_pressure_setting)
if("set_flow_rate")
. = TRUE
switch(params["press"])
if("min")
set_flow_rate = 0
if("max")
set_flow_rate = air1.volume
if("set")
var/new_flow_rate = tgui_input_number(usr,"Enter new flow rate limit (0-[air1.volume]L/s)","Flow Rate Control",src.set_flow_rate,air1.volume,0)
src.set_flow_rate = between(0, new_flow_rate, air1.volume)
update_icon()
add_fingerprint(usr)
/obj/machinery/atmospherics/binary/passive_gate/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (unlocked)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
deconstruct()
#undef REGULATE_NONE
#undef REGULATE_INPUT
#undef REGULATE_OUTPUT

View File

@@ -1,258 +1,258 @@
/*
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/binary/pump
icon = 'icons/atmos/pump.dmi'
icon_state = "map_off"
construction_type = /obj/item/pipe/directional
pipe_state = "pump"
level = 1
var/base_icon = "pump"
name = "gas pump"
desc = "A pump that moves gas from one place to another."
var/target_pressure = ONE_ATMOSPHERE
//var/max_volume_transfer = 10000
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //7500 W ~ 10 HP
var/max_pressure_setting = 15000 //kPa
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/pump/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP
/obj/machinery/atmospherics/binary/pump/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/binary/pump/on
icon_state = "map_on"
use_power = USE_POWER_IDLE
/obj/machinery/atmospherics/binary/pump/fuel
icon_state = "map_off-fuel"
base_icon = "pump-fuel"
icon_connect_type = "-fuel"
connect_types = CONNECT_TYPE_FUEL
/obj/machinery/atmospherics/binary/pump/fuel/on
icon_state = "map_on-fuel"
use_power = USE_POWER_IDLE
/obj/machinery/atmospherics/binary/pump/aux
icon_state = "map_off-aux"
base_icon = "pump-aux"
icon_connect_type = "-aux"
connect_types = CONNECT_TYPE_AUX
/obj/machinery/atmospherics/binary/pump/aux/on
icon_state = "map_on-aux"
use_power = USE_POWER_IDLE
/obj/machinery/atmospherics/binary/pump/update_icon()
if(!powered())
icon_state = "[base_icon]-off"
else
icon_state = "[use_power ? "[base_icon]-on" : "[base_icon]-off"]"
/obj/machinery/atmospherics/binary/pump/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, -180), node1?.icon_connect_type)
add_underlay(T, node2, dir, node2?.icon_connect_type)
/obj/machinery/atmospherics/binary/pump/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/binary/pump/process()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
var/power_draw = -1
var/pressure_delta = target_pressure - air2.return_pressure()
if(pressure_delta > 0.01 && air1.temperature > 0)
//Figure out how much gas to transfer to meet the target pressure.
var/transfer_moles = calculate_transfer_moles(air1, air2, pressure_delta, (network2)? network2.volume : 0)
power_draw = pump_gas(src, air1, air2, transfer_moles, power_rating)
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network1)
network1.update = 1
if(network2)
network2.update = 1
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/pump/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, radio_filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = use_power,
"target_output" = target_pressure,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, radio_filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/pump/tgui_interact(mob/user, datum/tgui/ui)
if(stat & (BROKEN|NOPOWER))
return
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GasPump", name)
ui.open()
/obj/machinery/atmospherics/binary/pump/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data = list(
"on" = use_power,
"pressure_set" = round(target_pressure*100), //Nano UI can't handle rounded non-integers, apparently.
"max_pressure" = max_pressure_setting,
"last_flow_rate" = round(last_flow_rate*10),
"last_power_draw" = round(last_power_draw),
"max_power_draw" = power_rating,
)
return data
/obj/machinery/atmospherics/binary/pump/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"])
if(text2num(signal.data["power"]))
update_use_power(USE_POWER_IDLE)
else
update_use_power(USE_POWER_OFF)
if("power_toggle" in signal.data)
update_use_power(!use_power)
if(signal.data["set_output_pressure"])
target_pressure = between(0, text2num(signal.data["set_output_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/binary/pump/attack_ghost(mob/user)
tgui_interact(user)
/obj/machinery/atmospherics/binary/pump/attack_hand(mob/user)
if(..())
return
add_fingerprint(usr)
if(!allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
tgui_interact(user)
/obj/machinery/atmospherics/binary/pump/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("power")
update_use_power(!use_power)
. = TRUE
if("set_press")
var/press = params["press"]
switch(press)
if("min")
target_pressure = 0
if("max")
target_pressure = max_pressure_setting
if("set")
var/new_pressure = tgui_input_number(usr,"Enter new output pressure (0-[max_pressure_setting]kPa)","Pressure control",src.target_pressure,max_pressure_setting,0)
src.target_pressure = between(0, new_pressure, max_pressure_setting)
. = TRUE
add_fingerprint(usr)
update_icon()
/obj/machinery/atmospherics/binary/pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/pump/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (!(stat & NOPOWER) && use_power)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench this [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
deconstruct()
/*
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/binary/pump
icon = 'icons/atmos/pump.dmi'
icon_state = "map_off"
construction_type = /obj/item/pipe/directional
pipe_state = "pump"
level = 1
var/base_icon = "pump"
name = "gas pump"
desc = "A pump that moves gas from one place to another."
var/target_pressure = ONE_ATMOSPHERE
//var/max_volume_transfer = 10000
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //7500 W ~ 10 HP
var/max_pressure_setting = 15000 //kPa
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/pump/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_PUMP
air2.volume = ATMOS_DEFAULT_VOLUME_PUMP
/obj/machinery/atmospherics/binary/pump/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/binary/pump/on
icon_state = "map_on"
use_power = USE_POWER_IDLE
/obj/machinery/atmospherics/binary/pump/fuel
icon_state = "map_off-fuel"
base_icon = "pump-fuel"
icon_connect_type = "-fuel"
connect_types = CONNECT_TYPE_FUEL
/obj/machinery/atmospherics/binary/pump/fuel/on
icon_state = "map_on-fuel"
use_power = USE_POWER_IDLE
/obj/machinery/atmospherics/binary/pump/aux
icon_state = "map_off-aux"
base_icon = "pump-aux"
icon_connect_type = "-aux"
connect_types = CONNECT_TYPE_AUX
/obj/machinery/atmospherics/binary/pump/aux/on
icon_state = "map_on-aux"
use_power = USE_POWER_IDLE
/obj/machinery/atmospherics/binary/pump/update_icon()
if(!powered())
icon_state = "[base_icon]-off"
else
icon_state = "[use_power ? "[base_icon]-on" : "[base_icon]-off"]"
/obj/machinery/atmospherics/binary/pump/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, -180), node1?.icon_connect_type)
add_underlay(T, node2, dir, node2?.icon_connect_type)
/obj/machinery/atmospherics/binary/pump/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/binary/pump/process()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
var/power_draw = -1
var/pressure_delta = target_pressure - air2.return_pressure()
if(pressure_delta > 0.01 && air1.temperature > 0)
//Figure out how much gas to transfer to meet the target pressure.
var/transfer_moles = calculate_transfer_moles(air1, air2, pressure_delta, (network2)? network2.volume : 0)
power_draw = pump_gas(src, air1, air2, transfer_moles, power_rating)
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network1)
network1.update = 1
if(network2)
network2.update = 1
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/pump/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, radio_filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = use_power,
"target_output" = target_pressure,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, radio_filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/pump/tgui_interact(mob/user, datum/tgui/ui)
if(stat & (BROKEN|NOPOWER))
return
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GasPump", name)
ui.open()
/obj/machinery/atmospherics/binary/pump/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data = list(
"on" = use_power,
"pressure_set" = round(target_pressure*100), //Nano UI can't handle rounded non-integers, apparently.
"max_pressure" = max_pressure_setting,
"last_flow_rate" = round(last_flow_rate*10),
"last_power_draw" = round(last_power_draw),
"max_power_draw" = power_rating,
)
return data
/obj/machinery/atmospherics/binary/pump/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"])
if(text2num(signal.data["power"]))
update_use_power(USE_POWER_IDLE)
else
update_use_power(USE_POWER_OFF)
if("power_toggle" in signal.data)
update_use_power(!use_power)
if(signal.data["set_output_pressure"])
target_pressure = between(0, text2num(signal.data["set_output_pressure"]), ONE_ATMOSPHERE*50)
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/binary/pump/attack_ghost(mob/user)
tgui_interact(user)
/obj/machinery/atmospherics/binary/pump/attack_hand(mob/user)
if(..())
return
add_fingerprint(usr)
if(!allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
tgui_interact(user)
/obj/machinery/atmospherics/binary/pump/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("power")
update_use_power(!use_power)
. = TRUE
if("set_press")
var/press = params["press"]
switch(press)
if("min")
target_pressure = 0
if("max")
target_pressure = max_pressure_setting
if("set")
var/new_pressure = tgui_input_number(usr,"Enter new output pressure (0-[max_pressure_setting]kPa)","Pressure control",src.target_pressure,max_pressure_setting,0)
src.target_pressure = between(0, new_pressure, max_pressure_setting)
. = TRUE
add_fingerprint(usr)
update_icon()
/obj/machinery/atmospherics/binary/pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/pump/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (!(stat & NOPOWER) && use_power)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench this [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
deconstruct()

View File

@@ -1,21 +1,21 @@
/obj/machinery/atmospherics/binary/pump/high_power
icon = 'icons/atmos/volume_pump.dmi'
icon_state = "map_off"
construction_type = /obj/item/pipe/directional
pipe_state = "volumepump"
level = 1
name = "high power gas pump"
desc = "A pump that moves gas from one place to another. Has double the power rating of the standard gas pump."
power_rating = 15000 //15000 W ~ 20 HP
/obj/machinery/atmospherics/binary/pump/high_power/on
use_power = USE_POWER_IDLE
icon_state = "map_on"
/obj/machinery/atmospherics/binary/pump/high_power/update_icon()
if(!powered())
icon_state = "off"
else
/obj/machinery/atmospherics/binary/pump/high_power
icon = 'icons/atmos/volume_pump.dmi'
icon_state = "map_off"
construction_type = /obj/item/pipe/directional
pipe_state = "volumepump"
level = 1
name = "high power gas pump"
desc = "A pump that moves gas from one place to another. Has double the power rating of the standard gas pump."
power_rating = 15000 //15000 W ~ 20 HP
/obj/machinery/atmospherics/binary/pump/high_power/on
use_power = USE_POWER_IDLE
icon_state = "map_on"
/obj/machinery/atmospherics/binary/pump/high_power/update_icon()
if(!powered())
icon_state = "off"
else
icon_state = "[use_power ? "on" : "off"]"

View File

@@ -1,168 +1,168 @@
/obj/machinery/atmospherics/portables_connector
icon = 'icons/atmos/connector.dmi'
icon_state = "map_connector"
name = "Connector Port"
desc = "For connecting portables devices related to atmospherics control."
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_state = "connector"
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/obj/machinery/portable_atmospherics/connected_device
var/obj/machinery/atmospherics/node
var/datum/pipe_network/network
var/on = 0
use_power = USE_POWER_OFF
level = 1
/obj/machinery/atmospherics/portables_connector/fuel
icon_state = "map_connector-fuel"
pipe_state = "connector-fuel"
icon_connect_type = "-fuel"
pipe_flags = PIPING_ONE_PER_TURF
connect_types = CONNECT_TYPE_FUEL
/obj/machinery/atmospherics/portables_connector/aux
icon_state = "map_connector-aux"
pipe_state = "connector-aux"
icon_connect_type = "-aux"
pipe_flags = PIPING_ONE_PER_TURF
connect_types = CONNECT_TYPE_AUX
/obj/machinery/atmospherics/portables_connector/init_dir()
initialize_directions = dir
/obj/machinery/atmospherics/portables_connector/update_icon()
icon_state = "connector"
/obj/machinery/atmospherics/portables_connector/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node, dir, node?.icon_connect_type)
/obj/machinery/atmospherics/portables_connector/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/portables_connector/process()
..()
if(!on)
return
if(!connected_device)
on = 0
return
if(network)
network.update = 1
return 1
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/portables_connector/get_neighbor_nodes_for_init()
return list(node)
/obj/machinery/atmospherics/portables_connector/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node)
network = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/portables_connector/Destroy()
. = ..()
if(connected_device)
connected_device.disconnect()
if(node)
node.disconnect(src)
qdel(network)
node = null
/obj/machinery/atmospherics/portables_connector/atmos_init()
if(node)
return
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
if(can_be_node(target, 1))
node = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/portables_connector/build_network()
if(!network && node)
network = new /datum/pipe_network()
network.normal_members += src
network.build_network(node, src)
/obj/machinery/atmospherics/portables_connector/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node)
return network
if(reference==connected_device)
return network
return null
/obj/machinery/atmospherics/portables_connector/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network == old_network)
network = new_network
return 1
/obj/machinery/atmospherics/portables_connector/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(connected_device)
results += connected_device.air_contents
return results
/obj/machinery/atmospherics/portables_connector/disconnect(obj/machinery/atmospherics/reference)
if(reference==node)
qdel(network)
node = null
update_underlays()
return null
/obj/machinery/atmospherics/portables_connector/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (connected_device)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], dettach \the [connected_device] first.</span>")
return 1
if (locate(/obj/machinery/portable_atmospherics, src.loc))
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
/obj/machinery/atmospherics/portables_connector
icon = 'icons/atmos/connector.dmi'
icon_state = "map_connector"
name = "Connector Port"
desc = "For connecting portables devices related to atmospherics control."
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_state = "connector"
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/obj/machinery/portable_atmospherics/connected_device
var/obj/machinery/atmospherics/node
var/datum/pipe_network/network
var/on = 0
use_power = USE_POWER_OFF
level = 1
/obj/machinery/atmospherics/portables_connector/fuel
icon_state = "map_connector-fuel"
pipe_state = "connector-fuel"
icon_connect_type = "-fuel"
pipe_flags = PIPING_ONE_PER_TURF
connect_types = CONNECT_TYPE_FUEL
/obj/machinery/atmospherics/portables_connector/aux
icon_state = "map_connector-aux"
pipe_state = "connector-aux"
icon_connect_type = "-aux"
pipe_flags = PIPING_ONE_PER_TURF
connect_types = CONNECT_TYPE_AUX
/obj/machinery/atmospherics/portables_connector/init_dir()
initialize_directions = dir
/obj/machinery/atmospherics/portables_connector/update_icon()
icon_state = "connector"
/obj/machinery/atmospherics/portables_connector/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node, dir, node?.icon_connect_type)
/obj/machinery/atmospherics/portables_connector/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/portables_connector/process()
..()
if(!on)
return
if(!connected_device)
on = 0
return
if(network)
network.update = 1
return 1
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/portables_connector/get_neighbor_nodes_for_init()
return list(node)
/obj/machinery/atmospherics/portables_connector/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node)
network = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/portables_connector/Destroy()
. = ..()
if(connected_device)
connected_device.disconnect()
if(node)
node.disconnect(src)
qdel(network)
node = null
/obj/machinery/atmospherics/portables_connector/atmos_init()
if(node)
return
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
if(can_be_node(target, 1))
node = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/portables_connector/build_network()
if(!network && node)
network = new /datum/pipe_network()
network.normal_members += src
network.build_network(node, src)
/obj/machinery/atmospherics/portables_connector/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node)
return network
if(reference==connected_device)
return network
return null
/obj/machinery/atmospherics/portables_connector/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network == old_network)
network = new_network
return 1
/obj/machinery/atmospherics/portables_connector/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(connected_device)
results += connected_device.air_contents
return results
/obj/machinery/atmospherics/portables_connector/disconnect(obj/machinery/atmospherics/reference)
if(reference==node)
qdel(network)
node = null
update_underlays()
return null
/obj/machinery/atmospherics/portables_connector/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (connected_device)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], dettach \the [connected_device] first.</span>")
return 1
if (locate(/obj/machinery/portable_atmospherics, src.loc))
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()

View File

@@ -1,231 +1,231 @@
/obj/machinery/atmospherics/trinary/atmos_filter
icon = 'icons/atmos/filter.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "filter"
density = FALSE
level = 1
name = "Gas filter"
desc = "Filters one type of gas from an input, and pushes it out the side."
use_power = USE_POWER_IDLE
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //This also doubles as a measure of how powerful the filter is, in Watts. 7500 W ~ 10 HP
var/temp = null // -- TLE
var/set_flow_rate = ATMOS_DEFAULT_VOLUME_FILTER
/*
Filter types:
-1: Nothing
0: Phoron: Phoron, Oxygen Agent B
1: Oxygen: Oxygen ONLY
2: Nitrogen: Nitrogen ONLY
3: Carbon Dioxide: Carbon Dioxide ONLY
4: Nitrous Oxide (Formerly called Sleeping Agent) (N2O)
*/
var/filter_type = -1
var/list/filtered_out = list()
var/frequency = 0
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/trinary/atmos_filter/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/trinary/atmos_filter/New()
..()
switch(filter_type)
if(0) //removing hydrocarbons
filtered_out = list("phoron")
if(1) //removing O2
filtered_out = list("oxygen")
if(2) //removing N2
filtered_out = list("nitrogen")
if(3) //removing CO2
filtered_out = list("carbon_dioxide")
if(4)//removing N2O
filtered_out = list("nitrous_oxide")
air1.volume = ATMOS_DEFAULT_VOLUME_FILTER
air2.volume = ATMOS_DEFAULT_VOLUME_FILTER
air3.volume = ATMOS_DEFAULT_VOLUME_FILTER
/obj/machinery/atmospherics/trinary/atmos_filter/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/trinary/atmos_filter/update_icon()
if(mirrored)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += use_power ? "on" : "off"
else
icon_state += "off"
update_use_power(USE_POWER_OFF)
/obj/machinery/atmospherics/trinary/atmos_filter/process()
..()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
//Figure out the amount of moles to transfer
var/transfer_moles = (set_flow_rate/air1.volume)*air1.total_moles
var/power_draw = -1
if (transfer_moles > MINIMUM_MOLES_TO_FILTER)
power_draw = filter_gas(src, filtered_out, air1, air2, air3, transfer_moles, power_rating)
if(network2)
network2.update = 1
if(network3)
network3.update = 1
if(network1)
network1.update = 1
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
return 1
/obj/machinery/atmospherics/trinary/atmos_filter/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/trinary/atmos_filter/attack_hand(user) // -- TLE
if(..())
return
if(!src.allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
tgui_interact(user)
// var/dat
// var/current_filter_type
// switch(filter_type)
// if(0)
// current_filter_type = "Phoron"
// if(1)
// current_filter_type = "Oxygen"
// if(2)
// current_filter_type = "Nitrogen"
// if(3)
// current_filter_type = "Carbon Dioxide"
// if(4)
// current_filter_type = "Nitrous Oxide"
// if(-1)
// current_filter_type = "Nothing"
// else
// current_filter_type = "ERROR - Report this bug to the admin, please!"
// dat += {"
// <b>Power: </b><a href='?src=\ref[src];power=1'>[use_power?"On":"Off"]</a><br>
// <b>Filtering: </b>[current_filter_type]<br><HR>
// <h4>Set Filter Type:</h4>
// <A href='?src=\ref[src];filterset=0'>Phoron</A><BR>
// <A href='?src=\ref[src];filterset=1'>Oxygen</A><BR>
// <A href='?src=\ref[src];filterset=2'>Nitrogen</A><BR>
// <A href='?src=\ref[src];filterset=3'>Carbon Dioxide</A><BR>
// <A href='?src=\ref[src];filterset=4'>Nitrous Oxide</A><BR>
// <A href='?src=\ref[src];filterset=-1'>Nothing</A><BR>
// <HR>
// <B>Set Flow Rate Limit:</B>
// [src.set_flow_rate]L/s | <a href='?src=\ref[src];set_flow_rate=1'>Change</a><BR>
// <B>Flow rate: </B>[round(last_flow_rate, 0.1)]L/s
// "}
// user << browse("<HEAD><TITLE>[src.name] control</TITLE></HEAD><TT>[dat]</TT>", "window=atmos_filter")
// onclose(user, "atmos_filter")
/obj/machinery/atmospherics/trinary/atmos_filter/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AtmosFilter", name)
ui.open()
/obj/machinery/atmospherics/trinary/atmos_filter/tgui_data(mob/user)
var/list/data = list()
data["on"] = use_power
data["rate"] = set_flow_rate
data["max_rate"] = air1.volume
data["last_flow_rate"] = round(last_flow_rate, 0.1)
data["filter_types"] = list()
data["filter_types"] += list(list("name" = "Nothing", "f_type" = -1, "selected" = filter_type == -1))
data["filter_types"] += list(list("name" = "Phoron", "f_type" = 0, "selected" = filter_type == 0))
data["filter_types"] += list(list("name" = "Oxygen", "f_type" = 1, "selected" = filter_type == 1))
data["filter_types"] += list(list("name" = "Nitrogen", "f_type" = 2, "selected" = filter_type == 2))
data["filter_types"] += list(list("name" = "Carbon Dioxide", "f_type" = 3, "selected" = filter_type == 3))
data["filter_types"] += list(list("name" = "Nitrous Oxide", "f_type" = 4, "selected" = filter_type == 4))
return data
/obj/machinery/atmospherics/trinary/atmos_filter/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("power")
update_use_power(!use_power)
if("rate")
var/rate = params["rate"]
if(rate == "max")
rate = air1.volume
. = TRUE
else if(text2num(rate) != null)
rate = text2num(rate)
. = TRUE
if(.)
set_flow_rate = clamp(rate, 0, air1.volume)
if("filter")
. = TRUE
filter_type = text2num(params["filterset"])
filtered_out.Cut() //no need to create new lists unnecessarily
switch(filter_type)
if(0) //removing hydrocarbons
filtered_out += "phoron"
filtered_out += "oxygen_agent_b"
if(1) //removing O2
filtered_out += "oxygen"
if(2) //removing N2
filtered_out += "nitrogen"
if(3) //removing CO2
filtered_out += "carbon_dioxide"
if(4)//removing N2O
filtered_out += "nitrous_oxide"
add_fingerprint(usr)
update_icon()
//
// Mirrored Orientation - Flips the output dir to opposite side from normal.
//
/obj/machinery/atmospherics/trinary/atmos_filter/m_filter
icon_state = "mmap"
dir = SOUTH
initialize_directions = SOUTH|NORTH|EAST
mirrored = TRUE
/obj/machinery/atmospherics/trinary/atmos_filter
icon = 'icons/atmos/filter.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "filter"
density = FALSE
level = 1
name = "Gas filter"
desc = "Filters one type of gas from an input, and pushes it out the side."
use_power = USE_POWER_IDLE
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //This also doubles as a measure of how powerful the filter is, in Watts. 7500 W ~ 10 HP
var/temp = null // -- TLE
var/set_flow_rate = ATMOS_DEFAULT_VOLUME_FILTER
/*
Filter types:
-1: Nothing
0: Phoron: Phoron, Oxygen Agent B
1: Oxygen: Oxygen ONLY
2: Nitrogen: Nitrogen ONLY
3: Carbon Dioxide: Carbon Dioxide ONLY
4: Nitrous Oxide (Formerly called Sleeping Agent) (N2O)
*/
var/filter_type = -1
var/list/filtered_out = list()
var/frequency = 0
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/trinary/atmos_filter/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/trinary/atmos_filter/New()
..()
switch(filter_type)
if(0) //removing hydrocarbons
filtered_out = list("phoron")
if(1) //removing O2
filtered_out = list("oxygen")
if(2) //removing N2
filtered_out = list("nitrogen")
if(3) //removing CO2
filtered_out = list("carbon_dioxide")
if(4)//removing N2O
filtered_out = list("nitrous_oxide")
air1.volume = ATMOS_DEFAULT_VOLUME_FILTER
air2.volume = ATMOS_DEFAULT_VOLUME_FILTER
air3.volume = ATMOS_DEFAULT_VOLUME_FILTER
/obj/machinery/atmospherics/trinary/atmos_filter/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/trinary/atmos_filter/update_icon()
if(mirrored)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += use_power ? "on" : "off"
else
icon_state += "off"
update_use_power(USE_POWER_OFF)
/obj/machinery/atmospherics/trinary/atmos_filter/process()
..()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
//Figure out the amount of moles to transfer
var/transfer_moles = (set_flow_rate/air1.volume)*air1.total_moles
var/power_draw = -1
if (transfer_moles > MINIMUM_MOLES_TO_FILTER)
power_draw = filter_gas(src, filtered_out, air1, air2, air3, transfer_moles, power_rating)
if(network2)
network2.update = 1
if(network3)
network3.update = 1
if(network1)
network1.update = 1
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
return 1
/obj/machinery/atmospherics/trinary/atmos_filter/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/trinary/atmos_filter/attack_hand(user) // -- TLE
if(..())
return
if(!src.allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
tgui_interact(user)
// var/dat
// var/current_filter_type
// switch(filter_type)
// if(0)
// current_filter_type = "Phoron"
// if(1)
// current_filter_type = "Oxygen"
// if(2)
// current_filter_type = "Nitrogen"
// if(3)
// current_filter_type = "Carbon Dioxide"
// if(4)
// current_filter_type = "Nitrous Oxide"
// if(-1)
// current_filter_type = "Nothing"
// else
// current_filter_type = "ERROR - Report this bug to the admin, please!"
// dat += {"
// <b>Power: </b><a href='?src=\ref[src];power=1'>[use_power?"On":"Off"]</a><br>
// <b>Filtering: </b>[current_filter_type]<br><HR>
// <h4>Set Filter Type:</h4>
// <A href='?src=\ref[src];filterset=0'>Phoron</A><BR>
// <A href='?src=\ref[src];filterset=1'>Oxygen</A><BR>
// <A href='?src=\ref[src];filterset=2'>Nitrogen</A><BR>
// <A href='?src=\ref[src];filterset=3'>Carbon Dioxide</A><BR>
// <A href='?src=\ref[src];filterset=4'>Nitrous Oxide</A><BR>
// <A href='?src=\ref[src];filterset=-1'>Nothing</A><BR>
// <HR>
// <B>Set Flow Rate Limit:</B>
// [src.set_flow_rate]L/s | <a href='?src=\ref[src];set_flow_rate=1'>Change</a><BR>
// <B>Flow rate: </B>[round(last_flow_rate, 0.1)]L/s
// "}
// user << browse("<HEAD><TITLE>[src.name] control</TITLE></HEAD><TT>[dat]</TT>", "window=atmos_filter")
// onclose(user, "atmos_filter")
/obj/machinery/atmospherics/trinary/atmos_filter/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AtmosFilter", name)
ui.open()
/obj/machinery/atmospherics/trinary/atmos_filter/tgui_data(mob/user)
var/list/data = list()
data["on"] = use_power
data["rate"] = set_flow_rate
data["max_rate"] = air1.volume
data["last_flow_rate"] = round(last_flow_rate, 0.1)
data["filter_types"] = list()
data["filter_types"] += list(list("name" = "Nothing", "f_type" = -1, "selected" = filter_type == -1))
data["filter_types"] += list(list("name" = "Phoron", "f_type" = 0, "selected" = filter_type == 0))
data["filter_types"] += list(list("name" = "Oxygen", "f_type" = 1, "selected" = filter_type == 1))
data["filter_types"] += list(list("name" = "Nitrogen", "f_type" = 2, "selected" = filter_type == 2))
data["filter_types"] += list(list("name" = "Carbon Dioxide", "f_type" = 3, "selected" = filter_type == 3))
data["filter_types"] += list(list("name" = "Nitrous Oxide", "f_type" = 4, "selected" = filter_type == 4))
return data
/obj/machinery/atmospherics/trinary/atmos_filter/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("power")
update_use_power(!use_power)
if("rate")
var/rate = params["rate"]
if(rate == "max")
rate = air1.volume
. = TRUE
else if(text2num(rate) != null)
rate = text2num(rate)
. = TRUE
if(.)
set_flow_rate = clamp(rate, 0, air1.volume)
if("filter")
. = TRUE
filter_type = text2num(params["filterset"])
filtered_out.Cut() //no need to create new lists unnecessarily
switch(filter_type)
if(0) //removing hydrocarbons
filtered_out += "phoron"
filtered_out += "oxygen_agent_b"
if(1) //removing O2
filtered_out += "oxygen"
if(2) //removing N2
filtered_out += "nitrogen"
if(3) //removing CO2
filtered_out += "carbon_dioxide"
if(4)//removing N2O
filtered_out += "nitrous_oxide"
add_fingerprint(usr)
update_icon()
//
// Mirrored Orientation - Flips the output dir to opposite side from normal.
//
/obj/machinery/atmospherics/trinary/atmos_filter/m_filter
icon_state = "mmap"
dir = SOUTH
initialize_directions = SOUTH|NORTH|EAST
mirrored = TRUE

View File

@@ -1,181 +1,181 @@
/obj/machinery/atmospherics/trinary/mixer
icon = 'icons/atmos/mixer.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "mixer"
density = FALSE
level = 1
name = "Gas mixer"
use_power = USE_POWER_IDLE
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 3700 //This also doubles as a measure of how powerful the mixer is, in Watts. 3700 W ~ 5 HP
var/set_flow_rate = ATMOS_DEFAULT_VOLUME_MIXER
var/list/mixing_inputs
//for mapping
var/node1_concentration = 0.5
var/node2_concentration = 0.5
//node 3 is the outlet, nodes 1 & 2 are intakes
/obj/machinery/atmospherics/trinary/mixer/update_icon(var/safety = 0)
if(tee)
icon_state = "t"
else if(mirrored)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += use_power ? "on" : "off"
else
icon_state += "off"
update_use_power(USE_POWER_OFF)
/obj/machinery/atmospherics/trinary/mixer/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_MIXER
air2.volume = ATMOS_DEFAULT_VOLUME_MIXER
air3.volume = ATMOS_DEFAULT_VOLUME_MIXER * 1.5
if (!mixing_inputs)
mixing_inputs = list(src.air1 = node1_concentration, src.air2 = node2_concentration)
/obj/machinery/atmospherics/trinary/mixer/process()
..()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
//Figure out the amount of moles to transfer
var/transfer_moles = (set_flow_rate*mixing_inputs[air1]/air1.volume)*air1.total_moles + (set_flow_rate*mixing_inputs[air1]/air2.volume)*air2.total_moles
var/power_draw = -1
if (transfer_moles > MINIMUM_MOLES_TO_FILTER)
power_draw = mix_gas(src, mixing_inputs, air3, transfer_moles, power_rating)
if(network1 && mixing_inputs[air1])
network1.update = 1
if(network2 && mixing_inputs[air2])
network2.update = 1
if(network3)
network3.update = 1
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
return 1
/obj/machinery/atmospherics/trinary/mixer/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AtmosMixer", name)
ui.open()
/obj/machinery/atmospherics/trinary/mixer/tgui_data(mob/user)
var/list/data = list()
data["on"] = use_power
data["set_pressure"] = round(set_flow_rate)
data["max_pressure"] = min(air1.volume, air2.volume)
data["node1_concentration"] = round(mixing_inputs[air1]*100, 1)
data["node2_concentration"] = round(mixing_inputs[air2]*100, 1)
var/list/node_connects = get_node_connect_dirs()
data["node1_dir"] = dir_name(node_connects[1],TRUE)
data["node2_dir"] = dir_name(node_connects[2],TRUE)
return data
/obj/machinery/atmospherics/trinary/mixer/attack_hand(user as mob)
if(..())
return
tgui_interact(user)
// src.add_fingerprint(usr)
// if(!src.allowed(user))
// to_chat(user, "<span class='warning'>Access denied.</span>")
// return
// usr.set_machine(src)
// var/list/node_connects = get_node_connect_dirs()
// var/dat = {"<b>Power: </b><a href='?src=\ref[src];power=1'>[use_power?"On":"Off"]</a><br>
// <b>Set Flow Rate Limit: </b>
// [set_flow_rate]L/s | <a href='?src=\ref[src];set_press=1'>Change</a>
// <br>
// <b>Flow Rate: </b>[round(last_flow_rate, 0.1)]L/s
// <br><hr>
// <b>Node 1 ([dir_name(node_connects[1],TRUE)]) Concentration:</b>
// <a href='?src=\ref[src];node1_c=-0.1'><b>-</b></a>
// <a href='?src=\ref[src];node1_c=-0.01'>-</a>
// [mixing_inputs[air1]]([mixing_inputs[air1]*100]%)
// <a href='?src=\ref[src];node1_c=0.01'><b>+</b></a>
// <a href='?src=\ref[src];node1_c=0.1'>+</a>
// <br>
// <b>Node 2 ([dir_name(node_connects[2],TRUE)]) Concentration:</b>
// <a href='?src=\ref[src];node2_c=-0.1'><b>-</b></a>
// <a href='?src=\ref[src];node2_c=-0.01'>-</a>
// [mixing_inputs[air2]]([mixing_inputs[air2]*100]%)
// <a href='?src=\ref[src];node2_c=0.01'><b>+</b></a>
// <a href='?src=\ref[src];node2_c=0.1'>+</a>
// "}
// user << browse("<HEAD><TITLE>[src.name] control</TITLE></HEAD><TT>[dat]</TT>", "window=atmo_mixer")
// onclose(user, "atmo_mixer")
// return
/obj/machinery/atmospherics/trinary/mixer/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("power")
update_use_power(!use_power)
. = TRUE
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
pressure = min(air1.volume, air2.volume)
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
set_flow_rate = clamp(pressure, 0, min(air1.volume, air2.volume))
if("node1")
var/value = text2num(params["concentration"])
mixing_inputs[air1] = max(0, min(1, value / 100))
mixing_inputs[air2] = 1.0 - mixing_inputs[air1]
. = TRUE
if("node2")
var/value = text2num(params["concentration"])
mixing_inputs[air2] = max(0, min(1, value / 100))
mixing_inputs[air1] = 1.0 - mixing_inputs[air2]
. = TRUE
update_icon()
//
// "T" Orientation - Inputs are on oposite sides instead of adjacent
//
/obj/machinery/atmospherics/trinary/mixer/t_mixer
icon_state = "tmap"
construction_type = /obj/item/pipe/trinary // Can't flip a "T", its symmetrical
pipe_state = "t_mixer"
dir = SOUTH
initialize_directions = SOUTH|EAST|WEST
tee = TRUE
//
// Mirrored Orientation - Flips the output dir to opposite side from normal.
//
/obj/machinery/atmospherics/trinary/mixer/m_mixer
icon_state = "mmap"
dir = SOUTH
initialize_directions = SOUTH|NORTH|EAST
mirrored = TRUE
/obj/machinery/atmospherics/trinary/mixer
icon = 'icons/atmos/mixer.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "mixer"
density = FALSE
level = 1
name = "Gas mixer"
use_power = USE_POWER_IDLE
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 3700 //This also doubles as a measure of how powerful the mixer is, in Watts. 3700 W ~ 5 HP
var/set_flow_rate = ATMOS_DEFAULT_VOLUME_MIXER
var/list/mixing_inputs
//for mapping
var/node1_concentration = 0.5
var/node2_concentration = 0.5
//node 3 is the outlet, nodes 1 & 2 are intakes
/obj/machinery/atmospherics/trinary/mixer/update_icon(var/safety = 0)
if(tee)
icon_state = "t"
else if(mirrored)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += use_power ? "on" : "off"
else
icon_state += "off"
update_use_power(USE_POWER_OFF)
/obj/machinery/atmospherics/trinary/mixer/New()
..()
air1.volume = ATMOS_DEFAULT_VOLUME_MIXER
air2.volume = ATMOS_DEFAULT_VOLUME_MIXER
air3.volume = ATMOS_DEFAULT_VOLUME_MIXER * 1.5
if (!mixing_inputs)
mixing_inputs = list(src.air1 = node1_concentration, src.air2 = node2_concentration)
/obj/machinery/atmospherics/trinary/mixer/process()
..()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
//Figure out the amount of moles to transfer
var/transfer_moles = (set_flow_rate*mixing_inputs[air1]/air1.volume)*air1.total_moles + (set_flow_rate*mixing_inputs[air1]/air2.volume)*air2.total_moles
var/power_draw = -1
if (transfer_moles > MINIMUM_MOLES_TO_FILTER)
power_draw = mix_gas(src, mixing_inputs, air3, transfer_moles, power_rating)
if(network1 && mixing_inputs[air1])
network1.update = 1
if(network2 && mixing_inputs[air2])
network2.update = 1
if(network3)
network3.update = 1
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
return 1
/obj/machinery/atmospherics/trinary/mixer/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AtmosMixer", name)
ui.open()
/obj/machinery/atmospherics/trinary/mixer/tgui_data(mob/user)
var/list/data = list()
data["on"] = use_power
data["set_pressure"] = round(set_flow_rate)
data["max_pressure"] = min(air1.volume, air2.volume)
data["node1_concentration"] = round(mixing_inputs[air1]*100, 1)
data["node2_concentration"] = round(mixing_inputs[air2]*100, 1)
var/list/node_connects = get_node_connect_dirs()
data["node1_dir"] = dir_name(node_connects[1],TRUE)
data["node2_dir"] = dir_name(node_connects[2],TRUE)
return data
/obj/machinery/atmospherics/trinary/mixer/attack_hand(user as mob)
if(..())
return
tgui_interact(user)
// src.add_fingerprint(usr)
// if(!src.allowed(user))
// to_chat(user, "<span class='warning'>Access denied.</span>")
// return
// usr.set_machine(src)
// var/list/node_connects = get_node_connect_dirs()
// var/dat = {"<b>Power: </b><a href='?src=\ref[src];power=1'>[use_power?"On":"Off"]</a><br>
// <b>Set Flow Rate Limit: </b>
// [set_flow_rate]L/s | <a href='?src=\ref[src];set_press=1'>Change</a>
// <br>
// <b>Flow Rate: </b>[round(last_flow_rate, 0.1)]L/s
// <br><hr>
// <b>Node 1 ([dir_name(node_connects[1],TRUE)]) Concentration:</b>
// <a href='?src=\ref[src];node1_c=-0.1'><b>-</b></a>
// <a href='?src=\ref[src];node1_c=-0.01'>-</a>
// [mixing_inputs[air1]]([mixing_inputs[air1]*100]%)
// <a href='?src=\ref[src];node1_c=0.01'><b>+</b></a>
// <a href='?src=\ref[src];node1_c=0.1'>+</a>
// <br>
// <b>Node 2 ([dir_name(node_connects[2],TRUE)]) Concentration:</b>
// <a href='?src=\ref[src];node2_c=-0.1'><b>-</b></a>
// <a href='?src=\ref[src];node2_c=-0.01'>-</a>
// [mixing_inputs[air2]]([mixing_inputs[air2]*100]%)
// <a href='?src=\ref[src];node2_c=0.01'><b>+</b></a>
// <a href='?src=\ref[src];node2_c=0.1'>+</a>
// "}
// user << browse("<HEAD><TITLE>[src.name] control</TITLE></HEAD><TT>[dat]</TT>", "window=atmo_mixer")
// onclose(user, "atmo_mixer")
// return
/obj/machinery/atmospherics/trinary/mixer/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("power")
update_use_power(!use_power)
. = TRUE
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
pressure = min(air1.volume, air2.volume)
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
set_flow_rate = clamp(pressure, 0, min(air1.volume, air2.volume))
if("node1")
var/value = text2num(params["concentration"])
mixing_inputs[air1] = max(0, min(1, value / 100))
mixing_inputs[air2] = 1.0 - mixing_inputs[air1]
. = TRUE
if("node2")
var/value = text2num(params["concentration"])
mixing_inputs[air2] = max(0, min(1, value / 100))
mixing_inputs[air1] = 1.0 - mixing_inputs[air2]
. = TRUE
update_icon()
//
// "T" Orientation - Inputs are on oposite sides instead of adjacent
//
/obj/machinery/atmospherics/trinary/mixer/t_mixer
icon_state = "tmap"
construction_type = /obj/item/pipe/trinary // Can't flip a "T", its symmetrical
pipe_state = "t_mixer"
dir = SOUTH
initialize_directions = SOUTH|EAST|WEST
tee = TRUE
//
// Mirrored Orientation - Flips the output dir to opposite side from normal.
//
/obj/machinery/atmospherics/trinary/mixer/m_mixer
icon_state = "mmap"
dir = SOUTH
initialize_directions = SOUTH|NORTH|EAST
mirrored = TRUE

View File

@@ -1,248 +1,248 @@
/obj/machinery/atmospherics/trinary
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = USE_POWER_OFF
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/mirrored = FALSE
var/tee = FALSE
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/datum/gas_mixture/air3
var/obj/machinery/atmospherics/node3
var/datum/pipe_network/network1
var/datum/pipe_network/network2
var/datum/pipe_network/network3
/obj/machinery/atmospherics/trinary/New()
..()
air1 = new
air2 = new
air3 = new
air1.volume = 200
air2.volume = 200
air3.volume = 200
/obj/machinery/atmospherics/trinary/init_dir()
initialize_directions = get_initialize_directions_trinary(dir, mirrored, tee)
/obj/machinery/atmospherics/trinary/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
var/list/node_connects = get_node_connect_dirs()
add_underlay(T, node1, node_connects[1])
add_underlay(T, node2, node_connects[2])
add_underlay(T, node3, node_connects[3])
/obj/machinery/atmospherics/trinary/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/trinary/power_change()
var/old_stat = stat
. = ..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/trinary/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/trinary/get_neighbor_nodes_for_init()
return list(node1, node2, node3)
/obj/machinery/atmospherics/trinary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
else if(reference == node2)
network2 = new_network
else if (reference == node3)
network3 = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/trinary/Destroy()
. = ..()
if(node1)
node1.disconnect(src)
qdel(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
if(node3)
node3.disconnect(src)
qdel(network3)
node1 = null
node2 = null
node3 = null
// Get the direction each node is facing to connect.
// It now returns as a list so it can be fetched nicely, each entry corresponds to node of same number.
/obj/machinery/atmospherics/trinary/get_node_connect_dirs()
return get_node_connect_dirs_trinary(dir, mirrored, tee)
/obj/machinery/atmospherics/trinary/atmos_init()
if(node1 && node2 && node3)
return
var/list/node_connects = get_node_connect_dirs()
STANDARD_ATMOS_CHOOSE_NODE(1, node_connects[1])
STANDARD_ATMOS_CHOOSE_NODE(2, node_connects[2])
STANDARD_ATMOS_CHOOSE_NODE(3, node_connects[3])
update_icon()
update_underlays()
/obj/machinery/atmospherics/trinary/build_network()
if(!network1 && node1)
network1 = new /datum/pipe_network()
network1.normal_members += src
network1.build_network(node1, src)
if(!network2 && node2)
network2 = new /datum/pipe_network()
network2.normal_members += src
network2.build_network(node2, src)
if(!network3 && node3)
network3 = new /datum/pipe_network()
network3.normal_members += src
network3.build_network(node3, src)
/obj/machinery/atmospherics/trinary/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node1)
return network1
if(reference==node2)
return network2
if(reference==node3)
return network3
return null
/obj/machinery/atmospherics/trinary/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network1 == old_network)
network1 = new_network
if(network2 == old_network)
network2 = new_network
if(network3 == old_network)
network3 = new_network
return 1
/obj/machinery/atmospherics/trinary/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(network1 == reference)
results += air1
if(network2 == reference)
results += air2
if(network3 == reference)
results += air3
return results
/obj/machinery/atmospherics/trinary/disconnect(obj/machinery/atmospherics/reference)
if(reference==node1)
qdel(network1)
node1 = null
else if(reference==node2)
qdel(network2)
node2 = null
else if(reference==node3)
qdel(network3)
node3 = null
update_underlays()
return null
// Trinary init_dir() logic in a separate proc so it can be referenced from "trinary-ish" places like T-Valves
// TODO - Someday refactor those places under atmospherics/trinary
/proc/get_initialize_directions_trinary(var/dir, var/mirrored = FALSE, var/tee = FALSE)
if(tee)
switch(dir)
if(NORTH)
return EAST|NORTH|WEST
if(SOUTH)
return SOUTH|WEST|EAST
if(EAST)
return EAST|NORTH|SOUTH
if(WEST)
return WEST|NORTH|SOUTH
else if(mirrored)
switch(dir)
if(NORTH)
return WEST|NORTH|SOUTH
if(SOUTH)
return SOUTH|EAST|NORTH
if(EAST)
return EAST|WEST|NORTH
if(WEST)
return WEST|SOUTH|EAST
else
switch(dir)
if(NORTH)
return EAST|NORTH|SOUTH
if(SOUTH)
return SOUTH|WEST|NORTH
if(EAST)
return EAST|WEST|SOUTH
if(WEST)
return WEST|NORTH|EAST
// Trinary get_node_connect_dirs() logic in a separate proc so it can be referenced from "trinary-ish" places like T-Valves
/proc/get_node_connect_dirs_trinary(var/dir, var/mirrored = FALSE, var/tee = FALSE)
var/node1_connect
var/node2_connect
var/node3_connect
if(tee)
node1_connect = turn(dir, -90)
node2_connect = turn(dir, 90)
node3_connect = dir
else if(mirrored)
node1_connect = turn(dir, 180)
node2_connect = turn(dir, 90)
node3_connect = dir
else
node1_connect = turn(dir, 180)
node2_connect = turn(dir, -90)
node3_connect = dir
return list(node1_connect, node2_connect, node3_connect)
/obj/machinery/atmospherics/trinary
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = USE_POWER_OFF
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/mirrored = FALSE
var/tee = FALSE
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/datum/gas_mixture/air3
var/obj/machinery/atmospherics/node3
var/datum/pipe_network/network1
var/datum/pipe_network/network2
var/datum/pipe_network/network3
/obj/machinery/atmospherics/trinary/New()
..()
air1 = new
air2 = new
air3 = new
air1.volume = 200
air2.volume = 200
air3.volume = 200
/obj/machinery/atmospherics/trinary/init_dir()
initialize_directions = get_initialize_directions_trinary(dir, mirrored, tee)
/obj/machinery/atmospherics/trinary/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
var/list/node_connects = get_node_connect_dirs()
add_underlay(T, node1, node_connects[1])
add_underlay(T, node2, node_connects[2])
add_underlay(T, node3, node_connects[3])
/obj/machinery/atmospherics/trinary/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/trinary/power_change()
var/old_stat = stat
. = ..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/trinary/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/trinary/get_neighbor_nodes_for_init()
return list(node1, node2, node3)
/obj/machinery/atmospherics/trinary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
else if(reference == node2)
network2 = new_network
else if (reference == node3)
network3 = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/trinary/Destroy()
. = ..()
if(node1)
node1.disconnect(src)
qdel(network1)
if(node2)
node2.disconnect(src)
qdel(network2)
if(node3)
node3.disconnect(src)
qdel(network3)
node1 = null
node2 = null
node3 = null
// Get the direction each node is facing to connect.
// It now returns as a list so it can be fetched nicely, each entry corresponds to node of same number.
/obj/machinery/atmospherics/trinary/get_node_connect_dirs()
return get_node_connect_dirs_trinary(dir, mirrored, tee)
/obj/machinery/atmospherics/trinary/atmos_init()
if(node1 && node2 && node3)
return
var/list/node_connects = get_node_connect_dirs()
STANDARD_ATMOS_CHOOSE_NODE(1, node_connects[1])
STANDARD_ATMOS_CHOOSE_NODE(2, node_connects[2])
STANDARD_ATMOS_CHOOSE_NODE(3, node_connects[3])
update_icon()
update_underlays()
/obj/machinery/atmospherics/trinary/build_network()
if(!network1 && node1)
network1 = new /datum/pipe_network()
network1.normal_members += src
network1.build_network(node1, src)
if(!network2 && node2)
network2 = new /datum/pipe_network()
network2.normal_members += src
network2.build_network(node2, src)
if(!network3 && node3)
network3 = new /datum/pipe_network()
network3.normal_members += src
network3.build_network(node3, src)
/obj/machinery/atmospherics/trinary/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node1)
return network1
if(reference==node2)
return network2
if(reference==node3)
return network3
return null
/obj/machinery/atmospherics/trinary/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network1 == old_network)
network1 = new_network
if(network2 == old_network)
network2 = new_network
if(network3 == old_network)
network3 = new_network
return 1
/obj/machinery/atmospherics/trinary/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(network1 == reference)
results += air1
if(network2 == reference)
results += air2
if(network3 == reference)
results += air3
return results
/obj/machinery/atmospherics/trinary/disconnect(obj/machinery/atmospherics/reference)
if(reference==node1)
qdel(network1)
node1 = null
else if(reference==node2)
qdel(network2)
node2 = null
else if(reference==node3)
qdel(network3)
node3 = null
update_underlays()
return null
// Trinary init_dir() logic in a separate proc so it can be referenced from "trinary-ish" places like T-Valves
// TODO - Someday refactor those places under atmospherics/trinary
/proc/get_initialize_directions_trinary(var/dir, var/mirrored = FALSE, var/tee = FALSE)
if(tee)
switch(dir)
if(NORTH)
return EAST|NORTH|WEST
if(SOUTH)
return SOUTH|WEST|EAST
if(EAST)
return EAST|NORTH|SOUTH
if(WEST)
return WEST|NORTH|SOUTH
else if(mirrored)
switch(dir)
if(NORTH)
return WEST|NORTH|SOUTH
if(SOUTH)
return SOUTH|EAST|NORTH
if(EAST)
return EAST|WEST|NORTH
if(WEST)
return WEST|SOUTH|EAST
else
switch(dir)
if(NORTH)
return EAST|NORTH|SOUTH
if(SOUTH)
return SOUTH|WEST|NORTH
if(EAST)
return EAST|WEST|SOUTH
if(WEST)
return WEST|NORTH|EAST
// Trinary get_node_connect_dirs() logic in a separate proc so it can be referenced from "trinary-ish" places like T-Valves
/proc/get_node_connect_dirs_trinary(var/dir, var/mirrored = FALSE, var/tee = FALSE)
var/node1_connect
var/node2_connect
var/node3_connect
if(tee)
node1_connect = turn(dir, -90)
node2_connect = turn(dir, 90)
node3_connect = dir
else if(mirrored)
node1_connect = turn(dir, 180)
node2_connect = turn(dir, 90)
node3_connect = dir
else
node1_connect = turn(dir, 180)
node2_connect = turn(dir, -90)
node3_connect = dir
return list(node1_connect, node2_connect, node3_connect)

View File

@@ -1,175 +1,175 @@
//TODO: Put this under a common parent type with heaters to cut down on the copypasta
#define FREEZER_PERF_MULT 2.5
/obj/machinery/atmospherics/unary/freezer
name = "gas cooling system"
desc = "Cools gas when connected to pipe network"
icon = 'icons/obj/Cryogenic2_vr.dmi'
icon_state = "freezer_0"
density = TRUE
anchored = TRUE
use_power = USE_POWER_OFF
idle_power_usage = 5 // 5 Watts for thermostat related circuitry
circuit = /obj/item/weapon/circuitboard/unary_atmos/cooler
var/heatsink_temperature = T20C // The constant temperature reservoir into which the freezer pumps heat. Probably the hull of the station or something.
var/internal_volume = 600 // L
var/max_power_rating = 20000 // Power rating when the usage is turned up to 100
var/power_setting = 100
var/set_temperature = T20C // Thermostat
var/cooling = 0
/obj/machinery/atmospherics/unary/freezer/Initialize()
. = ..()
default_apply_parts()
/obj/machinery/atmospherics/unary/freezer/atmos_init()
if(node)
return
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src, node_connect))
if(can_be_node(target, 1))
node = target
break
if(check_for_obstacles())
node = null
if(node)
update_icon()
/obj/machinery/atmospherics/unary/freezer/update_icon()
if(node)
if(use_power && cooling)
icon_state = "freezer_1"
else
icon_state = "freezer"
else
icon_state = "freezer_0"
return
/obj/machinery/atmospherics/unary/freezer/attack_ai(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/freezer/attack_hand(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/freezer/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GasTemperatureSystem", name)
ui.open()
/obj/machinery/atmospherics/unary/freezer/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data["on"] = use_power ? 1 : 0
data["gasPressure"] = round(air_contents.return_pressure())
data["gasTemperature"] = round(air_contents.temperature)
data["minGasTemperature"] = 0
data["maxGasTemperature"] = round(T20C+500)
data["targetGasTemperature"] = round(set_temperature)
data["powerSetting"] = power_setting
var/temp_class = "good"
if(air_contents.temperature > (T0C - 20))
temp_class = "bad"
else if(air_contents.temperature < (T0C - 20) && air_contents.temperature > (T0C - 100))
temp_class = "average"
data["gasTemperatureClass"] = temp_class
return data
/obj/machinery/atmospherics/unary/freezer/tgui_act(action, params)
if(..())
return TRUE
. = TRUE
switch(action)
if("toggleStatus")
update_use_power(!use_power)
update_icon()
if("setGasTemperature")
var/amount = text2num(params["temp"])
if(amount > 0)
set_temperature = min(amount, 1000)
else
set_temperature = max(amount, 0)
if("setPower") //setting power to 0 is redundant anyways
var/new_setting = between(0, text2num(params["value"]), 100)
set_power_level(new_setting)
add_fingerprint(usr)
/obj/machinery/atmospherics/unary/freezer/process()
..()
if(stat & (NOPOWER|BROKEN) || !use_power)
cooling = 0
update_icon()
return
if(network && air_contents.temperature > set_temperature)
cooling = 1
var/heat_transfer = max( -air_contents.get_thermal_energy_change(set_temperature - 5), 0 )
//Assume the heat is being pumped into the hull which is fixed at heatsink_temperature
//not /really/ proper thermodynamics but whatever
var/cop = FREEZER_PERF_MULT * air_contents.temperature/heatsink_temperature //heatpump coefficient of performance from thermodynamics -> power used = heat_transfer/cop
heat_transfer = min(heat_transfer, cop * power_rating) //limit heat transfer by available power
var/removed = -air_contents.add_thermal_energy(-heat_transfer) //remove the heat
if(debug)
visible_message("[src]: Removing [removed] W.")
use_power(power_rating)
network.update = 1
else
cooling = 0
update_icon()
//upgrading parts
/obj/machinery/atmospherics/unary/freezer/RefreshParts()
..()
var/cap_rating = 0
var/manip_rating = 0
var/bin_rating = 0
for(var/obj/item/weapon/stock_parts/P in component_parts)
if(istype(P, /obj/item/weapon/stock_parts/capacitor))
cap_rating += P.rating
if(istype(P, /obj/item/weapon/stock_parts/manipulator))
manip_rating += P.rating
if(istype(P, /obj/item/weapon/stock_parts/matter_bin))
bin_rating += P.rating
max_power_rating = initial(max_power_rating) * cap_rating / 2 //more powerful
heatsink_temperature = initial(heatsink_temperature) / ((manip_rating + bin_rating) / 2) //more efficient
air_contents.volume = max(initial(internal_volume) - 200, 0) + 200 * bin_rating
set_power_level(power_setting)
/obj/machinery/atmospherics/unary/freezer/proc/set_power_level(var/new_power_setting)
power_setting = new_power_setting
power_rating = max_power_rating * (power_setting/100)
/obj/machinery/atmospherics/unary/freezer/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O))
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return
..()
/obj/machinery/atmospherics/unary/freezer/examine(mob/user)
. = ..()
if(panel_open)
. += "The maintenance hatch is open."
//TODO: Put this under a common parent type with heaters to cut down on the copypasta
#define FREEZER_PERF_MULT 2.5
/obj/machinery/atmospherics/unary/freezer
name = "gas cooling system"
desc = "Cools gas when connected to pipe network"
icon = 'icons/obj/Cryogenic2_vr.dmi'
icon_state = "freezer_0"
density = TRUE
anchored = TRUE
use_power = USE_POWER_OFF
idle_power_usage = 5 // 5 Watts for thermostat related circuitry
circuit = /obj/item/weapon/circuitboard/unary_atmos/cooler
var/heatsink_temperature = T20C // The constant temperature reservoir into which the freezer pumps heat. Probably the hull of the station or something.
var/internal_volume = 600 // L
var/max_power_rating = 20000 // Power rating when the usage is turned up to 100
var/power_setting = 100
var/set_temperature = T20C // Thermostat
var/cooling = 0
/obj/machinery/atmospherics/unary/freezer/Initialize()
. = ..()
default_apply_parts()
/obj/machinery/atmospherics/unary/freezer/atmos_init()
if(node)
return
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src, node_connect))
if(can_be_node(target, 1))
node = target
break
if(check_for_obstacles())
node = null
if(node)
update_icon()
/obj/machinery/atmospherics/unary/freezer/update_icon()
if(node)
if(use_power && cooling)
icon_state = "freezer_1"
else
icon_state = "freezer"
else
icon_state = "freezer_0"
return
/obj/machinery/atmospherics/unary/freezer/attack_ai(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/freezer/attack_hand(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/freezer/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GasTemperatureSystem", name)
ui.open()
/obj/machinery/atmospherics/unary/freezer/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data["on"] = use_power ? 1 : 0
data["gasPressure"] = round(air_contents.return_pressure())
data["gasTemperature"] = round(air_contents.temperature)
data["minGasTemperature"] = 0
data["maxGasTemperature"] = round(T20C+500)
data["targetGasTemperature"] = round(set_temperature)
data["powerSetting"] = power_setting
var/temp_class = "good"
if(air_contents.temperature > (T0C - 20))
temp_class = "bad"
else if(air_contents.temperature < (T0C - 20) && air_contents.temperature > (T0C - 100))
temp_class = "average"
data["gasTemperatureClass"] = temp_class
return data
/obj/machinery/atmospherics/unary/freezer/tgui_act(action, params)
if(..())
return TRUE
. = TRUE
switch(action)
if("toggleStatus")
update_use_power(!use_power)
update_icon()
if("setGasTemperature")
var/amount = text2num(params["temp"])
if(amount > 0)
set_temperature = min(amount, 1000)
else
set_temperature = max(amount, 0)
if("setPower") //setting power to 0 is redundant anyways
var/new_setting = between(0, text2num(params["value"]), 100)
set_power_level(new_setting)
add_fingerprint(usr)
/obj/machinery/atmospherics/unary/freezer/process()
..()
if(stat & (NOPOWER|BROKEN) || !use_power)
cooling = 0
update_icon()
return
if(network && air_contents.temperature > set_temperature)
cooling = 1
var/heat_transfer = max( -air_contents.get_thermal_energy_change(set_temperature - 5), 0 )
//Assume the heat is being pumped into the hull which is fixed at heatsink_temperature
//not /really/ proper thermodynamics but whatever
var/cop = FREEZER_PERF_MULT * air_contents.temperature/heatsink_temperature //heatpump coefficient of performance from thermodynamics -> power used = heat_transfer/cop
heat_transfer = min(heat_transfer, cop * power_rating) //limit heat transfer by available power
var/removed = -air_contents.add_thermal_energy(-heat_transfer) //remove the heat
if(debug)
visible_message("[src]: Removing [removed] W.")
use_power(power_rating)
network.update = 1
else
cooling = 0
update_icon()
//upgrading parts
/obj/machinery/atmospherics/unary/freezer/RefreshParts()
..()
var/cap_rating = 0
var/manip_rating = 0
var/bin_rating = 0
for(var/obj/item/weapon/stock_parts/P in component_parts)
if(istype(P, /obj/item/weapon/stock_parts/capacitor))
cap_rating += P.rating
if(istype(P, /obj/item/weapon/stock_parts/manipulator))
manip_rating += P.rating
if(istype(P, /obj/item/weapon/stock_parts/matter_bin))
bin_rating += P.rating
max_power_rating = initial(max_power_rating) * cap_rating / 2 //more powerful
heatsink_temperature = initial(heatsink_temperature) / ((manip_rating + bin_rating) / 2) //more efficient
air_contents.volume = max(initial(internal_volume) - 200, 0) + 200 * bin_rating
set_power_level(power_setting)
/obj/machinery/atmospherics/unary/freezer/proc/set_power_level(var/new_power_setting)
power_setting = new_power_setting
power_rating = max_power_rating * (power_setting/100)
/obj/machinery/atmospherics/unary/freezer/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O))
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return
..()
/obj/machinery/atmospherics/unary/freezer/examine(mob/user)
. = ..()
if(panel_open)
. += "The maintenance hatch is open."

View File

@@ -1,87 +1,87 @@
/obj/machinery/atmospherics/unary/heat_exchanger
icon = 'icons/obj/atmospherics/heat_exchanger.dmi'
icon_state = "intact"
pipe_state = "heunary"
density = TRUE
name = "Heat Exchanger"
desc = "Exchanges heat between two input gases. Setup for fast heat transfer"
var/obj/machinery/atmospherics/unary/heat_exchanger/partner = null
var/update_cycle
/obj/machinery/atmospherics/unary/heat_exchanger/update_icon()
if(node)
icon_state = "intact"
else
icon_state = "exposed"
return
/obj/machinery/atmospherics/unary/heat_exchanger/atmos_init()
if(!partner)
var/partner_connect = turn(dir,180)
for(var/obj/machinery/atmospherics/unary/heat_exchanger/target in get_step(src,partner_connect))
if(target.dir & get_dir(src,target))
partner = target
partner.partner = src
break
..()
/obj/machinery/atmospherics/unary/heat_exchanger/process()
..()
if(!partner)
return 0
if(!air_master || air_master.current_cycle <= update_cycle)
return 0
update_cycle = air_master.current_cycle
partner.update_cycle = air_master.current_cycle
var/air_heat_capacity = air_contents.heat_capacity()
var/other_air_heat_capacity = partner.air_contents.heat_capacity()
var/combined_heat_capacity = other_air_heat_capacity + air_heat_capacity
var/old_temperature = air_contents.temperature
var/other_old_temperature = partner.air_contents.temperature
if(combined_heat_capacity > 0)
var/combined_energy = partner.air_contents.temperature*other_air_heat_capacity + air_heat_capacity*air_contents.temperature
var/new_temperature = combined_energy/combined_heat_capacity
air_contents.temperature = new_temperature
partner.air_contents.temperature = new_temperature
if(network)
if(abs(old_temperature-air_contents.temperature) > 1)
network.update = 1
if(partner.network)
if(abs(other_old_temperature-partner.air_contents.temperature) > 1)
partner.network.update = 1
return 1
/obj/machinery/atmospherics/unary/heat_exchanger/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
var/turf/T = src.loc
if (level==1 && isturf(T) && !T.is_plating())
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if (!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
/obj/machinery/atmospherics/unary/heat_exchanger
icon = 'icons/obj/atmospherics/heat_exchanger.dmi'
icon_state = "intact"
pipe_state = "heunary"
density = TRUE
name = "Heat Exchanger"
desc = "Exchanges heat between two input gases. Setup for fast heat transfer"
var/obj/machinery/atmospherics/unary/heat_exchanger/partner = null
var/update_cycle
/obj/machinery/atmospherics/unary/heat_exchanger/update_icon()
if(node)
icon_state = "intact"
else
icon_state = "exposed"
return
/obj/machinery/atmospherics/unary/heat_exchanger/atmos_init()
if(!partner)
var/partner_connect = turn(dir,180)
for(var/obj/machinery/atmospherics/unary/heat_exchanger/target in get_step(src,partner_connect))
if(target.dir & get_dir(src,target))
partner = target
partner.partner = src
break
..()
/obj/machinery/atmospherics/unary/heat_exchanger/process()
..()
if(!partner)
return 0
if(!air_master || air_master.current_cycle <= update_cycle)
return 0
update_cycle = air_master.current_cycle
partner.update_cycle = air_master.current_cycle
var/air_heat_capacity = air_contents.heat_capacity()
var/other_air_heat_capacity = partner.air_contents.heat_capacity()
var/combined_heat_capacity = other_air_heat_capacity + air_heat_capacity
var/old_temperature = air_contents.temperature
var/other_old_temperature = partner.air_contents.temperature
if(combined_heat_capacity > 0)
var/combined_energy = partner.air_contents.temperature*other_air_heat_capacity + air_heat_capacity*air_contents.temperature
var/new_temperature = combined_energy/combined_heat_capacity
air_contents.temperature = new_temperature
partner.air_contents.temperature = new_temperature
if(network)
if(abs(old_temperature-air_contents.temperature) > 1)
network.update = 1
if(partner.network)
if(abs(other_old_temperature-partner.air_contents.temperature) > 1)
partner.network.update = 1
return 1
/obj/machinery/atmospherics/unary/heat_exchanger/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
var/turf/T = src.loc
if (level==1 && isturf(T) && !T.is_plating())
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if (!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()

View File

@@ -1,162 +1,162 @@
//TODO: Put this under a common parent type with freezers to cut down on the copypasta
#define HEATER_PERF_MULT 2.5
/obj/machinery/atmospherics/unary/heater
name = "gas heating system"
desc = "Heats gas when connected to a pipe network"
icon = 'icons/obj/Cryogenic2_vr.dmi'
icon_state = "heater_0"
density = TRUE
anchored = TRUE
use_power = USE_POWER_OFF
idle_power_usage = 5 //5 Watts for thermostat related circuitry
circuit = /obj/item/weapon/circuitboard/unary_atmos/heater
var/max_temperature = T20C + 680
var/internal_volume = 600 //L
var/max_power_rating = 20000 //power rating when the usage is turned up to 100
var/power_setting = 100
var/set_temperature = T20C //thermostat
var/heating = 0 //mainly for icon updates
/obj/machinery/atmospherics/unary/heater/Initialize()
. = ..()
default_apply_parts()
/obj/machinery/atmospherics/unary/heater/atmos_init()
if(node)
return
var/node_connect = dir
//check that there is something to connect to
for(var/obj/machinery/atmospherics/target in get_step(src, node_connect))
if(can_be_node(target, 1))
node = target
break
if(check_for_obstacles())
node = null
if(node)
update_icon()
/obj/machinery/atmospherics/unary/heater/update_icon()
if(node)
if(use_power && heating)
icon_state = "heater_1"
else
icon_state = "heater"
else
icon_state = "heater_0"
return
/obj/machinery/atmospherics/unary/heater/process()
..()
if(stat & (NOPOWER|BROKEN) || !use_power)
heating = 0
update_icon()
return
if(network && air_contents.total_moles && air_contents.temperature < set_temperature)
air_contents.add_thermal_energy(power_rating * HEATER_PERF_MULT)
use_power(power_rating)
heating = 1
network.update = 1
else
heating = 0
update_icon()
/obj/machinery/atmospherics/unary/heater/attack_ai(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/heater/attack_hand(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/heater/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GasTemperatureSystem", name)
ui.open()
/obj/machinery/atmospherics/unary/heater/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data["on"] = use_power ? 1 : 0
data["gasPressure"] = round(air_contents.return_pressure())
data["gasTemperature"] = round(air_contents.temperature)
data["minGasTemperature"] = 0
data["maxGasTemperature"] = round(max_temperature)
data["targetGasTemperature"] = round(set_temperature)
data["powerSetting"] = power_setting
var/temp_class = "average"
if(air_contents.temperature > (T20C+40))
temp_class = "bad"
data["gasTemperatureClass"] = temp_class
return data
/obj/machinery/atmospherics/unary/heater/tgui_act(action, params)
if(..())
return TRUE
. = TRUE
switch(action)
if("toggleStatus")
update_use_power(!use_power)
update_icon()
if("setGasTemperature")
var/amount = text2num(params["temp"])
if(amount > 0)
set_temperature = min(amount, max_temperature)
else
set_temperature = max(amount, 0)
if("setPower") //setting power to 0 is redundant anyways
var/new_setting = between(0, text2num(params["value"]), 100)
set_power_level(new_setting)
add_fingerprint(usr)
//upgrading parts
/obj/machinery/atmospherics/unary/heater/RefreshParts()
..()
var/cap_rating = 0
var/bin_rating = 0
for(var/obj/item/weapon/stock_parts/P in component_parts)
if(istype(P, /obj/item/weapon/stock_parts/capacitor))
cap_rating += P.rating
if(istype(P, /obj/item/weapon/stock_parts/matter_bin))
bin_rating += P.rating
max_power_rating = initial(max_power_rating) * cap_rating / 2
max_temperature = max(initial(max_temperature) - T20C, 0) * ((bin_rating * 4 + cap_rating) / 5) + T20C
air_contents.volume = max(initial(internal_volume) - 200, 0) + 200 * bin_rating
set_power_level(power_setting)
/obj/machinery/atmospherics/unary/heater/proc/set_power_level(var/new_power_setting)
power_setting = new_power_setting
power_rating = max_power_rating * (power_setting/100)
/obj/machinery/atmospherics/unary/heater/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O))
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return
..()
/obj/machinery/atmospherics/unary/heater/examine(mob/user)
. = ..()
if(panel_open)
. += "The maintenance hatch is open."
//TODO: Put this under a common parent type with freezers to cut down on the copypasta
#define HEATER_PERF_MULT 2.5
/obj/machinery/atmospherics/unary/heater
name = "gas heating system"
desc = "Heats gas when connected to a pipe network"
icon = 'icons/obj/Cryogenic2_vr.dmi'
icon_state = "heater_0"
density = TRUE
anchored = TRUE
use_power = USE_POWER_OFF
idle_power_usage = 5 //5 Watts for thermostat related circuitry
circuit = /obj/item/weapon/circuitboard/unary_atmos/heater
var/max_temperature = T20C + 680
var/internal_volume = 600 //L
var/max_power_rating = 20000 //power rating when the usage is turned up to 100
var/power_setting = 100
var/set_temperature = T20C //thermostat
var/heating = 0 //mainly for icon updates
/obj/machinery/atmospherics/unary/heater/Initialize()
. = ..()
default_apply_parts()
/obj/machinery/atmospherics/unary/heater/atmos_init()
if(node)
return
var/node_connect = dir
//check that there is something to connect to
for(var/obj/machinery/atmospherics/target in get_step(src, node_connect))
if(can_be_node(target, 1))
node = target
break
if(check_for_obstacles())
node = null
if(node)
update_icon()
/obj/machinery/atmospherics/unary/heater/update_icon()
if(node)
if(use_power && heating)
icon_state = "heater_1"
else
icon_state = "heater"
else
icon_state = "heater_0"
return
/obj/machinery/atmospherics/unary/heater/process()
..()
if(stat & (NOPOWER|BROKEN) || !use_power)
heating = 0
update_icon()
return
if(network && air_contents.total_moles && air_contents.temperature < set_temperature)
air_contents.add_thermal_energy(power_rating * HEATER_PERF_MULT)
use_power(power_rating)
heating = 1
network.update = 1
else
heating = 0
update_icon()
/obj/machinery/atmospherics/unary/heater/attack_ai(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/heater/attack_hand(mob/user as mob)
tgui_interact(user)
/obj/machinery/atmospherics/unary/heater/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "GasTemperatureSystem", name)
ui.open()
/obj/machinery/atmospherics/unary/heater/tgui_data(mob/user)
// this is the data which will be sent to the ui
var/data[0]
data["on"] = use_power ? 1 : 0
data["gasPressure"] = round(air_contents.return_pressure())
data["gasTemperature"] = round(air_contents.temperature)
data["minGasTemperature"] = 0
data["maxGasTemperature"] = round(max_temperature)
data["targetGasTemperature"] = round(set_temperature)
data["powerSetting"] = power_setting
var/temp_class = "average"
if(air_contents.temperature > (T20C+40))
temp_class = "bad"
data["gasTemperatureClass"] = temp_class
return data
/obj/machinery/atmospherics/unary/heater/tgui_act(action, params)
if(..())
return TRUE
. = TRUE
switch(action)
if("toggleStatus")
update_use_power(!use_power)
update_icon()
if("setGasTemperature")
var/amount = text2num(params["temp"])
if(amount > 0)
set_temperature = min(amount, max_temperature)
else
set_temperature = max(amount, 0)
if("setPower") //setting power to 0 is redundant anyways
var/new_setting = between(0, text2num(params["value"]), 100)
set_power_level(new_setting)
add_fingerprint(usr)
//upgrading parts
/obj/machinery/atmospherics/unary/heater/RefreshParts()
..()
var/cap_rating = 0
var/bin_rating = 0
for(var/obj/item/weapon/stock_parts/P in component_parts)
if(istype(P, /obj/item/weapon/stock_parts/capacitor))
cap_rating += P.rating
if(istype(P, /obj/item/weapon/stock_parts/matter_bin))
bin_rating += P.rating
max_power_rating = initial(max_power_rating) * cap_rating / 2
max_temperature = max(initial(max_temperature) - T20C, 0) * ((bin_rating * 4 + cap_rating) / 5) + T20C
air_contents.volume = max(initial(internal_volume) - 200, 0) + 200 * bin_rating
set_power_level(power_setting)
/obj/machinery/atmospherics/unary/heater/proc/set_power_level(var/new_power_setting)
power_setting = new_power_setting
power_rating = max_power_rating * (power_setting/100)
/obj/machinery/atmospherics/unary/heater/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O))
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return
..()
/obj/machinery/atmospherics/unary/heater/examine(mob/user)
. = ..()
if(panel_open)
. += "The maintenance hatch is open."

View File

@@ -1,177 +1,177 @@
//Basically a one way passive valve. If the pressure inside is greater than the environment then gas will flow passively,
//but it does not permit gas to flow back from the environment into the injector. Can be turned off to prevent any gas flow.
//When it receives the "inject" signal, it will try to pump it's entire contents into the environment regardless of pressure, using power.
/obj/machinery/atmospherics/unary/outlet_injector
icon = 'icons/atmos/injector.dmi'
icon_state = "map_injector"
pipe_state = "injector"
name = "air injector"
desc = "Passively injects air into its surroundings. Has a valve attached to it that can control flow rate."
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 15000 //15000 W ~ 20 HP
var/injecting = 0
var/volume_rate = 50 //flow rate limit
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
level = 1
/obj/machinery/atmospherics/unary/outlet_injector/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP + 500 //Give it a small reservoir for injecting. Also allows it to have a higher flow rate limit than vent pumps, to differentiate injectors a bit more.
/obj/machinery/atmospherics/unary/outlet_injector/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/unary/outlet_injector/update_icon()
if(!powered())
icon_state = "off"
else
icon_state = "[use_power ? "on" : "off"]"
/obj/machinery/atmospherics/unary/outlet_injector/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node, dir)
/obj/machinery/atmospherics/unary/outlet_injector/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/process()
..()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
var/power_draw = -1
var/datum/gas_mixture/environment = loc.return_air()
if(environment && air_contents.temperature > 0)
var/transfer_moles = (volume_rate/air_contents.volume)*air_contents.total_moles //apply flow rate limit
power_draw = pump_gas(src, air_contents, environment, transfer_moles, power_rating)
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network)
network.update = 1
return 1
/obj/machinery/atmospherics/unary/outlet_injector/proc/inject()
if(injecting || (stat & NOPOWER))
return 0
var/datum/gas_mixture/environment = loc.return_air()
if (!environment)
return 0
injecting = 1
if(air_contents.temperature > 0)
var/power_used = pump_gas(src, air_contents, environment, air_contents.total_moles, power_rating)
use_power(power_used)
if(network)
network.update = 1
flick("inject", src)
/obj/machinery/atmospherics/unary/outlet_injector/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency)
/obj/machinery/atmospherics/unary/outlet_injector/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AO",
"power" = use_power,
"volume_rate" = volume_rate,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal)
return 1
/obj/machinery/atmospherics/unary/outlet_injector/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/unary/outlet_injector/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"])
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"])
update_use_power(!use_power)
if(signal.data["inject"])
spawn inject()
return
if(signal.data["set_volume_rate"])
var/number = text2num(signal.data["set_volume_rate"])
volume_rate = between(0, number, air_contents.volume)
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/unary/outlet_injector/attack_hand(mob/user as mob)
to_chat(user, "<span class='notice'>You toggle \the [src].</span>")
injecting = !injecting
update_use_power(injecting ? USE_POWER_IDLE : USE_POWER_OFF)
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
//Basically a one way passive valve. If the pressure inside is greater than the environment then gas will flow passively,
//but it does not permit gas to flow back from the environment into the injector. Can be turned off to prevent any gas flow.
//When it receives the "inject" signal, it will try to pump it's entire contents into the environment regardless of pressure, using power.
/obj/machinery/atmospherics/unary/outlet_injector
icon = 'icons/atmos/injector.dmi'
icon_state = "map_injector"
pipe_state = "injector"
name = "air injector"
desc = "Passively injects air into its surroundings. Has a valve attached to it that can control flow rate."
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 15000 //15000 W ~ 20 HP
var/injecting = 0
var/volume_rate = 50 //flow rate limit
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
level = 1
/obj/machinery/atmospherics/unary/outlet_injector/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP + 500 //Give it a small reservoir for injecting. Also allows it to have a higher flow rate limit than vent pumps, to differentiate injectors a bit more.
/obj/machinery/atmospherics/unary/outlet_injector/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/unary/outlet_injector/update_icon()
if(!powered())
icon_state = "off"
else
icon_state = "[use_power ? "on" : "off"]"
/obj/machinery/atmospherics/unary/outlet_injector/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node, dir)
/obj/machinery/atmospherics/unary/outlet_injector/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/process()
..()
last_power_draw = 0
last_flow_rate = 0
if((stat & (NOPOWER|BROKEN)) || !use_power)
return
var/power_draw = -1
var/datum/gas_mixture/environment = loc.return_air()
if(environment && air_contents.temperature > 0)
var/transfer_moles = (volume_rate/air_contents.volume)*air_contents.total_moles //apply flow rate limit
power_draw = pump_gas(src, air_contents, environment, transfer_moles, power_rating)
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network)
network.update = 1
return 1
/obj/machinery/atmospherics/unary/outlet_injector/proc/inject()
if(injecting || (stat & NOPOWER))
return 0
var/datum/gas_mixture/environment = loc.return_air()
if (!environment)
return 0
injecting = 1
if(air_contents.temperature > 0)
var/power_used = pump_gas(src, air_contents, environment, air_contents.total_moles, power_rating)
use_power(power_used)
if(network)
network.update = 1
flick("inject", src)
/obj/machinery/atmospherics/unary/outlet_injector/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency)
/obj/machinery/atmospherics/unary/outlet_injector/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AO",
"power" = use_power,
"volume_rate" = volume_rate,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal)
return 1
/obj/machinery/atmospherics/unary/outlet_injector/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/unary/outlet_injector/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"])
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"])
update_use_power(!use_power)
if(signal.data["inject"])
spawn inject()
return
if(signal.data["set_volume_rate"])
var/number = text2num(signal.data["set_volume_rate"])
volume_rate = between(0, number, air_contents.volume)
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/unary/outlet_injector/attack_hand(mob/user as mob)
to_chat(user, "<span class='notice'>You toggle \the [src].</span>")
injecting = !injecting
update_use_power(injecting ? USE_POWER_IDLE : USE_POWER_OFF)
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()

View File

@@ -1,116 +1,116 @@
/obj/machinery/atmospherics/unary
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
//layer = TURF_LAYER+0.1
var/datum/gas_mixture/air_contents
var/obj/machinery/atmospherics/node
var/datum/pipe_network/network
var/welded = 0 //defining this here for ventcrawl stuff
/obj/machinery/atmospherics/unary/New()
..()
air_contents = new
air_contents.volume = 200
/obj/machinery/atmospherics/unary/init_dir()
initialize_directions = dir
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/unary/get_neighbor_nodes_for_init()
return list(node)
/obj/machinery/atmospherics/unary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node)
network = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/unary/Destroy()
. = ..()
if(node)
node.disconnect(src)
qdel(network)
node = null
/obj/machinery/atmospherics/unary/atmos_init()
if(node)
return
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
if(can_be_node(target, 1))
node = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/unary/build_network()
if(!network && node)
network = new /datum/pipe_network()
network.normal_members += src
network.build_network(node, src)
/obj/machinery/atmospherics/unary/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node)
return network
return null
/obj/machinery/atmospherics/unary/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network == old_network)
network = new_network
return 1
/obj/machinery/atmospherics/unary/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(network == reference)
results += air_contents
return results
/obj/machinery/atmospherics/unary/disconnect(obj/machinery/atmospherics/reference)
if(reference==node)
qdel(network)
node = null
update_icon()
update_underlays()
return null
// Check if there are any other atmos machines in the same turf that will block this machine from initializing.
// Intended for use when a frame-constructable machine (i.e. not made from pipe fittings) wants to wrench down and connect.
// Returns TRUE if something is blocking, FALSE if its okay to continue.
/obj/machinery/atmospherics/unary/proc/check_for_obstacles()
for(var/obj/machinery/atmospherics/M in loc)
if(M == src) continue
if((M.pipe_flags & pipe_flags & PIPING_ONE_PER_TURF)) //Only one dense/requires density object per tile, eg connectors/cryo/heater/coolers.
visible_message("<span class='warning'>\The [src]'s cannot be connected, something is hogging the tile!</span>")
return TRUE
if((M.piping_layer != piping_layer) && !((M.pipe_flags | flags) & PIPING_ALL_LAYER)) // Pipes on different layers can't block each other unless they are ALL_LAYER
continue
if(M.get_init_dirs() & get_init_dirs()) // matches at least one direction on either type of pipe
visible_message("<span class='warning'>\The [src]'s connector can't be connected, there is already a pipe at that location!</span>")
return TRUE
return FALSE
/obj/machinery/atmospherics/unary
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
//layer = TURF_LAYER+0.1
var/datum/gas_mixture/air_contents
var/obj/machinery/atmospherics/node
var/datum/pipe_network/network
var/welded = 0 //defining this here for ventcrawl stuff
/obj/machinery/atmospherics/unary/New()
..()
air_contents = new
air_contents.volume = 200
/obj/machinery/atmospherics/unary/init_dir()
initialize_directions = dir
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/unary/get_neighbor_nodes_for_init()
return list(node)
/obj/machinery/atmospherics/unary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node)
network = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
return null
/obj/machinery/atmospherics/unary/Destroy()
. = ..()
if(node)
node.disconnect(src)
qdel(network)
node = null
/obj/machinery/atmospherics/unary/atmos_init()
if(node)
return
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
if(can_be_node(target, 1))
node = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/unary/build_network()
if(!network && node)
network = new /datum/pipe_network()
network.normal_members += src
network.build_network(node, src)
/obj/machinery/atmospherics/unary/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node)
return network
return null
/obj/machinery/atmospherics/unary/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network == old_network)
network = new_network
return 1
/obj/machinery/atmospherics/unary/return_network_air(datum/pipe_network/reference)
var/list/results = list()
if(network == reference)
results += air_contents
return results
/obj/machinery/atmospherics/unary/disconnect(obj/machinery/atmospherics/reference)
if(reference==node)
qdel(network)
node = null
update_icon()
update_underlays()
return null
// Check if there are any other atmos machines in the same turf that will block this machine from initializing.
// Intended for use when a frame-constructable machine (i.e. not made from pipe fittings) wants to wrench down and connect.
// Returns TRUE if something is blocking, FALSE if its okay to continue.
/obj/machinery/atmospherics/unary/proc/check_for_obstacles()
for(var/obj/machinery/atmospherics/M in loc)
if(M == src) continue
if((M.pipe_flags & pipe_flags & PIPING_ONE_PER_TURF)) //Only one dense/requires density object per tile, eg connectors/cryo/heater/coolers.
visible_message("<span class='warning'>\The [src]'s cannot be connected, something is hogging the tile!</span>")
return TRUE
if((M.piping_layer != piping_layer) && !((M.pipe_flags | flags) & PIPING_ALL_LAYER)) // Pipes on different layers can't block each other unless they are ALL_LAYER
continue
if(M.get_init_dirs() & get_init_dirs()) // matches at least one direction on either type of pipe
visible_message("<span class='warning'>\The [src]'s connector can't be connected, there is already a pipe at that location!</span>")
return TRUE
return FALSE

View File

@@ -1,461 +1,461 @@
#define DEFAULT_PRESSURE_DELTA 10000
#define EXTERNAL_PRESSURE_BOUND ONE_ATMOSPHERE
#define INTERNAL_PRESSURE_BOUND 0
#define PRESSURE_CHECKS 1
#define PRESSURE_CHECK_EXTERNAL 1
#define PRESSURE_CHECK_INTERNAL 2
/obj/machinery/atmospherics/unary/vent_pump
icon = 'icons/atmos/vent_pump.dmi'
icon_state = "map_vent"
pipe_state = "uvent"
name = "Air Vent"
desc = "Has a valve and pump attached to it"
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 30000 //7500 W ~ 10 HP //VOREStation Edit - 30000 W
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY //connects to regular and supply pipes
blocks_emissive = FALSE
var/area/initial_loc
level = 1
var/area_uid
var/id_tag = null
var/hibernate = 0 //Do we even process?
var/pump_direction = 1 //0 = siphoning, 1 = releasing
var/external_pressure_bound = EXTERNAL_PRESSURE_BOUND
var/internal_pressure_bound = INTERNAL_PRESSURE_BOUND
var/pressure_checks = PRESSURE_CHECKS
//1: Do not pass external_pressure_bound
//2: Do not pass internal_pressure_bound
//3: Do not pass either
// Used when handling incoming radio signals requesting default settings
var/external_pressure_bound_default = EXTERNAL_PRESSURE_BOUND
var/internal_pressure_bound_default = INTERNAL_PRESSURE_BOUND
var/pressure_checks_default = PRESSURE_CHECKS
var/frequency = 1439
var/datum/radio_frequency/radio_connection
var/radio_filter_out
var/radio_filter_in
//var/datum/looping_sound/air_pump/soundloop
var/static/start_sound = 'sound/machines/air_pump/airpumpstart.ogg'
var/static/stop_sound = 'sound/machines/air_pump/airpumpshutdown.ogg'
/obj/machinery/atmospherics/unary/vent_pump/on
use_power = USE_POWER_IDLE
icon_state = "map_vent_out"
/obj/machinery/atmospherics/unary/vent_pump/aux
icon_state = "map_vent_aux"
icon_connect_type = "-aux"
connect_types = CONNECT_TYPE_AUX //connects to aux pipes
/obj/machinery/atmospherics/unary/vent_pump/siphon
pump_direction = 0
/obj/machinery/atmospherics/unary/vent_pump/siphon/on
use_power = USE_POWER_IDLE
icon_state = "map_vent_in"
/obj/machinery/atmospherics/unary/vent_pump/siphon/on/atmos
use_power = USE_POWER_IDLE
icon_state = "map_vent_in"
external_pressure_bound = 0
external_pressure_bound_default = 0
internal_pressure_bound = 2000
internal_pressure_bound_default = 2000
pressure_checks = 2
pressure_checks_default = 2
/obj/machinery/atmospherics/unary/vent_pump/Initialize()
. = ..()
//soundloop = new(list(src), FALSE)
/obj/machinery/atmospherics/unary/vent_pump/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP
icon = null
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
if (!id_tag)
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_pump/proc/update_area()
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_pump/Destroy()
unregister_radio(src, frequency)
if(initial_loc)
initial_loc.air_vent_info -= id_tag
initial_loc.air_vent_names -= id_tag
//QDEL_NULL(soundloop)
return ..()
/obj/machinery/atmospherics/unary/vent_pump/high_volume
name = "Large Air Vent"
power_channel = EQUIP
power_rating = 45000 //15 kW ~ 20 HP //VOREStation Edit - 45000
/obj/machinery/atmospherics/unary/vent_pump/high_volume/aux
icon_state = "map_vent_aux"
icon_connect_type = "-aux"
connect_types = CONNECT_TYPE_AUX //connects to aux pipes
/obj/machinery/atmospherics/unary/vent_pump/high_volume/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP + 800
// VOREStation Edit Start - Wall mounted vents
/obj/machinery/atmospherics/unary/vent_pump/high_volume/wall_mounted
name = "Wall Mounted Air Vent"
/obj/machinery/atmospherics/unary/vent_pump/high_volume/wall_mounted/can_unwrench()
return FALSE // No way to construct these, so don't let them be removed.
// Return the air from the turf in "front" of us (opposite the way the pipe is facing)
/obj/machinery/atmospherics/unary/vent_pump/high_volume/wall_mounted/return_air()
var/turf/T = get_step(src, reverse_dir[dir])
if(isnull(T))
return ..()
return T.return_air()
// VOREStation Edit End
/obj/machinery/atmospherics/unary/vent_pump/engine
name = "Engine Core Vent"
power_channel = ENVIRON
power_rating = 30000 //15 kW ~ 20 HP
/obj/machinery/atmospherics/unary/vent_pump/engine/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP + 500 //meant to match air injector
/obj/machinery/atmospherics/unary/vent_pump/update_icon(var/safety = 0)
if(!check_icon_cache())
return
cut_overlays()
var/vent_icon = "vent"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
vent_icon += "h"
if(welded)
vent_icon += "weld"
playsound(src, stop_sound, 25, ignore_walls = FALSE, preference = /datum/client_preference/air_pump_noise)
else if(!use_power || !node || (stat & (NOPOWER|BROKEN)))
vent_icon += "off"
playsound(src, stop_sound, 25, ignore_walls = FALSE, preference = /datum/client_preference/air_pump_noise)
else
vent_icon += "[pump_direction ? "out" : "in"]"
playsound(src, start_sound, 25, ignore_walls = FALSE, preference = /datum/client_preference/air_pump_noise)
add_overlay(icon_manager.get_atmos_icon("device", , , vent_icon))
/obj/machinery/atmospherics/unary/vent_pump/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
return
else
if(node)
add_underlay(T, node, dir, node.icon_connect_type)
else
add_underlay(T,, dir)
/obj/machinery/atmospherics/unary/vent_pump/hide()
update_icon()
update_underlays()
/obj/machinery/atmospherics/unary/vent_pump/proc/can_pump()
if(stat & (NOPOWER|BROKEN))
return 0
if(!use_power)
return 0
if(welded)
return 0
return 1
/obj/machinery/atmospherics/unary/vent_pump/process()
..()
if (hibernate)
return 1
if (!node)
update_use_power(USE_POWER_OFF)
if(!can_pump())
return 0
var/datum/gas_mixture/environment = return_air() // VOREStation Edit - Use our own proc
var/power_draw = -1
//Figure out the target pressure difference
var/pressure_delta = get_pressure_delta(environment)
//src.visible_message("DEBUG >>> [src]: pressure_delta = [pressure_delta]")
if((environment.temperature || air_contents.temperature) && pressure_delta > 0.5)
if(pump_direction) //internal -> external
var/transfer_moles = calculate_transfer_moles(air_contents, environment, pressure_delta)
power_draw = pump_gas(src, air_contents, environment, transfer_moles, power_rating)
else //external -> internal
var/transfer_moles = calculate_transfer_moles(environment, air_contents, pressure_delta, (network)? network.volume : 0)
//limit flow rate from turfs
transfer_moles = min(transfer_moles, environment.total_moles*air_contents.volume/environment.volume) //group_multiplier gets divided out here
power_draw = pump_gas(src, environment, air_contents, transfer_moles, power_rating)
else
//If we're in an area that is fucking ideal, and we don't have to do anything, chances are we won't next tick either so why redo these calculations?
//JESUS FUCK. THERE ARE LITERALLY 250 OF YOU MOTHERFUCKERS ON ZLEVEL ONE AND YOU DO THIS SHIT EVERY TICK WHEN VERY OFTEN THERE IS NO REASON TO
if(pump_direction && pressure_checks == PRESSURE_CHECK_EXTERNAL && controller_iteration > 10) //99% of all vents
//Fucking hibernate because you ain't doing shit.
hibernate = 1
spawn(rand(100,200)) //hibernate for 10 or 20 seconds randomly
hibernate = 0
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network)
network.update = 1
return 1
/obj/machinery/atmospherics/unary/vent_pump/proc/get_pressure_delta(datum/gas_mixture/environment)
var/pressure_delta = DEFAULT_PRESSURE_DELTA
var/environment_pressure = environment.return_pressure()
if(pump_direction) //internal -> external
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, external_pressure_bound - environment_pressure) //increasing the pressure here
if(pressure_checks & PRESSURE_CHECK_INTERNAL)
pressure_delta = min(pressure_delta, air_contents.return_pressure() - internal_pressure_bound) //decreasing the pressure here
else //external -> internal
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, environment_pressure - external_pressure_bound) //decreasing the pressure here
if(pressure_checks & PRESSURE_CHECK_INTERNAL)
pressure_delta = min(pressure_delta, internal_pressure_bound - air_contents.return_pressure()) //increasing the pressure here
return pressure_delta
/obj/machinery/atmospherics/unary/vent_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"area" = src.area_uid,
"tag" = src.id_tag,
"device" = "AVP",
"power" = use_power,
"direction" = pump_direction?("release"):("siphon"),
"checks" = pressure_checks,
"internal" = internal_pressure_bound,
"external" = external_pressure_bound,
"timestamp" = world.time,
"sigtype" = "status",
"power_draw" = last_power_draw,
"flow_rate" = last_flow_rate,
)
if(!initial_loc.air_vent_names[id_tag])
var/new_name = "[initial_loc.name] Vent Pump #[initial_loc.air_vent_names.len+1]"
initial_loc.air_vent_names[id_tag] = new_name
src.name = new_name
initial_loc.air_vent_info[id_tag] = signal.data
radio_connection.post_signal(src, signal, radio_filter_out)
return 1
/obj/machinery/atmospherics/unary/vent_pump/atmos_init()
..()
//some vents work his own special way
radio_filter_in = frequency==1439?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==1439?(RADIO_TO_AIRALARM):null
if(frequency)
radio_connection = register_radio(src, frequency, frequency, radio_filter_in)
src.broadcast_status()
/obj/machinery/atmospherics/unary/vent_pump/receive_signal(datum/signal/signal)
if(stat & (NOPOWER|BROKEN))
return
hibernate = 0
//log_admin("DEBUG \[[world.timeofday]\]: /obj/machinery/atmospherics/unary/vent_pump/receive_signal([signal.debug_print()])")
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["purge"] != null)
pressure_checks &= ~1
pump_direction = 0
if(signal.data["stabalize"] != null)
pressure_checks |= 1
pump_direction = 1
if(signal.data["power"] != null)
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"] != null)
update_use_power(!use_power)
if(signal.data["checks"] != null)
if (signal.data["checks"] == "default")
pressure_checks = pressure_checks_default
else
pressure_checks = text2num(signal.data["checks"])
if(signal.data["checks_toggle"] != null)
pressure_checks = (pressure_checks?0:3)
if(signal.data["direction"] != null)
pump_direction = text2num(signal.data["direction"])
if(signal.data["set_internal_pressure"] != null)
if (signal.data["set_internal_pressure"] == "default")
internal_pressure_bound = internal_pressure_bound_default
else
internal_pressure_bound = between(0,text2num(signal.data["set_internal_pressure"]),ONE_ATMOSPHERE*50)
if(signal.data["set_external_pressure"] != null)
if (signal.data["set_external_pressure"] == "default")
external_pressure_bound = external_pressure_bound_default
else
external_pressure_bound = between(0,text2num(signal.data["set_external_pressure"]),ONE_ATMOSPHERE*50)
if(signal.data["adjust_internal_pressure"] != null)
internal_pressure_bound = between(0,internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]),ONE_ATMOSPHERE*50)
if(signal.data["adjust_external_pressure"] != null)
external_pressure_bound = between(0,external_pressure_bound + text2num(signal.data["adjust_external_pressure"]),ONE_ATMOSPHERE*50)
if("reset_external_pressure" in signal.data)
external_pressure_bound = ONE_ATMOSPHERE
if("reset_internal_pressure" in signal.data)
internal_pressure_bound = 0
if(signal.data["init"] != null)
name = signal.data["init"]
return
if(signal.data["status"] != null)
spawn(2)
broadcast_status()
return //do not update_icon
//log_admin("DEBUG \[[world.timeofday]\]: vent_pump/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/unary/vent_pump/attackby(obj/item/W, mob/user)
if(W.has_tool_quality(TOOL_WELDER))
var/obj/item/weapon/weldingtool/WT = W.get_welder()
if (WT.remove_fuel(0,user))
to_chat(user, "<span class='notice'>Now welding the vent.</span>")
if(do_after(user, 20 * WT.toolspeed))
if(!src || !WT.isOn()) return
playsound(src, WT.usesound, 50, 1)
if(!welded)
user.visible_message("<b>\The [user]</b> welds the vent shut.", "<span class='notice'>You weld the vent shut.</span>", "You hear welding.")
welded = 1
update_icon()
else
user.visible_message("<span class='notice'>[user] unwelds the vent.</span>", "<span class='notice'>You unweld the vent.</span>", "You hear welding.")
welded = 0
update_icon()
else
to_chat(user, "<span class='notice'>The welding tool needs to be on to start this task.</span>")
else
to_chat(user, "<span class='warning'>You need more welding fuel to complete this task.</span>")
return 1
else
..()
/obj/machinery/atmospherics/unary/vent_pump/examine(mob/user)
. = ..()
if(Adjacent(user))
. += "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
else
. += "You are too far away to read the gauge."
if(welded)
. += "It seems welded shut."
/obj/machinery/atmospherics/unary/vent_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/unary/vent_pump/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (!(stat & NOPOWER) && use_power)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
var/turf/T = src.loc
if (node && node.level==1 && isturf(T) && !T.is_plating())
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
#undef DEFAULT_PRESSURE_DELTA
#undef EXTERNAL_PRESSURE_BOUND
#undef INTERNAL_PRESSURE_BOUND
#undef PRESSURE_CHECKS
#undef PRESSURE_CHECK_EXTERNAL
#undef PRESSURE_CHECK_INTERNAL
#define DEFAULT_PRESSURE_DELTA 10000
#define EXTERNAL_PRESSURE_BOUND ONE_ATMOSPHERE
#define INTERNAL_PRESSURE_BOUND 0
#define PRESSURE_CHECKS 1
#define PRESSURE_CHECK_EXTERNAL 1
#define PRESSURE_CHECK_INTERNAL 2
/obj/machinery/atmospherics/unary/vent_pump
icon = 'icons/atmos/vent_pump.dmi'
icon_state = "map_vent"
pipe_state = "uvent"
name = "Air Vent"
desc = "Has a valve and pump attached to it"
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 30000 //7500 W ~ 10 HP //VOREStation Edit - 30000 W
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY //connects to regular and supply pipes
blocks_emissive = FALSE
var/area/initial_loc
level = 1
var/area_uid
var/id_tag = null
var/hibernate = 0 //Do we even process?
var/pump_direction = 1 //0 = siphoning, 1 = releasing
var/external_pressure_bound = EXTERNAL_PRESSURE_BOUND
var/internal_pressure_bound = INTERNAL_PRESSURE_BOUND
var/pressure_checks = PRESSURE_CHECKS
//1: Do not pass external_pressure_bound
//2: Do not pass internal_pressure_bound
//3: Do not pass either
// Used when handling incoming radio signals requesting default settings
var/external_pressure_bound_default = EXTERNAL_PRESSURE_BOUND
var/internal_pressure_bound_default = INTERNAL_PRESSURE_BOUND
var/pressure_checks_default = PRESSURE_CHECKS
var/frequency = 1439
var/datum/radio_frequency/radio_connection
var/radio_filter_out
var/radio_filter_in
//var/datum/looping_sound/air_pump/soundloop
var/static/start_sound = 'sound/machines/air_pump/airpumpstart.ogg'
var/static/stop_sound = 'sound/machines/air_pump/airpumpshutdown.ogg'
/obj/machinery/atmospherics/unary/vent_pump/on
use_power = USE_POWER_IDLE
icon_state = "map_vent_out"
/obj/machinery/atmospherics/unary/vent_pump/aux
icon_state = "map_vent_aux"
icon_connect_type = "-aux"
connect_types = CONNECT_TYPE_AUX //connects to aux pipes
/obj/machinery/atmospherics/unary/vent_pump/siphon
pump_direction = 0
/obj/machinery/atmospherics/unary/vent_pump/siphon/on
use_power = USE_POWER_IDLE
icon_state = "map_vent_in"
/obj/machinery/atmospherics/unary/vent_pump/siphon/on/atmos
use_power = USE_POWER_IDLE
icon_state = "map_vent_in"
external_pressure_bound = 0
external_pressure_bound_default = 0
internal_pressure_bound = 2000
internal_pressure_bound_default = 2000
pressure_checks = 2
pressure_checks_default = 2
/obj/machinery/atmospherics/unary/vent_pump/Initialize()
. = ..()
//soundloop = new(list(src), FALSE)
/obj/machinery/atmospherics/unary/vent_pump/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP
icon = null
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
if (!id_tag)
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_pump/proc/update_area()
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_pump/Destroy()
unregister_radio(src, frequency)
if(initial_loc)
initial_loc.air_vent_info -= id_tag
initial_loc.air_vent_names -= id_tag
//QDEL_NULL(soundloop)
return ..()
/obj/machinery/atmospherics/unary/vent_pump/high_volume
name = "Large Air Vent"
power_channel = EQUIP
power_rating = 45000 //15 kW ~ 20 HP //VOREStation Edit - 45000
/obj/machinery/atmospherics/unary/vent_pump/high_volume/aux
icon_state = "map_vent_aux"
icon_connect_type = "-aux"
connect_types = CONNECT_TYPE_AUX //connects to aux pipes
/obj/machinery/atmospherics/unary/vent_pump/high_volume/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP + 800
// VOREStation Edit Start - Wall mounted vents
/obj/machinery/atmospherics/unary/vent_pump/high_volume/wall_mounted
name = "Wall Mounted Air Vent"
/obj/machinery/atmospherics/unary/vent_pump/high_volume/wall_mounted/can_unwrench()
return FALSE // No way to construct these, so don't let them be removed.
// Return the air from the turf in "front" of us (opposite the way the pipe is facing)
/obj/machinery/atmospherics/unary/vent_pump/high_volume/wall_mounted/return_air()
var/turf/T = get_step(src, reverse_dir[dir])
if(isnull(T))
return ..()
return T.return_air()
// VOREStation Edit End
/obj/machinery/atmospherics/unary/vent_pump/engine
name = "Engine Core Vent"
power_channel = ENVIRON
power_rating = 30000 //15 kW ~ 20 HP
/obj/machinery/atmospherics/unary/vent_pump/engine/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_PUMP + 500 //meant to match air injector
/obj/machinery/atmospherics/unary/vent_pump/update_icon(var/safety = 0)
if(!check_icon_cache())
return
cut_overlays()
var/vent_icon = "vent"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
vent_icon += "h"
if(welded)
vent_icon += "weld"
playsound(src, stop_sound, 25, ignore_walls = FALSE, preference = /datum/client_preference/air_pump_noise)
else if(!use_power || !node || (stat & (NOPOWER|BROKEN)))
vent_icon += "off"
playsound(src, stop_sound, 25, ignore_walls = FALSE, preference = /datum/client_preference/air_pump_noise)
else
vent_icon += "[pump_direction ? "out" : "in"]"
playsound(src, start_sound, 25, ignore_walls = FALSE, preference = /datum/client_preference/air_pump_noise)
add_overlay(icon_manager.get_atmos_icon("device", , , vent_icon))
/obj/machinery/atmospherics/unary/vent_pump/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
return
else
if(node)
add_underlay(T, node, dir, node.icon_connect_type)
else
add_underlay(T,, dir)
/obj/machinery/atmospherics/unary/vent_pump/hide()
update_icon()
update_underlays()
/obj/machinery/atmospherics/unary/vent_pump/proc/can_pump()
if(stat & (NOPOWER|BROKEN))
return 0
if(!use_power)
return 0
if(welded)
return 0
return 1
/obj/machinery/atmospherics/unary/vent_pump/process()
..()
if (hibernate)
return 1
if (!node)
update_use_power(USE_POWER_OFF)
if(!can_pump())
return 0
var/datum/gas_mixture/environment = return_air() // VOREStation Edit - Use our own proc
var/power_draw = -1
//Figure out the target pressure difference
var/pressure_delta = get_pressure_delta(environment)
//src.visible_message("DEBUG >>> [src]: pressure_delta = [pressure_delta]")
if((environment.temperature || air_contents.temperature) && pressure_delta > 0.5)
if(pump_direction) //internal -> external
var/transfer_moles = calculate_transfer_moles(air_contents, environment, pressure_delta)
power_draw = pump_gas(src, air_contents, environment, transfer_moles, power_rating)
else //external -> internal
var/transfer_moles = calculate_transfer_moles(environment, air_contents, pressure_delta, (network)? network.volume : 0)
//limit flow rate from turfs
transfer_moles = min(transfer_moles, environment.total_moles*air_contents.volume/environment.volume) //group_multiplier gets divided out here
power_draw = pump_gas(src, environment, air_contents, transfer_moles, power_rating)
else
//If we're in an area that is fucking ideal, and we don't have to do anything, chances are we won't next tick either so why redo these calculations?
//JESUS FUCK. THERE ARE LITERALLY 250 OF YOU MOTHERFUCKERS ON ZLEVEL ONE AND YOU DO THIS SHIT EVERY TICK WHEN VERY OFTEN THERE IS NO REASON TO
if(pump_direction && pressure_checks == PRESSURE_CHECK_EXTERNAL && controller_iteration > 10) //99% of all vents
//Fucking hibernate because you ain't doing shit.
hibernate = 1
spawn(rand(100,200)) //hibernate for 10 or 20 seconds randomly
hibernate = 0
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network)
network.update = 1
return 1
/obj/machinery/atmospherics/unary/vent_pump/proc/get_pressure_delta(datum/gas_mixture/environment)
var/pressure_delta = DEFAULT_PRESSURE_DELTA
var/environment_pressure = environment.return_pressure()
if(pump_direction) //internal -> external
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, external_pressure_bound - environment_pressure) //increasing the pressure here
if(pressure_checks & PRESSURE_CHECK_INTERNAL)
pressure_delta = min(pressure_delta, air_contents.return_pressure() - internal_pressure_bound) //decreasing the pressure here
else //external -> internal
if(pressure_checks & PRESSURE_CHECK_EXTERNAL)
pressure_delta = min(pressure_delta, environment_pressure - external_pressure_bound) //decreasing the pressure here
if(pressure_checks & PRESSURE_CHECK_INTERNAL)
pressure_delta = min(pressure_delta, internal_pressure_bound - air_contents.return_pressure()) //increasing the pressure here
return pressure_delta
/obj/machinery/atmospherics/unary/vent_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"area" = src.area_uid,
"tag" = src.id_tag,
"device" = "AVP",
"power" = use_power,
"direction" = pump_direction?("release"):("siphon"),
"checks" = pressure_checks,
"internal" = internal_pressure_bound,
"external" = external_pressure_bound,
"timestamp" = world.time,
"sigtype" = "status",
"power_draw" = last_power_draw,
"flow_rate" = last_flow_rate,
)
if(!initial_loc.air_vent_names[id_tag])
var/new_name = "[initial_loc.name] Vent Pump #[initial_loc.air_vent_names.len+1]"
initial_loc.air_vent_names[id_tag] = new_name
src.name = new_name
initial_loc.air_vent_info[id_tag] = signal.data
radio_connection.post_signal(src, signal, radio_filter_out)
return 1
/obj/machinery/atmospherics/unary/vent_pump/atmos_init()
..()
//some vents work his own special way
radio_filter_in = frequency==1439?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==1439?(RADIO_TO_AIRALARM):null
if(frequency)
radio_connection = register_radio(src, frequency, frequency, radio_filter_in)
src.broadcast_status()
/obj/machinery/atmospherics/unary/vent_pump/receive_signal(datum/signal/signal)
if(stat & (NOPOWER|BROKEN))
return
hibernate = 0
//log_admin("DEBUG \[[world.timeofday]\]: /obj/machinery/atmospherics/unary/vent_pump/receive_signal([signal.debug_print()])")
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["purge"] != null)
pressure_checks &= ~1
pump_direction = 0
if(signal.data["stabalize"] != null)
pressure_checks |= 1
pump_direction = 1
if(signal.data["power"] != null)
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"] != null)
update_use_power(!use_power)
if(signal.data["checks"] != null)
if (signal.data["checks"] == "default")
pressure_checks = pressure_checks_default
else
pressure_checks = text2num(signal.data["checks"])
if(signal.data["checks_toggle"] != null)
pressure_checks = (pressure_checks?0:3)
if(signal.data["direction"] != null)
pump_direction = text2num(signal.data["direction"])
if(signal.data["set_internal_pressure"] != null)
if (signal.data["set_internal_pressure"] == "default")
internal_pressure_bound = internal_pressure_bound_default
else
internal_pressure_bound = between(0,text2num(signal.data["set_internal_pressure"]),ONE_ATMOSPHERE*50)
if(signal.data["set_external_pressure"] != null)
if (signal.data["set_external_pressure"] == "default")
external_pressure_bound = external_pressure_bound_default
else
external_pressure_bound = between(0,text2num(signal.data["set_external_pressure"]),ONE_ATMOSPHERE*50)
if(signal.data["adjust_internal_pressure"] != null)
internal_pressure_bound = between(0,internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]),ONE_ATMOSPHERE*50)
if(signal.data["adjust_external_pressure"] != null)
external_pressure_bound = between(0,external_pressure_bound + text2num(signal.data["adjust_external_pressure"]),ONE_ATMOSPHERE*50)
if("reset_external_pressure" in signal.data)
external_pressure_bound = ONE_ATMOSPHERE
if("reset_internal_pressure" in signal.data)
internal_pressure_bound = 0
if(signal.data["init"] != null)
name = signal.data["init"]
return
if(signal.data["status"] != null)
spawn(2)
broadcast_status()
return //do not update_icon
//log_admin("DEBUG \[[world.timeofday]\]: vent_pump/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/unary/vent_pump/attackby(obj/item/W, mob/user)
if(W.has_tool_quality(TOOL_WELDER))
var/obj/item/weapon/weldingtool/WT = W.get_welder()
if (WT.remove_fuel(0,user))
to_chat(user, "<span class='notice'>Now welding the vent.</span>")
if(do_after(user, 20 * WT.toolspeed))
if(!src || !WT.isOn()) return
playsound(src, WT.usesound, 50, 1)
if(!welded)
user.visible_message("<b>\The [user]</b> welds the vent shut.", "<span class='notice'>You weld the vent shut.</span>", "You hear welding.")
welded = 1
update_icon()
else
user.visible_message("<span class='notice'>[user] unwelds the vent.</span>", "<span class='notice'>You unweld the vent.</span>", "You hear welding.")
welded = 0
update_icon()
else
to_chat(user, "<span class='notice'>The welding tool needs to be on to start this task.</span>")
else
to_chat(user, "<span class='warning'>You need more welding fuel to complete this task.</span>")
return 1
else
..()
/obj/machinery/atmospherics/unary/vent_pump/examine(mob/user)
. = ..()
if(Adjacent(user))
. += "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
else
. += "You are too far away to read the gauge."
if(welded)
. += "It seems welded shut."
/obj/machinery/atmospherics/unary/vent_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/unary/vent_pump/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (!(stat & NOPOWER) && use_power)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
var/turf/T = src.loc
if (node && node.level==1 && isturf(T) && !T.is_plating())
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
#undef DEFAULT_PRESSURE_DELTA
#undef EXTERNAL_PRESSURE_BOUND
#undef INTERNAL_PRESSURE_BOUND
#undef PRESSURE_CHECKS
#undef PRESSURE_CHECK_EXTERNAL
#undef PRESSURE_CHECK_INTERNAL

View File

@@ -1,300 +1,300 @@
/obj/machinery/atmospherics/unary/vent_scrubber
icon = 'icons/atmos/vent_scrubber.dmi'
icon_state = "map_scrubber_off"
pipe_state = "scrubber"
name = "Air Scrubber"
desc = "Has a valve and pump attached to it"
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //7500 W ~ 10 HP
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SCRUBBER //connects to regular and scrubber pipes
level = 1
var/area/initial_loc
var/id_tag = null
var/frequency = 1439
var/datum/radio_frequency/radio_connection
var/hibernate = 0 //Do we even process?
var/scrubbing = 1 //0 = siphoning, 1 = scrubbing
var/list/scrubbing_gas = list("carbon_dioxide", "phoron")
var/panic = 0 //is this scrubber panicked?
var/area_uid
var/radio_filter_out
var/radio_filter_in
/obj/machinery/atmospherics/unary/vent_scrubber/on
use_power = USE_POWER_IDLE
icon_state = "map_scrubber_on"
/obj/machinery/atmospherics/unary/vent_scrubber/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_FILTER
icon = null
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
if (!id_tag)
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/update_area()
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_scrubber/Destroy()
unregister_radio(src, frequency)
if(initial_loc)
initial_loc.air_scrub_info -= id_tag
initial_loc.air_scrub_names -= id_tag
return ..()
/obj/machinery/atmospherics/unary/vent_scrubber/update_icon(var/safety = 0)
if(!check_icon_cache())
return
cut_overlays()
var/scrubber_icon = "scrubber"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!powered())
scrubber_icon += "off"
else
scrubber_icon += "[use_power ? "[scrubbing ? "on" : "in"]" : "off"]"
add_overlay(icon_manager.get_atmos_icon("device", , , scrubber_icon))
/obj/machinery/atmospherics/unary/vent_scrubber/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
return
else
if(node)
add_underlay(T, node, dir, node.icon_connect_type)
else
add_underlay(T,, dir)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
radio_connection = radio_controller.add_object(src, frequency, radio_filter_in)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"area" = area_uid,
"tag" = id_tag,
"device" = "AScr",
"timestamp" = world.time,
"power" = use_power,
"scrubbing" = scrubbing,
"panic" = panic,
"filter_o2" = ("oxygen" in scrubbing_gas),
"filter_n2" = ("nitrogen" in scrubbing_gas),
"filter_co2" = ("carbon_dioxide" in scrubbing_gas),
"filter_phoron" = ("phoron" in scrubbing_gas),
"filter_n2o" = ("nitrous_oxide" in scrubbing_gas),
"filter_fuel" = ("volatile_fuel" in scrubbing_gas),
"sigtype" = "status"
)
if(!initial_loc.air_scrub_names[id_tag])
var/new_name = "[initial_loc.name] Air Scrubber #[initial_loc.air_scrub_names.len+1]"
initial_loc.air_scrub_names[id_tag] = new_name
src.name = new_name
initial_loc.air_scrub_info[id_tag] = signal.data
radio_connection.post_signal(src, signal, radio_filter_out)
return 1
/obj/machinery/atmospherics/unary/vent_scrubber/atmos_init()
..()
radio_filter_in = frequency==initial(frequency)?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==initial(frequency)?(RADIO_TO_AIRALARM):null
if (frequency)
set_frequency(frequency)
src.broadcast_status()
/obj/machinery/atmospherics/unary/vent_scrubber/process()
..()
if (hibernate)
return 1
if (!node)
update_use_power(USE_POWER_OFF)
//broadcast_status()
if(!use_power || (stat & (NOPOWER|BROKEN)))
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/power_draw = -1
if(scrubbing)
//limit flow rate from turfs
var/transfer_moles = min(environment.total_moles, environment.total_moles*MAX_SCRUBBER_FLOWRATE/environment.volume) //group_multiplier gets divided out here
power_draw = scrub_gas(src, scrubbing_gas, environment, air_contents, transfer_moles, power_rating)
else //Just siphon all air
//limit flow rate from turfs
var/transfer_moles = min(environment.total_moles, environment.total_moles*MAX_SIPHON_FLOWRATE/environment.volume) //group_multiplier gets divided out here
power_draw = pump_gas(src, environment, air_contents, transfer_moles, power_rating)
if(scrubbing && power_draw < 0 && controller_iteration > 10) //99% of all scrubbers
//Fucking hibernate because you ain't doing shit.
hibernate = 1
spawn(rand(100,200)) //hibernate for 10 or 20 seconds randomly
hibernate = 0
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network)
network.update = 1
return 1
/obj/machinery/atmospherics/unary/vent_scrubber/hide(var/i) //to make the little pipe section invisible, the icon changes.
update_icon()
update_underlays()
/obj/machinery/atmospherics/unary/vent_scrubber/receive_signal(datum/signal/signal)
if(stat & (NOPOWER|BROKEN))
return
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"] != null)
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"] != null)
update_use_power(!use_power)
if(signal.data["panic_siphon"]) //must be before if("scrubbing" thing
panic = text2num(signal.data["panic_siphon"])
if(panic)
update_use_power(USE_POWER_IDLE)
scrubbing = 0
else
scrubbing = 1
if(signal.data["toggle_panic_siphon"] != null)
panic = !panic
if(panic)
update_use_power(USE_POWER_IDLE)
scrubbing = 0
else
scrubbing = 1
if(signal.data["scrubbing"] != null)
scrubbing = text2num(signal.data["scrubbing"])
if(scrubbing)
panic = 0
if(signal.data["toggle_scrubbing"])
scrubbing = !scrubbing
if(scrubbing)
panic = 0
var/list/toggle = list()
if(!isnull(signal.data["o2_scrub"]) && text2num(signal.data["o2_scrub"]) != ("oxygen" in scrubbing_gas))
toggle += "oxygen"
else if(signal.data["toggle_o2_scrub"])
toggle += "oxygen"
if(!isnull(signal.data["n2_scrub"]) && text2num(signal.data["n2_scrub"]) != ("nitrogen" in scrubbing_gas))
toggle += "nitrogen"
else if(signal.data["toggle_n2_scrub"])
toggle += "nitrogen"
if(!isnull(signal.data["co2_scrub"]) && text2num(signal.data["co2_scrub"]) != ("carbon_dioxide" in scrubbing_gas))
toggle += "carbon_dioxide"
else if(signal.data["toggle_co2_scrub"])
toggle += "carbon_dioxide"
if(!isnull(signal.data["tox_scrub"]) && text2num(signal.data["tox_scrub"]) != ("phoron" in scrubbing_gas))
toggle += "phoron"
else if(signal.data["toggle_tox_scrub"])
toggle += "phoron"
if(!isnull(signal.data["n2o_scrub"]) && text2num(signal.data["n2o_scrub"]) != ("nitrous_oxide" in scrubbing_gas))
toggle += "nitrous_oxide"
else if(signal.data["toggle_n2o_scrub"])
toggle += "nitrous_oxide"
if(!isnull(signal.data["fuel_scrub"]) && text2num(signal.data["fuel_scrub"]) != ("volatile_fuel" in scrubbing_gas))
toggle += "volatile_fuel"
else if(signal.data["toggle_fuel_scrub"])
toggle += "volatile_fuel"
scrubbing_gas ^= toggle
if(signal.data["init"] != null)
name = signal.data["init"]
return
if(signal.data["status"] != null)
spawn(2)
broadcast_status()
return //do not update_icon
// log_admin("DEBUG \[[world.timeofday]\]: vent_scrubber/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/unary/vent_scrubber/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/unary/vent_scrubber/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (!(stat & NOPOWER) && use_power)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
var/turf/T = src.loc
if (node && node.level==1 && isturf(T) && !T.is_plating())
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
/obj/machinery/atmospherics/unary/vent_scrubber/examine(mob/user)
. = ..()
if(Adjacent(user))
. += "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
else
. += "You are too far away to read the gauge."
/obj/machinery/atmospherics/unary/vent_scrubber
icon = 'icons/atmos/vent_scrubber.dmi'
icon_state = "map_scrubber_off"
pipe_state = "scrubber"
name = "Air Scrubber"
desc = "Has a valve and pump attached to it"
use_power = USE_POWER_OFF
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //7500 W ~ 10 HP
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SCRUBBER //connects to regular and scrubber pipes
level = 1
var/area/initial_loc
var/id_tag = null
var/frequency = 1439
var/datum/radio_frequency/radio_connection
var/hibernate = 0 //Do we even process?
var/scrubbing = 1 //0 = siphoning, 1 = scrubbing
var/list/scrubbing_gas = list("carbon_dioxide", "phoron")
var/panic = 0 //is this scrubber panicked?
var/area_uid
var/radio_filter_out
var/radio_filter_in
/obj/machinery/atmospherics/unary/vent_scrubber/on
use_power = USE_POWER_IDLE
icon_state = "map_scrubber_on"
/obj/machinery/atmospherics/unary/vent_scrubber/New()
..()
air_contents.volume = ATMOS_DEFAULT_VOLUME_FILTER
icon = null
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
if (!id_tag)
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/update_area()
initial_loc = get_area(loc)
area_uid = "\ref[initial_loc]"
assign_uid()
id_tag = num2text(uid)
/obj/machinery/atmospherics/unary/vent_scrubber/Destroy()
unregister_radio(src, frequency)
if(initial_loc)
initial_loc.air_scrub_info -= id_tag
initial_loc.air_scrub_names -= id_tag
return ..()
/obj/machinery/atmospherics/unary/vent_scrubber/update_icon(var/safety = 0)
if(!check_icon_cache())
return
cut_overlays()
var/scrubber_icon = "scrubber"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!powered())
scrubber_icon += "off"
else
scrubber_icon += "[use_power ? "[scrubbing ? "on" : "in"]" : "off"]"
add_overlay(icon_manager.get_atmos_icon("device", , , scrubber_icon))
/obj/machinery/atmospherics/unary/vent_scrubber/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
if(!T.is_plating() && node && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
return
else
if(node)
add_underlay(T, node, dir, node.icon_connect_type)
else
add_underlay(T,, dir)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
radio_connection = radio_controller.add_object(src, frequency, radio_filter_in)
/obj/machinery/atmospherics/unary/vent_scrubber/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = TRANSMISSION_RADIO //radio signal
signal.source = src
signal.data = list(
"area" = area_uid,
"tag" = id_tag,
"device" = "AScr",
"timestamp" = world.time,
"power" = use_power,
"scrubbing" = scrubbing,
"panic" = panic,
"filter_o2" = ("oxygen" in scrubbing_gas),
"filter_n2" = ("nitrogen" in scrubbing_gas),
"filter_co2" = ("carbon_dioxide" in scrubbing_gas),
"filter_phoron" = ("phoron" in scrubbing_gas),
"filter_n2o" = ("nitrous_oxide" in scrubbing_gas),
"filter_fuel" = ("volatile_fuel" in scrubbing_gas),
"sigtype" = "status"
)
if(!initial_loc.air_scrub_names[id_tag])
var/new_name = "[initial_loc.name] Air Scrubber #[initial_loc.air_scrub_names.len+1]"
initial_loc.air_scrub_names[id_tag] = new_name
src.name = new_name
initial_loc.air_scrub_info[id_tag] = signal.data
radio_connection.post_signal(src, signal, radio_filter_out)
return 1
/obj/machinery/atmospherics/unary/vent_scrubber/atmos_init()
..()
radio_filter_in = frequency==initial(frequency)?(RADIO_FROM_AIRALARM):null
radio_filter_out = frequency==initial(frequency)?(RADIO_TO_AIRALARM):null
if (frequency)
set_frequency(frequency)
src.broadcast_status()
/obj/machinery/atmospherics/unary/vent_scrubber/process()
..()
if (hibernate)
return 1
if (!node)
update_use_power(USE_POWER_OFF)
//broadcast_status()
if(!use_power || (stat & (NOPOWER|BROKEN)))
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/power_draw = -1
if(scrubbing)
//limit flow rate from turfs
var/transfer_moles = min(environment.total_moles, environment.total_moles*MAX_SCRUBBER_FLOWRATE/environment.volume) //group_multiplier gets divided out here
power_draw = scrub_gas(src, scrubbing_gas, environment, air_contents, transfer_moles, power_rating)
else //Just siphon all air
//limit flow rate from turfs
var/transfer_moles = min(environment.total_moles, environment.total_moles*MAX_SIPHON_FLOWRATE/environment.volume) //group_multiplier gets divided out here
power_draw = pump_gas(src, environment, air_contents, transfer_moles, power_rating)
if(scrubbing && power_draw < 0 && controller_iteration > 10) //99% of all scrubbers
//Fucking hibernate because you ain't doing shit.
hibernate = 1
spawn(rand(100,200)) //hibernate for 10 or 20 seconds randomly
hibernate = 0
if (power_draw >= 0)
last_power_draw = power_draw
use_power(power_draw)
if(network)
network.update = 1
return 1
/obj/machinery/atmospherics/unary/vent_scrubber/hide(var/i) //to make the little pipe section invisible, the icon changes.
update_icon()
update_underlays()
/obj/machinery/atmospherics/unary/vent_scrubber/receive_signal(datum/signal/signal)
if(stat & (NOPOWER|BROKEN))
return
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command"))
return 0
if(signal.data["power"] != null)
update_use_power(text2num(signal.data["power"]))
if(signal.data["power_toggle"] != null)
update_use_power(!use_power)
if(signal.data["panic_siphon"]) //must be before if("scrubbing" thing
panic = text2num(signal.data["panic_siphon"])
if(panic)
update_use_power(USE_POWER_IDLE)
scrubbing = 0
else
scrubbing = 1
if(signal.data["toggle_panic_siphon"] != null)
panic = !panic
if(panic)
update_use_power(USE_POWER_IDLE)
scrubbing = 0
else
scrubbing = 1
if(signal.data["scrubbing"] != null)
scrubbing = text2num(signal.data["scrubbing"])
if(scrubbing)
panic = 0
if(signal.data["toggle_scrubbing"])
scrubbing = !scrubbing
if(scrubbing)
panic = 0
var/list/toggle = list()
if(!isnull(signal.data["o2_scrub"]) && text2num(signal.data["o2_scrub"]) != ("oxygen" in scrubbing_gas))
toggle += "oxygen"
else if(signal.data["toggle_o2_scrub"])
toggle += "oxygen"
if(!isnull(signal.data["n2_scrub"]) && text2num(signal.data["n2_scrub"]) != ("nitrogen" in scrubbing_gas))
toggle += "nitrogen"
else if(signal.data["toggle_n2_scrub"])
toggle += "nitrogen"
if(!isnull(signal.data["co2_scrub"]) && text2num(signal.data["co2_scrub"]) != ("carbon_dioxide" in scrubbing_gas))
toggle += "carbon_dioxide"
else if(signal.data["toggle_co2_scrub"])
toggle += "carbon_dioxide"
if(!isnull(signal.data["tox_scrub"]) && text2num(signal.data["tox_scrub"]) != ("phoron" in scrubbing_gas))
toggle += "phoron"
else if(signal.data["toggle_tox_scrub"])
toggle += "phoron"
if(!isnull(signal.data["n2o_scrub"]) && text2num(signal.data["n2o_scrub"]) != ("nitrous_oxide" in scrubbing_gas))
toggle += "nitrous_oxide"
else if(signal.data["toggle_n2o_scrub"])
toggle += "nitrous_oxide"
if(!isnull(signal.data["fuel_scrub"]) && text2num(signal.data["fuel_scrub"]) != ("volatile_fuel" in scrubbing_gas))
toggle += "volatile_fuel"
else if(signal.data["toggle_fuel_scrub"])
toggle += "volatile_fuel"
scrubbing_gas ^= toggle
if(signal.data["init"] != null)
name = signal.data["init"]
return
if(signal.data["status"] != null)
spawn(2)
broadcast_status()
return //do not update_icon
// log_admin("DEBUG \[[world.timeofday]\]: vent_scrubber/receive_signal: unknown command \"[signal.data["command"]]\"\n[signal.debug_print()]")
spawn(2)
broadcast_status()
update_icon()
return
/obj/machinery/atmospherics/unary/vent_scrubber/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/unary/vent_scrubber/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (!(stat & NOPOWER) && use_power)
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
var/turf/T = src.loc
if (node && node.level==1 && isturf(T) && !T.is_plating())
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
/obj/machinery/atmospherics/unary/vent_scrubber/examine(mob/user)
. = ..()
if(Adjacent(user))
. += "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
else
. += "You are too far away to read the gauge."

View File

@@ -1,311 +1,311 @@
/obj/machinery/atmospherics/valve
icon = 'icons/atmos/valve.dmi'
icon_state = "map_valve0"
construction_type = /obj/item/pipe/binary
pipe_state = "mvalve"
name = "manual valve"
desc = "A pipe valve"
level = 1
dir = SOUTH
initialize_directions = SOUTH|NORTH
var/open = 0
var/openDuringInit = 0
var/datum/pipe_network/network_node1
var/datum/pipe_network/network_node2
/obj/machinery/atmospherics/valve/open
open = 1
icon_state = "map_valve1"
/obj/machinery/atmospherics/valve/update_icon(animation)
if(animation)
flick("valve[src.open][!src.open]",src)
else
icon_state = "valve[open]"
/obj/machinery/atmospherics/valve/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, get_dir(src, node1))
add_underlay(T, node2, get_dir(src, node2))
/obj/machinery/atmospherics/valve/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/valve/init_dir()
switch(dir)
if(NORTH,SOUTH)
initialize_directions = NORTH|SOUTH
if(EAST,WEST)
initialize_directions = EAST|WEST
/obj/machinery/atmospherics/valve/get_neighbor_nodes_for_init()
return list(node1, node2)
/obj/machinery/atmospherics/valve/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network_node1 = new_network
if(open)
network_node2 = new_network
else if(reference == node2)
network_node2 = new_network
if(open)
network_node1 = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
if(open)
if(reference == node1)
if(node2)
return node2.network_expand(new_network, src)
else if(reference == node2)
if(node1)
return node1.network_expand(new_network, src)
return null
/obj/machinery/atmospherics/valve/Destroy()
. = ..()
if(node1)
node1.disconnect(src)
qdel(network_node1)
if(node2)
node2.disconnect(src)
qdel(network_node2)
node1 = null
node2 = null
/obj/machinery/atmospherics/valve/proc/open()
if(open) return 0
open = 1
update_icon()
if(network_node1&&network_node2)
network_node1.merge(network_node2)
network_node2 = network_node1
if(network_node1)
network_node1.update = 1
else if(network_node2)
network_node2.update = 1
return 1
/obj/machinery/atmospherics/valve/proc/close()
if(!open)
return 0
open = 0
update_icon()
if(network_node1)
qdel(network_node1)
if(network_node2)
qdel(network_node2)
build_network()
return 1
/obj/machinery/atmospherics/valve/proc/normalize_dir()
if(dir==3)
set_dir(1)
else if(dir==12)
set_dir(4)
/obj/machinery/atmospherics/valve/attack_ai(mob/user as mob)
return
/obj/machinery/atmospherics/valve/attack_hand(mob/user as mob)
src.add_fingerprint(usr)
update_icon(1)
sleep(10)
if (src.open)
src.close()
else
src.open()
/obj/machinery/atmospherics/valve/process()
..()
. = PROCESS_KILL
return
/obj/machinery/atmospherics/valve/atmos_init()
normalize_dir()
var/node1_dir
var/node2_dir
for(var/direction in cardinal)
if(direction&initialize_directions)
if (!node1_dir)
node1_dir = direction
else if (!node2_dir)
node2_dir = direction
STANDARD_ATMOS_CHOOSE_NODE(1, node1_dir)
STANDARD_ATMOS_CHOOSE_NODE(2, node2_dir)
build_network()
update_icon()
update_underlays()
if(openDuringInit)
close()
open()
openDuringInit = 0
/obj/machinery/atmospherics/valve/build_network()
if(!network_node1 && node1)
network_node1 = new /datum/pipe_network()
network_node1.normal_members += src
network_node1.build_network(node1, src)
if(!network_node2 && node2)
network_node2 = new /datum/pipe_network()
network_node2.normal_members += src
network_node2.build_network(node2, src)
/obj/machinery/atmospherics/valve/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node1)
return network_node1
if(reference==node2)
return network_node2
return null
/obj/machinery/atmospherics/valve/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network_node1 == old_network)
network_node1 = new_network
if(network_node2 == old_network)
network_node2 = new_network
return 1
/obj/machinery/atmospherics/valve/return_network_air(datum/pipe_network/reference)
return null
/obj/machinery/atmospherics/valve/disconnect(obj/machinery/atmospherics/reference)
if(reference==node1)
qdel(network_node1)
node1 = null
else if(reference==node2)
qdel(network_node2)
node2 = null
update_underlays()
return null
/obj/machinery/atmospherics/valve/digital // can be controlled by AI
name = "digital valve"
desc = "A digitally controlled valve."
icon = 'icons/atmos/digital_valve.dmi'
pipe_state = "dvalve"
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/valve/digital/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/valve/digital/attack_ai(mob/user as mob)
return src.attack_hand(user)
/obj/machinery/atmospherics/valve/digital/attack_hand(mob/user as mob)
if(!powered())
return
if(!src.allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
..()
/obj/machinery/atmospherics/valve/digital/open
open = 1
icon_state = "map_valve1"
/obj/machinery/atmospherics/valve/digital/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/valve/digital/update_icon()
..()
if(!powered())
icon_state = "valve[open]nopower"
/obj/machinery/atmospherics/valve/digital/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/valve/digital/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/valve/digital/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id))
return 0
switch(signal.data["command"])
if("valve_open")
if(!open)
open()
if("valve_close")
if(open)
close()
if("valve_toggle")
if(open)
close()
else
open()
/obj/machinery/atmospherics/valve/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (istype(src, /obj/machinery/atmospherics/valve/digital) && !src.allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
/obj/machinery/atmospherics/valve/examine(mob/user)
. = ..()
. += "It is [open ? "open" : "closed"]."
/obj/machinery/atmospherics/valve
icon = 'icons/atmos/valve.dmi'
icon_state = "map_valve0"
construction_type = /obj/item/pipe/binary
pipe_state = "mvalve"
name = "manual valve"
desc = "A pipe valve"
level = 1
dir = SOUTH
initialize_directions = SOUTH|NORTH
var/open = 0
var/openDuringInit = 0
var/datum/pipe_network/network_node1
var/datum/pipe_network/network_node2
/obj/machinery/atmospherics/valve/open
open = 1
icon_state = "map_valve1"
/obj/machinery/atmospherics/valve/update_icon(animation)
if(animation)
flick("valve[src.open][!src.open]",src)
else
icon_state = "valve[open]"
/obj/machinery/atmospherics/valve/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, get_dir(src, node1))
add_underlay(T, node2, get_dir(src, node2))
/obj/machinery/atmospherics/valve/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/valve/init_dir()
switch(dir)
if(NORTH,SOUTH)
initialize_directions = NORTH|SOUTH
if(EAST,WEST)
initialize_directions = EAST|WEST
/obj/machinery/atmospherics/valve/get_neighbor_nodes_for_init()
return list(node1, node2)
/obj/machinery/atmospherics/valve/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network_node1 = new_network
if(open)
network_node2 = new_network
else if(reference == node2)
network_node2 = new_network
if(open)
network_node1 = new_network
if(new_network.normal_members.Find(src))
return 0
new_network.normal_members += src
if(open)
if(reference == node1)
if(node2)
return node2.network_expand(new_network, src)
else if(reference == node2)
if(node1)
return node1.network_expand(new_network, src)
return null
/obj/machinery/atmospherics/valve/Destroy()
. = ..()
if(node1)
node1.disconnect(src)
qdel(network_node1)
if(node2)
node2.disconnect(src)
qdel(network_node2)
node1 = null
node2 = null
/obj/machinery/atmospherics/valve/proc/open()
if(open) return 0
open = 1
update_icon()
if(network_node1&&network_node2)
network_node1.merge(network_node2)
network_node2 = network_node1
if(network_node1)
network_node1.update = 1
else if(network_node2)
network_node2.update = 1
return 1
/obj/machinery/atmospherics/valve/proc/close()
if(!open)
return 0
open = 0
update_icon()
if(network_node1)
qdel(network_node1)
if(network_node2)
qdel(network_node2)
build_network()
return 1
/obj/machinery/atmospherics/valve/proc/normalize_dir()
if(dir==3)
set_dir(1)
else if(dir==12)
set_dir(4)
/obj/machinery/atmospherics/valve/attack_ai(mob/user as mob)
return
/obj/machinery/atmospherics/valve/attack_hand(mob/user as mob)
src.add_fingerprint(usr)
update_icon(1)
sleep(10)
if (src.open)
src.close()
else
src.open()
/obj/machinery/atmospherics/valve/process()
..()
. = PROCESS_KILL
return
/obj/machinery/atmospherics/valve/atmos_init()
normalize_dir()
var/node1_dir
var/node2_dir
for(var/direction in cardinal)
if(direction&initialize_directions)
if (!node1_dir)
node1_dir = direction
else if (!node2_dir)
node2_dir = direction
STANDARD_ATMOS_CHOOSE_NODE(1, node1_dir)
STANDARD_ATMOS_CHOOSE_NODE(2, node2_dir)
build_network()
update_icon()
update_underlays()
if(openDuringInit)
close()
open()
openDuringInit = 0
/obj/machinery/atmospherics/valve/build_network()
if(!network_node1 && node1)
network_node1 = new /datum/pipe_network()
network_node1.normal_members += src
network_node1.build_network(node1, src)
if(!network_node2 && node2)
network_node2 = new /datum/pipe_network()
network_node2.normal_members += src
network_node2.build_network(node2, src)
/obj/machinery/atmospherics/valve/return_network(obj/machinery/atmospherics/reference)
build_network()
if(reference==node1)
return network_node1
if(reference==node2)
return network_node2
return null
/obj/machinery/atmospherics/valve/reassign_network(datum/pipe_network/old_network, datum/pipe_network/new_network)
if(network_node1 == old_network)
network_node1 = new_network
if(network_node2 == old_network)
network_node2 = new_network
return 1
/obj/machinery/atmospherics/valve/return_network_air(datum/pipe_network/reference)
return null
/obj/machinery/atmospherics/valve/disconnect(obj/machinery/atmospherics/reference)
if(reference==node1)
qdel(network_node1)
node1 = null
else if(reference==node2)
qdel(network_node2)
node2 = null
update_underlays()
return null
/obj/machinery/atmospherics/valve/digital // can be controlled by AI
name = "digital valve"
desc = "A digitally controlled valve."
icon = 'icons/atmos/digital_valve.dmi'
pipe_state = "dvalve"
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/valve/digital/Destroy()
unregister_radio(src, frequency)
. = ..()
/obj/machinery/atmospherics/valve/digital/attack_ai(mob/user as mob)
return src.attack_hand(user)
/obj/machinery/atmospherics/valve/digital/attack_hand(mob/user as mob)
if(!powered())
return
if(!src.allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return
..()
/obj/machinery/atmospherics/valve/digital/open
open = 1
icon_state = "map_valve1"
/obj/machinery/atmospherics/valve/digital/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/valve/digital/update_icon()
..()
if(!powered())
icon_state = "valve[open]nopower"
/obj/machinery/atmospherics/valve/digital/proc/set_frequency(new_frequency)
radio_controller.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = radio_controller.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/valve/digital/Initialize()
. = ..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/valve/digital/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id))
return 0
switch(signal.data["command"])
if("valve_open")
if(!open)
open()
if("valve_close")
if(open)
close()
if("valve_toggle")
if(open)
close()
else
open()
/obj/machinery/atmospherics/valve/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!W.has_tool_quality(TOOL_WRENCH))
return ..()
if (istype(src, /obj/machinery/atmospherics/valve/digital) && !src.allowed(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<b>\The [user]</b> unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
/obj/machinery/atmospherics/valve/examine(mob/user)
. = ..()
. += "It is [open ? "open" : "closed"]."