File standardisation (#13131)

* Adds the check components

* Adds in trailing newlines

* Converts all CRLF to LF

* Post merge EOF

* Post merge line endings

* Final commit
This commit is contained in:
AffectedArc07
2020-03-17 22:08:51 +00:00
committed by GitHub
parent ec19ea3d2d
commit 04ba5c1cc9
1451 changed files with 183694 additions and 183593 deletions
+345 -345
View File
@@ -1,345 +1,345 @@
/*
Quick overview:
Pipes combine to form pipelines
Pipelines and other atmospheric objects combine to form pipe_networks
Note: A single pipe_network represents a completely open space
Pipes -> Pipelines
Pipelines + Other Objects -> Pipe network
*/
GLOBAL_DATUM_INIT(pipe_icon_manager, /datum/pipe_icon_manager, new())
/obj/machinery/atmospherics
anchored = 1
layer = GAS_PIPE_HIDDEN_LAYER //under wires
resistance_flags = FIRE_PROOF
max_integrity = 200
plane = FLOOR_PLANE
idle_power_usage = 0
active_power_usage = 0
power_channel = ENVIRON
on_blueprints = TRUE
var/nodealert = 0
var/can_unwrench = 0
var/connect_types[] = list(1) //1=regular, 2=supply, 3=scrubber
var/connected_to = 1 //same as above, currently not used for anything
var/icon_connect_type = "" //"-supply" or "-scrubbers"
var/initialize_directions = 0
var/pipe_color
var/obj/item/pipe/stored
var/image/pipe_image
/obj/machinery/atmospherics/New()
if (!armor)
armor = list("melee" = 25, "bullet" = 10, "laser" = 10, "energy" = 100, "bomb" = 0, "bio" = 100, "rad" = 100, "fire" = 100, "acid" = 70)
..()
if(!pipe_color)
pipe_color = color
color = null
if(!pipe_color_check(pipe_color))
pipe_color = null
/obj/machinery/atmospherics/Initialize()
. = ..()
SSair.atmos_machinery += src
/obj/machinery/atmospherics/proc/atmos_init()
if(can_unwrench)
stored = new(src, make_from = src)
/obj/machinery/atmospherics/Destroy()
QDEL_NULL(stored)
SSair.atmos_machinery -= src
SSair.deferred_pipenet_rebuilds -= src
for(var/mob/living/L in src) //ventcrawling is serious business
L.remove_ventcrawl()
L.forceMove(get_turf(src))
QDEL_NULL(pipe_image) //we have to del it, or it might keep a ref somewhere else
return ..()
// Icons/overlays/underlays
/obj/machinery/atmospherics/update_icon()
var/turf/T = get_turf(loc)
if(!T || level == 2 || !T.intact)
plane = GAME_PLANE
else
plane = FLOOR_PLANE
/obj/machinery/atmospherics/proc/update_pipe_image()
pipe_image = image(src, loc, layer = ABOVE_HUD_LAYER, dir = dir) //the 20 puts it above Byond's darkness (not its opacity view)
pipe_image.plane = HUD_PLANE
/obj/machinery/atmospherics/proc/check_icon_cache(var/safety = 0)
if(!istype(GLOB.pipe_icon_manager))
if(!safety) //to prevent infinite loops
GLOB.pipe_icon_manager = new()
check_icon_cache(1)
return 0
return 1
/obj/machinery/atmospherics/proc/color_cache_name(var/obj/machinery/atmospherics/node)
//Don't use this for standard pipes
if(!istype(node))
return null
return node.pipe_color
/obj/machinery/atmospherics/proc/add_underlay(var/turf/T, var/obj/machinery/atmospherics/node, var/direction, var/icon_connect_type)
if(node)
if(T.intact && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
//underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay_down", direction, color_cache_name(node))
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "down" + icon_connect_type)
else
//underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay_intact", direction, color_cache_name(node))
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "intact" + icon_connect_type)
else
//underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay_exposed", direction, pipe_color)
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "exposed" + icon_connect_type)
/obj/machinery/atmospherics/proc/update_underlays()
if(check_icon_cache())
return 1
else
return 0
// Connect types
/obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/atmos1, obj/machinery/atmospherics/atmos2)
var/i
var/list1[] = atmos1.connect_types
var/list2[] = atmos2.connect_types
for(i=1,i<=list1.len,i++)
var/j
for(j=1,j<=list2.len,j++)
if(list1[i] == list2[j])
var/n = list1[i]
return n
return 0
/obj/machinery/atmospherics/proc/check_connect_types_construction(obj/machinery/atmospherics/atmos1, obj/item/pipe/pipe2)
var/i
var/list1[] = atmos1.connect_types
var/list2[] = pipe2.connect_types
for(i=1,i<=list1.len,i++)
var/j
for(j=1,j<=list2.len,j++)
if(list1[i] == list2[j])
var/n = list1[i]
return n
return 0
// Pipenet related functions
/obj/machinery/atmospherics/proc/returnPipenet()
return
/obj/machinery/atmospherics/proc/returnPipenetAir()
return
/obj/machinery/atmospherics/proc/setPipenet()
return
/obj/machinery/atmospherics/proc/replacePipenet()
return
/obj/machinery/atmospherics/proc/build_network(remove_deferral = FALSE)
// Called to build a network from this node
if(remove_deferral)
SSair.deferred_pipenet_rebuilds -= src
/obj/machinery/atmospherics/proc/defer_build_network()
SSair.deferred_pipenet_rebuilds += src
/obj/machinery/atmospherics/proc/disconnect(obj/machinery/atmospherics/reference)
return
/obj/machinery/atmospherics/proc/nullifyPipenet(datum/pipeline/P)
if(P)
P.other_atmosmch -= src
//(De)construction
/obj/machinery/atmospherics/attackby(obj/item/W, mob/user)
if(can_unwrench && istype(W, /obj/item/wrench))
var/turf/T = get_turf(src)
if(level == 1 && isturf(T) && T.intact)
to_chat(user, "<span class='danger'>You must remove the plating first.</span>")
return 1
var/datum/gas_mixture/int_air = return_air()
var/datum/gas_mixture/env_air = loc.return_air()
add_fingerprint(user)
var/unsafe_wrenching = FALSE
var/I = int_air ? int_air.return_pressure() : 0
var/E = env_air ? env_air.return_pressure() : 0
var/internal_pressure = I - E
playsound(src.loc, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if(internal_pressure > 2*ONE_ATMOSPHERE)
to_chat(user, "<span class='warning'>As you begin unwrenching \the [src] a gush of air blows in your face... maybe you should reconsider?</span>")
unsafe_wrenching = TRUE //Oh dear oh dear
if(do_after(user, 40 * W.toolspeed, target = src) && !QDELETED(src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"<span class='italics'>You hear ratchet.</span>")
investigate_log("was <span class='warning'>REMOVED</span> by [key_name(usr)]", "atmos")
//You unwrenched a pipe full of pressure? let's splat you into the wall silly.
if(unsafe_wrenching)
unsafe_pressure_release(user,internal_pressure)
deconstruct(TRUE)
else
return ..()
//Called when an atmospherics object is unwrenched while having a large pressure difference
//with it's locs air contents.
/obj/machinery/atmospherics/proc/unsafe_pressure_release(mob/user, pressures)
if(!user)
return
if(!pressures)
var/datum/gas_mixture/int_air = return_air()
var/datum/gas_mixture/env_air = loc.return_air()
pressures = int_air.return_pressure() - env_air.return_pressure()
var/fuck_you_dir = get_dir(src, user)
var/turf/general_direction = get_edge_target_turf(user, fuck_you_dir)
user.visible_message("<span class='danger'>[user] is sent flying by pressure!</span>","<span class='userdanger'>The pressure sends you flying!</span>")
//Values based on 2*ONE_ATMOS (the unsafe pressure), resulting in 20 range and 4 speed
user.throw_at(general_direction, pressures/10, pressures/50)
/obj/machinery/atmospherics/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
if(can_unwrench)
if(stored)
stored.forceMove(get_turf(src))
if(!disassembled)
stored.obj_integrity = stored.max_integrity * 0.5
transfer_fingerprints_to(stored)
stored = null
..()
/obj/machinery/atmospherics/on_construction(D, P, C)
if(C)
color = C
dir = D
initialize_directions = P
var/turf/T = loc
level = T.intact ? 2 : 1
add_fingerprint(usr)
if(!SSair.initialized) //If there's no atmos subsystem, we can't really initialize pipenets
SSair.machinery_to_construct.Add(src)
return
initialize_atmos_network()
/obj/machinery/atmospherics/proc/initialize_atmos_network()
atmos_init()
var/list/nodes = pipeline_expansion()
for(var/obj/machinery/atmospherics/A in nodes)
A.atmos_init()
A.addMember(src)
build_network()
// Find a connecting /obj/machinery/atmospherics in specified direction.
/obj/machinery/atmospherics/proc/findConnecting(var/direction)
for(var/obj/machinery/atmospherics/target in get_step(src,direction))
var/can_connect = check_connect_types(target, src)
if(can_connect && (target.initialize_directions & get_dir(target,src)))
return target
// Ventcrawling
#define VENT_SOUND_DELAY 30
/obj/machinery/atmospherics/relaymove(mob/living/user, direction)
direction &= initialize_directions
if(!direction || !(direction in cardinal)) //cant go this way.
return
if(user in buckled_mobs)// fixes buckle ventcrawl edgecase fuck bug
return
var/obj/machinery/atmospherics/target_move = findConnecting(direction)
if(target_move)
if(is_type_in_list(target_move, ventcrawl_machinery) && target_move.can_crawl_through())
user.remove_ventcrawl()
user.forceMove(target_move.loc) //handles entering and so on
user.visible_message("You hear something squeezing through the ducts.", "You climb out the ventilation system.")
else if(target_move.can_crawl_through())
if(returnPipenet() != target_move.returnPipenet())
user.update_pipe_vision(target_move)
user.loc = target_move
user.client.eye = target_move //if we don't do this, Byond only updates the eye every tick - required for smooth movement
if(world.time - user.last_played_vent > VENT_SOUND_DELAY)
user.last_played_vent = world.time
playsound(src, 'sound/machines/ventcrawl.ogg', 50, 1, -3)
else
if((direction & initialize_directions) || is_type_in_list(src, ventcrawl_machinery)) //if we move in a way the pipe can connect, but doesn't - or we're in a vent
user.remove_ventcrawl()
user.forceMove(src.loc)
user.visible_message("You hear something squeezing through the pipes.", "You climb out the ventilation system.")
user.canmove = 0
spawn(1)
user.canmove = 1
/obj/machinery/atmospherics/AltClick(var/mob/living/L)
if(is_type_in_list(src, ventcrawl_machinery))
L.handle_ventcrawl(src)
return
..()
/obj/machinery/atmospherics/proc/can_crawl_through()
return 1
/obj/machinery/atmospherics/proc/change_color(var/new_color)
//only pass valid pipe colors please ~otherwise your pipe will turn invisible
if(!pipe_color_check(new_color))
return
pipe_color = new_color
update_icon()
// Additional icon procs
/obj/machinery/atmospherics/proc/universal_underlays(var/obj/machinery/atmospherics/node, var/direction)
var/turf/T = get_turf(src)
if(!istype(T)) return
if(node)
var/node_dir = get_dir(src,node)
if(node.icon_connect_type == "-supply")
add_underlay_adapter(T, , node_dir, "")
add_underlay_adapter(T, node, node_dir, "-supply")
add_underlay_adapter(T, , node_dir, "-scrubbers")
else if(node.icon_connect_type == "-scrubbers")
add_underlay_adapter(T, , node_dir, "")
add_underlay_adapter(T, , node_dir, "-supply")
add_underlay_adapter(T, node, node_dir, "-scrubbers")
else
add_underlay_adapter(T, node, node_dir, "")
add_underlay_adapter(T, , node_dir, "-supply")
add_underlay_adapter(T, , node_dir, "-scrubbers")
else
add_underlay_adapter(T, , direction, "-supply")
add_underlay_adapter(T, , direction, "-scrubbers")
add_underlay_adapter(T, , direction, "")
/obj/machinery/atmospherics/proc/add_underlay_adapter(var/turf/T, var/obj/machinery/atmospherics/node, var/direction, var/icon_connect_type) //modified from add_underlay, does not make exposed underlays
if(node)
if(T.intact && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "down" + icon_connect_type)
else
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "intact" + icon_connect_type)
else
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "retracted" + icon_connect_type)
/obj/machinery/atmospherics/singularity_pull(S, current_size)
if(current_size >= STAGE_FIVE)
deconstruct(FALSE)
return ..()
/obj/machinery/atmospherics/update_remote_sight(mob/user)
user.sight |= (SEE_TURFS|BLIND)
. = ..()
/*
Quick overview:
Pipes combine to form pipelines
Pipelines and other atmospheric objects combine to form pipe_networks
Note: A single pipe_network represents a completely open space
Pipes -> Pipelines
Pipelines + Other Objects -> Pipe network
*/
GLOBAL_DATUM_INIT(pipe_icon_manager, /datum/pipe_icon_manager, new())
/obj/machinery/atmospherics
anchored = 1
layer = GAS_PIPE_HIDDEN_LAYER //under wires
resistance_flags = FIRE_PROOF
max_integrity = 200
plane = FLOOR_PLANE
idle_power_usage = 0
active_power_usage = 0
power_channel = ENVIRON
on_blueprints = TRUE
var/nodealert = 0
var/can_unwrench = 0
var/connect_types[] = list(1) //1=regular, 2=supply, 3=scrubber
var/connected_to = 1 //same as above, currently not used for anything
var/icon_connect_type = "" //"-supply" or "-scrubbers"
var/initialize_directions = 0
var/pipe_color
var/obj/item/pipe/stored
var/image/pipe_image
/obj/machinery/atmospherics/New()
if (!armor)
armor = list("melee" = 25, "bullet" = 10, "laser" = 10, "energy" = 100, "bomb" = 0, "bio" = 100, "rad" = 100, "fire" = 100, "acid" = 70)
..()
if(!pipe_color)
pipe_color = color
color = null
if(!pipe_color_check(pipe_color))
pipe_color = null
/obj/machinery/atmospherics/Initialize()
. = ..()
SSair.atmos_machinery += src
/obj/machinery/atmospherics/proc/atmos_init()
if(can_unwrench)
stored = new(src, make_from = src)
/obj/machinery/atmospherics/Destroy()
QDEL_NULL(stored)
SSair.atmos_machinery -= src
SSair.deferred_pipenet_rebuilds -= src
for(var/mob/living/L in src) //ventcrawling is serious business
L.remove_ventcrawl()
L.forceMove(get_turf(src))
QDEL_NULL(pipe_image) //we have to del it, or it might keep a ref somewhere else
return ..()
// Icons/overlays/underlays
/obj/machinery/atmospherics/update_icon()
var/turf/T = get_turf(loc)
if(!T || level == 2 || !T.intact)
plane = GAME_PLANE
else
plane = FLOOR_PLANE
/obj/machinery/atmospherics/proc/update_pipe_image()
pipe_image = image(src, loc, layer = ABOVE_HUD_LAYER, dir = dir) //the 20 puts it above Byond's darkness (not its opacity view)
pipe_image.plane = HUD_PLANE
/obj/machinery/atmospherics/proc/check_icon_cache(var/safety = 0)
if(!istype(GLOB.pipe_icon_manager))
if(!safety) //to prevent infinite loops
GLOB.pipe_icon_manager = new()
check_icon_cache(1)
return 0
return 1
/obj/machinery/atmospherics/proc/color_cache_name(var/obj/machinery/atmospherics/node)
//Don't use this for standard pipes
if(!istype(node))
return null
return node.pipe_color
/obj/machinery/atmospherics/proc/add_underlay(var/turf/T, var/obj/machinery/atmospherics/node, var/direction, var/icon_connect_type)
if(node)
if(T.intact && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
//underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay_down", direction, color_cache_name(node))
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "down" + icon_connect_type)
else
//underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay_intact", direction, color_cache_name(node))
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "intact" + icon_connect_type)
else
//underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay_exposed", direction, pipe_color)
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "exposed" + icon_connect_type)
/obj/machinery/atmospherics/proc/update_underlays()
if(check_icon_cache())
return 1
else
return 0
// Connect types
/obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/atmos1, obj/machinery/atmospherics/atmos2)
var/i
var/list1[] = atmos1.connect_types
var/list2[] = atmos2.connect_types
for(i=1,i<=list1.len,i++)
var/j
for(j=1,j<=list2.len,j++)
if(list1[i] == list2[j])
var/n = list1[i]
return n
return 0
/obj/machinery/atmospherics/proc/check_connect_types_construction(obj/machinery/atmospherics/atmos1, obj/item/pipe/pipe2)
var/i
var/list1[] = atmos1.connect_types
var/list2[] = pipe2.connect_types
for(i=1,i<=list1.len,i++)
var/j
for(j=1,j<=list2.len,j++)
if(list1[i] == list2[j])
var/n = list1[i]
return n
return 0
// Pipenet related functions
/obj/machinery/atmospherics/proc/returnPipenet()
return
/obj/machinery/atmospherics/proc/returnPipenetAir()
return
/obj/machinery/atmospherics/proc/setPipenet()
return
/obj/machinery/atmospherics/proc/replacePipenet()
return
/obj/machinery/atmospherics/proc/build_network(remove_deferral = FALSE)
// Called to build a network from this node
if(remove_deferral)
SSair.deferred_pipenet_rebuilds -= src
/obj/machinery/atmospherics/proc/defer_build_network()
SSair.deferred_pipenet_rebuilds += src
/obj/machinery/atmospherics/proc/disconnect(obj/machinery/atmospherics/reference)
return
/obj/machinery/atmospherics/proc/nullifyPipenet(datum/pipeline/P)
if(P)
P.other_atmosmch -= src
//(De)construction
/obj/machinery/atmospherics/attackby(obj/item/W, mob/user)
if(can_unwrench && istype(W, /obj/item/wrench))
var/turf/T = get_turf(src)
if(level == 1 && isturf(T) && T.intact)
to_chat(user, "<span class='danger'>You must remove the plating first.</span>")
return 1
var/datum/gas_mixture/int_air = return_air()
var/datum/gas_mixture/env_air = loc.return_air()
add_fingerprint(user)
var/unsafe_wrenching = FALSE
var/I = int_air ? int_air.return_pressure() : 0
var/E = env_air ? env_air.return_pressure() : 0
var/internal_pressure = I - E
playsound(src.loc, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if(internal_pressure > 2*ONE_ATMOSPHERE)
to_chat(user, "<span class='warning'>As you begin unwrenching \the [src] a gush of air blows in your face... maybe you should reconsider?</span>")
unsafe_wrenching = TRUE //Oh dear oh dear
if(do_after(user, 40 * W.toolspeed, target = src) && !QDELETED(src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"<span class='italics'>You hear ratchet.</span>")
investigate_log("was <span class='warning'>REMOVED</span> by [key_name(usr)]", "atmos")
//You unwrenched a pipe full of pressure? let's splat you into the wall silly.
if(unsafe_wrenching)
unsafe_pressure_release(user,internal_pressure)
deconstruct(TRUE)
else
return ..()
//Called when an atmospherics object is unwrenched while having a large pressure difference
//with it's locs air contents.
/obj/machinery/atmospherics/proc/unsafe_pressure_release(mob/user, pressures)
if(!user)
return
if(!pressures)
var/datum/gas_mixture/int_air = return_air()
var/datum/gas_mixture/env_air = loc.return_air()
pressures = int_air.return_pressure() - env_air.return_pressure()
var/fuck_you_dir = get_dir(src, user)
var/turf/general_direction = get_edge_target_turf(user, fuck_you_dir)
user.visible_message("<span class='danger'>[user] is sent flying by pressure!</span>","<span class='userdanger'>The pressure sends you flying!</span>")
//Values based on 2*ONE_ATMOS (the unsafe pressure), resulting in 20 range and 4 speed
user.throw_at(general_direction, pressures/10, pressures/50)
/obj/machinery/atmospherics/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
if(can_unwrench)
if(stored)
stored.forceMove(get_turf(src))
if(!disassembled)
stored.obj_integrity = stored.max_integrity * 0.5
transfer_fingerprints_to(stored)
stored = null
..()
/obj/machinery/atmospherics/on_construction(D, P, C)
if(C)
color = C
dir = D
initialize_directions = P
var/turf/T = loc
level = T.intact ? 2 : 1
add_fingerprint(usr)
if(!SSair.initialized) //If there's no atmos subsystem, we can't really initialize pipenets
SSair.machinery_to_construct.Add(src)
return
initialize_atmos_network()
/obj/machinery/atmospherics/proc/initialize_atmos_network()
atmos_init()
var/list/nodes = pipeline_expansion()
for(var/obj/machinery/atmospherics/A in nodes)
A.atmos_init()
A.addMember(src)
build_network()
// Find a connecting /obj/machinery/atmospherics in specified direction.
/obj/machinery/atmospherics/proc/findConnecting(var/direction)
for(var/obj/machinery/atmospherics/target in get_step(src,direction))
var/can_connect = check_connect_types(target, src)
if(can_connect && (target.initialize_directions & get_dir(target,src)))
return target
// Ventcrawling
#define VENT_SOUND_DELAY 30
/obj/machinery/atmospherics/relaymove(mob/living/user, direction)
direction &= initialize_directions
if(!direction || !(direction in cardinal)) //cant go this way.
return
if(user in buckled_mobs)// fixes buckle ventcrawl edgecase fuck bug
return
var/obj/machinery/atmospherics/target_move = findConnecting(direction)
if(target_move)
if(is_type_in_list(target_move, ventcrawl_machinery) && target_move.can_crawl_through())
user.remove_ventcrawl()
user.forceMove(target_move.loc) //handles entering and so on
user.visible_message("You hear something squeezing through the ducts.", "You climb out the ventilation system.")
else if(target_move.can_crawl_through())
if(returnPipenet() != target_move.returnPipenet())
user.update_pipe_vision(target_move)
user.loc = target_move
user.client.eye = target_move //if we don't do this, Byond only updates the eye every tick - required for smooth movement
if(world.time - user.last_played_vent > VENT_SOUND_DELAY)
user.last_played_vent = world.time
playsound(src, 'sound/machines/ventcrawl.ogg', 50, 1, -3)
else
if((direction & initialize_directions) || is_type_in_list(src, ventcrawl_machinery)) //if we move in a way the pipe can connect, but doesn't - or we're in a vent
user.remove_ventcrawl()
user.forceMove(src.loc)
user.visible_message("You hear something squeezing through the pipes.", "You climb out the ventilation system.")
user.canmove = 0
spawn(1)
user.canmove = 1
/obj/machinery/atmospherics/AltClick(var/mob/living/L)
if(is_type_in_list(src, ventcrawl_machinery))
L.handle_ventcrawl(src)
return
..()
/obj/machinery/atmospherics/proc/can_crawl_through()
return 1
/obj/machinery/atmospherics/proc/change_color(var/new_color)
//only pass valid pipe colors please ~otherwise your pipe will turn invisible
if(!pipe_color_check(new_color))
return
pipe_color = new_color
update_icon()
// Additional icon procs
/obj/machinery/atmospherics/proc/universal_underlays(var/obj/machinery/atmospherics/node, var/direction)
var/turf/T = get_turf(src)
if(!istype(T)) return
if(node)
var/node_dir = get_dir(src,node)
if(node.icon_connect_type == "-supply")
add_underlay_adapter(T, , node_dir, "")
add_underlay_adapter(T, node, node_dir, "-supply")
add_underlay_adapter(T, , node_dir, "-scrubbers")
else if(node.icon_connect_type == "-scrubbers")
add_underlay_adapter(T, , node_dir, "")
add_underlay_adapter(T, , node_dir, "-supply")
add_underlay_adapter(T, node, node_dir, "-scrubbers")
else
add_underlay_adapter(T, node, node_dir, "")
add_underlay_adapter(T, , node_dir, "-supply")
add_underlay_adapter(T, , node_dir, "-scrubbers")
else
add_underlay_adapter(T, , direction, "-supply")
add_underlay_adapter(T, , direction, "-scrubbers")
add_underlay_adapter(T, , direction, "")
/obj/machinery/atmospherics/proc/add_underlay_adapter(var/turf/T, var/obj/machinery/atmospherics/node, var/direction, var/icon_connect_type) //modified from add_underlay, does not make exposed underlays
if(node)
if(T.intact && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "down" + icon_connect_type)
else
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "intact" + icon_connect_type)
else
underlays += GLOB.pipe_icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "retracted" + icon_connect_type)
/obj/machinery/atmospherics/singularity_pull(S, current_size)
if(current_size >= STAGE_FIVE)
deconstruct(FALSE)
return ..()
/obj/machinery/atmospherics/update_remote_sight(mob/user)
user.sight |= (SEE_TURFS|BLIND)
. = ..()
@@ -1,155 +1,155 @@
/obj/machinery/atmospherics/binary
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = IDLE_POWER_USE
layer = GAS_PUMP_LAYER
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/datum/pipeline/parent1
var/datum/pipeline/parent2
/obj/machinery/atmospherics/binary/New()
..()
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
air1 = new
air2 = new
air1.volume = 200
air2.volume = 200
/obj/machinery/atmospherics/binary/Destroy()
if(node1)
node1.disconnect(src)
node1 = null
nullifyPipenet(parent1)
if(node2)
node2.disconnect(src)
node2 = null
nullifyPipenet(parent2)
return ..()
/obj/machinery/atmospherics/binary/atmos_init()
..()
var/node2_connect = dir
var/node1_connect = turn(dir, 180)
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node2 = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/build_network(remove_deferral = FALSE)
if(!parent1)
parent1 = new /datum/pipeline()
parent1.build_pipeline(src)
if(!parent2)
parent2 = new /datum/pipeline()
parent2.build_pipeline(src)
..()
/obj/machinery/atmospherics/binary/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent1)
node1 = null
else if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent2)
node2 = null
update_icon()
/obj/machinery/atmospherics/binary/nullifyPipenet(datum/pipeline/P)
..()
if(!P)
return
if(P == parent1)
parent1.other_airs -= air1
parent1 = null
else if(P == parent2)
parent2.other_airs -= air2
parent2 = null
/obj/machinery/atmospherics/binary/returnPipenetAir(datum/pipeline/P)
if(P == parent1)
return air1
else if(P == parent2)
return air2
/obj/machinery/atmospherics/binary/pipeline_expansion(datum/pipeline/P)
if(P)
if(parent1 == P)
return list(node1)
else if(parent2 == P)
return list(node2)
else
return list(node1, node2)
/obj/machinery/atmospherics/binary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
if(A == node1)
parent1 = P
else if(A == node2)
parent2 = P
/obj/machinery/atmospherics/binary/returnPipenet(obj/machinery/atmospherics/A)
if(A == node1)
return parent1
else if(A == node2)
return parent2
/obj/machinery/atmospherics/binary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent1)
parent1 = New
else if(Old == parent2)
parent2 = New
/obj/machinery/atmospherics/binary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
var/turf/T = get_turf(src)
if(T)
//Remove the gas from air1+air2 and assume it
var/datum/gas_mixture/environment = T.return_air()
var/lost = pressures*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
lost += pressures*environment.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
var/shared_loss = lost/2
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
to_release.merge(air2.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/binary/process_atmos()
..()
return parent1 && parent2
/obj/machinery/atmospherics/binary
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = IDLE_POWER_USE
layer = GAS_PUMP_LAYER
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/datum/pipeline/parent1
var/datum/pipeline/parent2
/obj/machinery/atmospherics/binary/New()
..()
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
air1 = new
air2 = new
air1.volume = 200
air2.volume = 200
/obj/machinery/atmospherics/binary/Destroy()
if(node1)
node1.disconnect(src)
node1 = null
nullifyPipenet(parent1)
if(node2)
node2.disconnect(src)
node2 = null
nullifyPipenet(parent2)
return ..()
/obj/machinery/atmospherics/binary/atmos_init()
..()
var/node2_connect = dir
var/node1_connect = turn(dir, 180)
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
var/c = check_connect_types(target,src)
if(c)
target.connected_to = c
connected_to = c
node2 = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/binary/build_network(remove_deferral = FALSE)
if(!parent1)
parent1 = new /datum/pipeline()
parent1.build_pipeline(src)
if(!parent2)
parent2 = new /datum/pipeline()
parent2.build_pipeline(src)
..()
/obj/machinery/atmospherics/binary/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent1)
node1 = null
else if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent2)
node2 = null
update_icon()
/obj/machinery/atmospherics/binary/nullifyPipenet(datum/pipeline/P)
..()
if(!P)
return
if(P == parent1)
parent1.other_airs -= air1
parent1 = null
else if(P == parent2)
parent2.other_airs -= air2
parent2 = null
/obj/machinery/atmospherics/binary/returnPipenetAir(datum/pipeline/P)
if(P == parent1)
return air1
else if(P == parent2)
return air2
/obj/machinery/atmospherics/binary/pipeline_expansion(datum/pipeline/P)
if(P)
if(parent1 == P)
return list(node1)
else if(parent2 == P)
return list(node2)
else
return list(node1, node2)
/obj/machinery/atmospherics/binary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
if(A == node1)
parent1 = P
else if(A == node2)
parent2 = P
/obj/machinery/atmospherics/binary/returnPipenet(obj/machinery/atmospherics/A)
if(A == node1)
return parent1
else if(A == node2)
return parent2
/obj/machinery/atmospherics/binary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent1)
parent1 = New
else if(Old == parent2)
parent2 = New
/obj/machinery/atmospherics/binary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
var/turf/T = get_turf(src)
if(T)
//Remove the gas from air1+air2 and assume it
var/datum/gas_mixture/environment = T.return_air()
var/lost = pressures*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
lost += pressures*environment.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
var/shared_loss = lost/2
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
to_release.merge(air2.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/binary/process_atmos()
..()
return parent1 && parent2
@@ -1,125 +1,125 @@
//node1, air1, network1 correspond to input
//node2, air2, network2 correspond to output
#define CIRC_LEFT WEST
#define CIRC_RIGHT EAST
/obj/machinery/atmospherics/binary/circulator
name = "circulator/heat exchanger"
desc = "A gas circulator pump and heat exchanger. Its input port is on the south side, and its output port is on the north side."
icon = 'icons/obj/atmospherics/circulator.dmi'
icon_state = "circ1-off"
var/side = CIRC_LEFT
var/last_pressure_delta = 0
var/obj/machinery/power/generator/generator
anchored = 1
density = 1
can_unwrench = 1
var/side_inverted = 0
// Creating a custom circulator pipe subtype to be delivered through cargo
/obj/item/pipe/circulator
name = "circulator/heat exchanger fitting"
/obj/item/pipe/circulator/New(loc)
var/obj/machinery/atmospherics/binary/circulator/C = new /obj/machinery/atmospherics/binary/circulator(null)
..(loc, make_from = C)
/obj/machinery/atmospherics/binary/circulator/Destroy()
if(generator && generator.cold_circ == src)
generator.cold_circ = null
else if(generator && generator.hot_circ == src)
generator.hot_circ = null
return ..()
/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
var/datum/gas_mixture/inlet = get_inlet_air()
var/datum/gas_mixture/outlet = get_outlet_air()
var/output_starting_pressure = outlet.return_pressure()
var/input_starting_pressure = inlet.return_pressure()
if(output_starting_pressure >= input_starting_pressure - 10)
//Need at least 10 KPa difference to overcome friction in the mechanism
last_pressure_delta = 0
return null
//Calculate necessary moles to transfer using PV = nRT
if(inlet.temperature > 0)
var/pressure_delta = (input_starting_pressure - output_starting_pressure) / 2
var/transfer_moles = pressure_delta * outlet.volume/(inlet.temperature * R_IDEAL_GAS_EQUATION)
last_pressure_delta = pressure_delta
//log_debug("pressure_delta = [pressure_delta]; transfer_moles = [transfer_moles];")
//Actually transfer the gas
var/datum/gas_mixture/removed = inlet.remove(transfer_moles)
parent1.update = 1
parent2.update = 1
return removed
else
last_pressure_delta = 0
/obj/machinery/atmospherics/binary/circulator/process_atmos()
..()
update_icon()
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_air()
if(side_inverted==0)
return air2
else
return air1
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_air()
if(side_inverted==0)
return air1
else
return air2
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "South"
else
return "North"
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "North"
else
return "South"
/obj/machinery/atmospherics/binary/circulator/multitool_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(!side_inverted)
side_inverted = TRUE
else
side_inverted = FALSE
to_chat(user, "<span class='notice'>You reverse the circulator's valve settings. The inlet of the circulator is now on the [get_inlet_side(dir)] side.</span>")
desc = "A gas circulator pump and heat exchanger. Its input port is on the [get_inlet_side(dir)] side, and its output port is on the [get_outlet_side(dir)] side."
/obj/machinery/atmospherics/binary/circulator/update_icon()
..()
if(stat & (BROKEN|NOPOWER))
icon_state = "circ[side]-p"
else if(last_pressure_delta > 0)
if(last_pressure_delta > ONE_ATMOSPHERE)
icon_state = "circ[side]-run"
else
icon_state = "circ[side]-slow"
else
icon_state = "circ[side]-off"
return 1
//node1, air1, network1 correspond to input
//node2, air2, network2 correspond to output
#define CIRC_LEFT WEST
#define CIRC_RIGHT EAST
/obj/machinery/atmospherics/binary/circulator
name = "circulator/heat exchanger"
desc = "A gas circulator pump and heat exchanger. Its input port is on the south side, and its output port is on the north side."
icon = 'icons/obj/atmospherics/circulator.dmi'
icon_state = "circ1-off"
var/side = CIRC_LEFT
var/last_pressure_delta = 0
var/obj/machinery/power/generator/generator
anchored = 1
density = 1
can_unwrench = 1
var/side_inverted = 0
// Creating a custom circulator pipe subtype to be delivered through cargo
/obj/item/pipe/circulator
name = "circulator/heat exchanger fitting"
/obj/item/pipe/circulator/New(loc)
var/obj/machinery/atmospherics/binary/circulator/C = new /obj/machinery/atmospherics/binary/circulator(null)
..(loc, make_from = C)
/obj/machinery/atmospherics/binary/circulator/Destroy()
if(generator && generator.cold_circ == src)
generator.cold_circ = null
else if(generator && generator.hot_circ == src)
generator.hot_circ = null
return ..()
/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
var/datum/gas_mixture/inlet = get_inlet_air()
var/datum/gas_mixture/outlet = get_outlet_air()
var/output_starting_pressure = outlet.return_pressure()
var/input_starting_pressure = inlet.return_pressure()
if(output_starting_pressure >= input_starting_pressure - 10)
//Need at least 10 KPa difference to overcome friction in the mechanism
last_pressure_delta = 0
return null
//Calculate necessary moles to transfer using PV = nRT
if(inlet.temperature > 0)
var/pressure_delta = (input_starting_pressure - output_starting_pressure) / 2
var/transfer_moles = pressure_delta * outlet.volume/(inlet.temperature * R_IDEAL_GAS_EQUATION)
last_pressure_delta = pressure_delta
//log_debug("pressure_delta = [pressure_delta]; transfer_moles = [transfer_moles];")
//Actually transfer the gas
var/datum/gas_mixture/removed = inlet.remove(transfer_moles)
parent1.update = 1
parent2.update = 1
return removed
else
last_pressure_delta = 0
/obj/machinery/atmospherics/binary/circulator/process_atmos()
..()
update_icon()
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_air()
if(side_inverted==0)
return air2
else
return air1
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_air()
if(side_inverted==0)
return air1
else
return air2
/obj/machinery/atmospherics/binary/circulator/proc/get_inlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "South"
else
return "North"
/obj/machinery/atmospherics/binary/circulator/proc/get_outlet_side()
if(dir==SOUTH||dir==NORTH)
if(side_inverted==0)
return "North"
else
return "South"
/obj/machinery/atmospherics/binary/circulator/multitool_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(!side_inverted)
side_inverted = TRUE
else
side_inverted = FALSE
to_chat(user, "<span class='notice'>You reverse the circulator's valve settings. The inlet of the circulator is now on the [get_inlet_side(dir)] side.</span>")
desc = "A gas circulator pump and heat exchanger. Its input port is on the [get_inlet_side(dir)] side, and its output port is on the [get_outlet_side(dir)] side."
/obj/machinery/atmospherics/binary/circulator/update_icon()
..()
if(stat & (BROKEN|NOPOWER))
icon_state = "circ[side]-p"
else if(last_pressure_delta > 0)
if(last_pressure_delta > ONE_ATMOSPHERE)
icon_state = "circ[side]-run"
else
icon_state = "circ[side]-slow"
else
icon_state = "circ[side]-off"
return 1
@@ -1,269 +1,269 @@
/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
req_one_access_txt = "24;10"
name = "dual-port air vent"
desc = "Has a valve and pump attached to it. There are two ports."
can_unwrench = 1
level = 1
connect_types = list(1,2,3) //connects to regular, supply and scrubbers pipes
var/on = 0
var/pump_direction = 1 //0 = siphoning, 1 = releasing
var/external_pressure_bound = ONE_ATMOSPHERE
var/input_pressure_min = 0
var/output_pressure_max = 0
var/frequency = ATMOS_VENTSCRUB
var/id_tag = null
var/datum/radio_frequency/radio_connection
var/advcontrol = 0//does this device listen to the AAC
settagwhitelist = list("id_tag")
var/pressure_checks = 1
//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()
..()
if(!id_tag)
assign_uid()
id_tag = num2text(uid)
icon = null
/obj/machinery/atmospherics/binary/dp_vent_pump/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/dp_vent_pump/atmos_init()
..()
if(frequency)
set_frequency(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/on
on = TRUE
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume/New()
..()
air1.volume = 1000
air2.volume = 1000
/obj/machinery/atmospherics/binary/volume_pump/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/dp_vent_pump/update_icon(var/safety = 0)
..()
if(!check_icon_cache())
return
overlays.Cut()
var/vent_icon = "vent"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(T.intact && 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 += "[on ? "[pump_direction ? "out" : "in"]" : "off"]"
overlays += GLOB.pipe_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.intact && 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/process_atmos()
..()
if(!on)
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/environment_pressure = environment.return_pressure()
if(pump_direction) //input -> external
var/pressure_delta = 10000
if(pressure_checks&1)
pressure_delta = min(pressure_delta, (external_pressure_bound - environment_pressure))
if(pressure_checks&2)
pressure_delta = min(pressure_delta, (air1.return_pressure() - input_pressure_min))
if(pressure_delta > 0)
if(air1.temperature > 0)
var/transfer_moles = pressure_delta*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
loc.assume_air(removed)
parent1.update = 1
air_update_turf()
else //external -> output
var/pressure_delta = 10000
if(pressure_checks&1)
pressure_delta = min(pressure_delta, (environment_pressure - external_pressure_bound))
if(pressure_checks&4)
pressure_delta = min(pressure_delta, (output_pressure_max - air2.return_pressure()))
if(pressure_delta > 0)
if(environment.temperature > 0)
var/transfer_moles = pressure_delta*air2.volume/(environment.temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
air2.merge(removed)
parent2.update = 1
air_update_turf()
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id_tag,
"device" = "ADVP",
"power" = on,
"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, filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/dp_vent_pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command") || (signal.data["advcontrol"] && !advcontrol))
return 0
if(signal.data["power"] != null)
on = text2num(signal.data["power"])
if(signal.data["power_toggle"] != null)
on = !on
if(signal.data["direction"] != null)
pump_direction = text2num(signal.data["direction"])
if(signal.data["checks"] != null)
pressure_checks = text2num(signal.data["checks"])
if(signal.data["purge"])
pressure_checks &= ~1
pump_direction = 0
if(signal.data["stabilize"])//the fact that this was "stabalize" shows how many fucks people give about these wonders, none
pressure_checks |= 1
pump_direction = 1
if(signal.data["set_input_pressure"] != null)
input_pressure_min = between(
0,
text2num(signal.data["set_input_pressure"]),
ONE_ATMOSPHERE*50
)
if(signal.data["set_output_pressure"] != null)
output_pressure_max = between(
0,
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(signal.data["set_external_pressure"] != null)
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()
/obj/machinery/atmospherics/binary/dp_vent_pump/attackby(var/obj/item/W as obj, var/mob/user as mob)
if(istype(W, /obj/item/multitool))
update_multitool_menu(user)
return 1
return ..()
/obj/machinery/atmospherics/binary/dp_vent_pump/multitool_menu(var/mob/user,var/obj/item/multitool/P)
return {"
<ul>
<li><b>Frequency:</b> <a href="?src=[UID()];set_freq=-1">[format_frequency(frequency)] GHz</a> (<a href="?src=[UID()];set_freq=[ATMOS_VENTSCRUB]">Reset</a>)</li>
<li><b>ID Tag:</b> <a href="?src=[UID()];set_id=1">[id_tag]</a></li>
<li><b>AAC Acces:</b> <a href="?src=[UID()];toggleadvcontrol=1">[advcontrol ? "Allowed" : "Blocked"]</a></li>
</ul>
"}
/obj/machinery/atmospherics/binary/dp_vent_pump/multitool_topic(var/mob/user, var/list/href_list, var/obj/O)
. = ..()
if(.)
return .
if("toggleadvcontrol" in href_list)
advcontrol = !advcontrol
return TRUE
/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
req_one_access_txt = "24;10"
name = "dual-port air vent"
desc = "Has a valve and pump attached to it. There are two ports."
can_unwrench = 1
level = 1
connect_types = list(1,2,3) //connects to regular, supply and scrubbers pipes
var/on = 0
var/pump_direction = 1 //0 = siphoning, 1 = releasing
var/external_pressure_bound = ONE_ATMOSPHERE
var/input_pressure_min = 0
var/output_pressure_max = 0
var/frequency = ATMOS_VENTSCRUB
var/id_tag = null
var/datum/radio_frequency/radio_connection
var/advcontrol = 0//does this device listen to the AAC
settagwhitelist = list("id_tag")
var/pressure_checks = 1
//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()
..()
if(!id_tag)
assign_uid()
id_tag = num2text(uid)
icon = null
/obj/machinery/atmospherics/binary/dp_vent_pump/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/dp_vent_pump/atmos_init()
..()
if(frequency)
set_frequency(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/on
on = TRUE
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume/New()
..()
air1.volume = 1000
air2.volume = 1000
/obj/machinery/atmospherics/binary/volume_pump/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/dp_vent_pump/update_icon(var/safety = 0)
..()
if(!check_icon_cache())
return
overlays.Cut()
var/vent_icon = "vent"
var/turf/T = get_turf(src)
if(!istype(T))
return
if(T.intact && 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 += "[on ? "[pump_direction ? "out" : "in"]" : "off"]"
overlays += GLOB.pipe_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.intact && 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/process_atmos()
..()
if(!on)
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/environment_pressure = environment.return_pressure()
if(pump_direction) //input -> external
var/pressure_delta = 10000
if(pressure_checks&1)
pressure_delta = min(pressure_delta, (external_pressure_bound - environment_pressure))
if(pressure_checks&2)
pressure_delta = min(pressure_delta, (air1.return_pressure() - input_pressure_min))
if(pressure_delta > 0)
if(air1.temperature > 0)
var/transfer_moles = pressure_delta*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
loc.assume_air(removed)
parent1.update = 1
air_update_turf()
else //external -> output
var/pressure_delta = 10000
if(pressure_checks&1)
pressure_delta = min(pressure_delta, (environment_pressure - external_pressure_bound))
if(pressure_checks&4)
pressure_delta = min(pressure_delta, (output_pressure_max - air2.return_pressure()))
if(pressure_delta > 0)
if(environment.temperature > 0)
var/transfer_moles = pressure_delta*air2.volume/(environment.temperature * R_IDEAL_GAS_EQUATION)
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
air2.merge(removed)
parent2.update = 1
air_update_turf()
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/dp_vent_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id_tag,
"device" = "ADVP",
"power" = on,
"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, filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/dp_vent_pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id_tag) || (signal.data["sigtype"]!="command") || (signal.data["advcontrol"] && !advcontrol))
return 0
if(signal.data["power"] != null)
on = text2num(signal.data["power"])
if(signal.data["power_toggle"] != null)
on = !on
if(signal.data["direction"] != null)
pump_direction = text2num(signal.data["direction"])
if(signal.data["checks"] != null)
pressure_checks = text2num(signal.data["checks"])
if(signal.data["purge"])
pressure_checks &= ~1
pump_direction = 0
if(signal.data["stabilize"])//the fact that this was "stabalize" shows how many fucks people give about these wonders, none
pressure_checks |= 1
pump_direction = 1
if(signal.data["set_input_pressure"] != null)
input_pressure_min = between(
0,
text2num(signal.data["set_input_pressure"]),
ONE_ATMOSPHERE*50
)
if(signal.data["set_output_pressure"] != null)
output_pressure_max = between(
0,
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(signal.data["set_external_pressure"] != null)
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()
/obj/machinery/atmospherics/binary/dp_vent_pump/attackby(var/obj/item/W as obj, var/mob/user as mob)
if(istype(W, /obj/item/multitool))
update_multitool_menu(user)
return 1
return ..()
/obj/machinery/atmospherics/binary/dp_vent_pump/multitool_menu(var/mob/user,var/obj/item/multitool/P)
return {"
<ul>
<li><b>Frequency:</b> <a href="?src=[UID()];set_freq=-1">[format_frequency(frequency)] GHz</a> (<a href="?src=[UID()];set_freq=[ATMOS_VENTSCRUB]">Reset</a>)</li>
<li><b>ID Tag:</b> <a href="?src=[UID()];set_id=1">[id_tag]</a></li>
<li><b>AAC Acces:</b> <a href="?src=[UID()];toggleadvcontrol=1">[advcontrol ? "Allowed" : "Blocked"]</a></li>
</ul>
"}
/obj/machinery/atmospherics/binary/dp_vent_pump/multitool_topic(var/mob/user, var/list/href_list, var/obj/O)
. = ..()
if(.)
return .
if("toggleadvcontrol" in href_list)
advcontrol = !advcontrol
return TRUE
@@ -1,192 +1,192 @@
/obj/machinery/atmospherics/binary/passive_gate
//Tries to achieve target pressure at output (like a normal pump) except
// Uses no power but can not transfer gases from a low pressure area to a high pressure area
icon = 'icons/atmos/passive_gate.dmi'
icon_state = "map"
name = "passive gate"
desc = "A one-way air valve that does not require power"
can_unwrench = 1
var/on = 0
var/target_pressure = ONE_ATMOSPHERE
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/passive_gate/atmos_init()
..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/passive_gate/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/passive_gate/update_icon()
..()
icon_state = "[on ? "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/process_atmos()
..()
if(!on)
return 0
var/output_starting_pressure = air2.return_pressure()
var/input_starting_pressure = air1.return_pressure()
if(output_starting_pressure >= min(target_pressure,input_starting_pressure-10))
//No need to pump gas if target is already reached or input pressure is too low
//Need at least 10 KPa difference to overcome friction in the mechanism
return 1
//Calculate necessary moles to transfer using PV = nRT
if((air1.total_moles() > 0) && (air1.temperature>0))
var/pressure_delta = min(target_pressure - output_starting_pressure, (input_starting_pressure - output_starting_pressure)/2)
//Can not have a pressure delta that would cause output_pressure > input_pressure
var/transfer_moles = pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
//Actually transfer the gas
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
air2.merge(removed)
parent1.update = 1
parent2.update = 1
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/passive_gate/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/passive_gate/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = on,
"target_output" = target_pressure,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA)
return 1
/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
var/old_on = on //for logging
if("power" in signal.data)
on = text2num(signal.data["power"])
if("power_toggle" in signal.data)
on = !on
if("set_output_pressure" in signal.data)
target_pressure = between(
0,
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
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(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/binary/passive_gate/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/binary/passive_gate/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 385, 115, state = state)
ui.open()
/obj/machinery/atmospherics/binary/passive_gate/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
return data
/obj/machinery/atmospherics/binary/passive_gate/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure))
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/binary/passive_gate/attackby(obj/item/W, mob/user, params)
if(!istype(W, /obj/item/wrench))
return ..()
if(on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
return 1
return ..()
/obj/machinery/atmospherics/binary/passive_gate
//Tries to achieve target pressure at output (like a normal pump) except
// Uses no power but can not transfer gases from a low pressure area to a high pressure area
icon = 'icons/atmos/passive_gate.dmi'
icon_state = "map"
name = "passive gate"
desc = "A one-way air valve that does not require power"
can_unwrench = 1
var/on = 0
var/target_pressure = ONE_ATMOSPHERE
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/passive_gate/atmos_init()
..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/passive_gate/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/passive_gate/update_icon()
..()
icon_state = "[on ? "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/process_atmos()
..()
if(!on)
return 0
var/output_starting_pressure = air2.return_pressure()
var/input_starting_pressure = air1.return_pressure()
if(output_starting_pressure >= min(target_pressure,input_starting_pressure-10))
//No need to pump gas if target is already reached or input pressure is too low
//Need at least 10 KPa difference to overcome friction in the mechanism
return 1
//Calculate necessary moles to transfer using PV = nRT
if((air1.total_moles() > 0) && (air1.temperature>0))
var/pressure_delta = min(target_pressure - output_starting_pressure, (input_starting_pressure - output_starting_pressure)/2)
//Can not have a pressure delta that would cause output_pressure > input_pressure
var/transfer_moles = pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
//Actually transfer the gas
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
air2.merge(removed)
parent1.update = 1
parent2.update = 1
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/passive_gate/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/passive_gate/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = on,
"target_output" = target_pressure,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA)
return 1
/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
var/old_on = on //for logging
if("power" in signal.data)
on = text2num(signal.data["power"])
if("power_toggle" in signal.data)
on = !on
if("set_output_pressure" in signal.data)
target_pressure = between(
0,
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
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(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/binary/passive_gate/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/binary/passive_gate/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 385, 115, state = state)
ui.open()
/obj/machinery/atmospherics/binary/passive_gate/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
return data
/obj/machinery/atmospherics/binary/passive_gate/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure))
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/binary/passive_gate/attackby(obj/item/W, mob/user, params)
if(!istype(W, /obj/item/wrench))
return ..()
if(on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
return 1
return ..()
@@ -1,261 +1,261 @@
/*
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"
name = "gas pump"
desc = "A pump"
can_unwrench = 1
var/on = 0
var/target_pressure = ONE_ATMOSPHERE
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/pump/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/binary/pump/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/binary/pump/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/binary/pump/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/binary/pump/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/binary/pump/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/binary/pump/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/pump/on
icon_state = "map_on"
on = 1
/obj/machinery/atmospherics/binary/pump/update_icon()
..()
if(!powered())
icon_state = "off"
else
icon_state = "[on ? "on" : "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))
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/pump/process_atmos()
..()
if((stat & (NOPOWER|BROKEN)) || !on)
return 0
var/output_starting_pressure = air2.return_pressure()
if( (target_pressure - output_starting_pressure) < 0.01)
//No need to pump gas if target is already reached!
return 1
//Calculate necessary moles to transfer using PV=nRT
if((air1.total_moles() > 0) && (air1.temperature>0))
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles = pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
//Actually transfer the gas
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
air2.merge(removed)
parent1.update = 1
parent2.update = 1
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/pump/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = on,
"target_output" = target_pressure,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/pump/atmos_init()
..()
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
var/old_on = on //for logging
if(signal.data["power"])
on = text2num(signal.data["power"])
if(signal.data["power_toggle"])
on = !on
if(signal.data["set_output_pressure"])
target_pressure = between(
0,
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
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_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/binary/pump/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/binary/pump/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 385, 115, state = state)
ui.open()
/obj/machinery/atmospherics/binary/pump/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
return data
/obj/machinery/atmospherics/binary/pump/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure))
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/binary/pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/pump/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the pump.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else if(!istype(W, /obj/item/wrench))
return ..()
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
return 1
return ..()
/*
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"
name = "gas pump"
desc = "A pump"
can_unwrench = 1
var/on = 0
var/target_pressure = ONE_ATMOSPHERE
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/pump/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/binary/pump/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/binary/pump/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/binary/pump/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/binary/pump/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/binary/pump/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/binary/pump/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/pump/on
icon_state = "map_on"
on = 1
/obj/machinery/atmospherics/binary/pump/update_icon()
..()
if(!powered())
icon_state = "off"
else
icon_state = "[on ? "on" : "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))
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/pump/process_atmos()
..()
if((stat & (NOPOWER|BROKEN)) || !on)
return 0
var/output_starting_pressure = air2.return_pressure()
if( (target_pressure - output_starting_pressure) < 0.01)
//No need to pump gas if target is already reached!
return 1
//Calculate necessary moles to transfer using PV=nRT
if((air1.total_moles() > 0) && (air1.temperature>0))
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles = pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
//Actually transfer the gas
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
air2.merge(removed)
parent1.update = 1
parent2.update = 1
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/pump/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, filter = RADIO_ATMOSIA)
/obj/machinery/atmospherics/binary/pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "AGP",
"power" = on,
"target_output" = target_pressure,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA)
return 1
/obj/machinery/atmospherics/binary/pump/atmos_init()
..()
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
var/old_on = on //for logging
if(signal.data["power"])
on = text2num(signal.data["power"])
if(signal.data["power_toggle"])
on = !on
if(signal.data["set_output_pressure"])
target_pressure = between(
0,
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
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_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/binary/pump/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/binary/pump/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 385, 115, state = state)
ui.open()
/obj/machinery/atmospherics/binary/pump/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
return data
/obj/machinery/atmospherics/binary/pump/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure))
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/binary/pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/pump/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the pump.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else if(!istype(W, /obj/item/wrench))
return ..()
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
return 1
return ..()
@@ -1,257 +1,257 @@
/*
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/volume_pump
icon = 'icons/atmos/volume_pump.dmi'
icon_state = "map_off"
name = "volumetric gas pump"
desc = "A volumetric pump"
can_unwrench = 1
var/on = 0
var/transfer_rate = 200
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/volume_pump/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/binary/volume_pump/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/proc/set_max()
if(powered())
transfer_rate = MAX_TRANSFER_RATE
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/volume_pump/on
on = 1
icon_state = "map_on"
/obj/machinery/atmospherics/binary/volume_pump/atmos_init()
..()
set_frequency(frequency)
/obj/machinery/atmospherics/binary/volume_pump/update_icon()
..()
if(!powered())
icon_state = "off"
else
icon_state = "[on ? "on" : "off"]"
/obj/machinery/atmospherics/binary/volume_pump/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/volume_pump/process_atmos()
..()
if((stat & (NOPOWER|BROKEN)) || !on)
return 0
// Pump mechanism just won't do anything if the pressure is too high/too low
var/input_starting_pressure = air1.return_pressure()
var/output_starting_pressure = air2.return_pressure()
if((input_starting_pressure < 0.01) || (output_starting_pressure > 9000))
return 1
var/transfer_ratio = max(1, transfer_rate/air1.volume)
var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio)
air2.merge(removed)
parent1.update = 1
parent2.update = 1
return 1
/obj/machinery/atmospherics/binary/volume_pump/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency)
/obj/machinery/atmospherics/binary/volume_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "APV",
"power" = on,
"transfer_rate" = transfer_rate,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal)
return 1
/obj/machinery/atmospherics/binary/volume_pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
var/old_on = on //for logging
if(signal.data["power"])
on = text2num(signal.data["power"])
if(signal.data["power_toggle"])
on = !on
if(signal.data["set_transfer_rate"])
transfer_rate = between(
0,
text2num(signal.data["set_transfer_rate"]),
air1.volume
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/attack_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/binary/volume_pump/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/binary/volume_pump/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 310, 115, state = state)
ui.open()
/obj/machinery/atmospherics/binary/volume_pump/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["rate"] = round(transfer_rate)
data["max_rate"] = round(MAX_TRANSFER_RATE)
return data
/obj/machinery/atmospherics/binary/volume_pump/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["rate"])
var/rate = href_list["rate"]
if(rate == "max")
rate = MAX_TRANSFER_RATE
. = TRUE
else if(rate == "input")
rate = input("New transfer rate (0-[MAX_TRANSFER_RATE] L/s):", name, transfer_rate) as num|null
if(!isnull(rate))
. = TRUE
else if(text2num(rate) != null)
rate = text2num(rate)
. = TRUE
if(.)
transfer_rate = Clamp(rate, 0, MAX_TRANSFER_RATE)
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", "atmos")
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/binary/volume_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the volume pump.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else if(!istype(W, /obj/item/wrench))
return ..()
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
return 1
return ..()
/*
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/volume_pump
icon = 'icons/atmos/volume_pump.dmi'
icon_state = "map_off"
name = "volumetric gas pump"
desc = "A volumetric pump"
can_unwrench = 1
var/on = 0
var/transfer_rate = 200
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/volume_pump/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/binary/volume_pump/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/proc/set_max()
if(powered())
transfer_rate = MAX_TRANSFER_RATE
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/binary/volume_pump/on
on = 1
icon_state = "map_on"
/obj/machinery/atmospherics/binary/volume_pump/atmos_init()
..()
set_frequency(frequency)
/obj/machinery/atmospherics/binary/volume_pump/update_icon()
..()
if(!powered())
icon_state = "off"
else
icon_state = "[on ? "on" : "off"]"
/obj/machinery/atmospherics/binary/volume_pump/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/volume_pump/process_atmos()
..()
if((stat & (NOPOWER|BROKEN)) || !on)
return 0
// Pump mechanism just won't do anything if the pressure is too high/too low
var/input_starting_pressure = air1.return_pressure()
var/output_starting_pressure = air2.return_pressure()
if((input_starting_pressure < 0.01) || (output_starting_pressure > 9000))
return 1
var/transfer_ratio = max(1, transfer_rate/air1.volume)
var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio)
air2.merge(removed)
parent1.update = 1
parent2.update = 1
return 1
/obj/machinery/atmospherics/binary/volume_pump/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency)
/obj/machinery/atmospherics/binary/volume_pump/proc/broadcast_status()
if(!radio_connection)
return 0
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src
signal.data = list(
"tag" = id,
"device" = "APV",
"power" = on,
"transfer_rate" = transfer_rate,
"sigtype" = "status"
)
radio_connection.post_signal(src, signal)
return 1
/obj/machinery/atmospherics/binary/volume_pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
var/old_on = on //for logging
if(signal.data["power"])
on = text2num(signal.data["power"])
if(signal.data["power_toggle"])
on = !on
if(signal.data["set_transfer_rate"])
transfer_rate = between(
0,
text2num(signal.data["set_transfer_rate"]),
air1.volume
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
if(signal.data["status"])
spawn(2)
broadcast_status()
return //do not update_icon
spawn(2)
broadcast_status()
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/attack_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/binary/volume_pump/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/binary/volume_pump/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_pump.tmpl", name, 310, 115, state = state)
ui.open()
/obj/machinery/atmospherics/binary/volume_pump/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["rate"] = round(transfer_rate)
data["max_rate"] = round(MAX_TRANSFER_RATE)
return data
/obj/machinery/atmospherics/binary/volume_pump/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["rate"])
var/rate = href_list["rate"]
if(rate == "max")
rate = MAX_TRANSFER_RATE
. = TRUE
else if(rate == "input")
rate = input("New transfer rate (0-[MAX_TRANSFER_RATE] L/s):", name, transfer_rate) as num|null
if(!isnull(rate))
. = TRUE
else if(text2num(rate) != null)
rate = text2num(rate)
. = TRUE
if(.)
transfer_rate = Clamp(rate, 0, MAX_TRANSFER_RATE)
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", "atmos")
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/binary/volume_pump/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the volume pump.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else if(!istype(W, /obj/item/wrench))
return ..()
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
return 1
return ..()
@@ -91,4 +91,4 @@
return WEST
else
return 0
@@ -1,267 +1,267 @@
/obj/machinery/atmospherics/trinary/filter
icon = 'icons/atmos/filter.dmi'
icon_state = "map"
can_unwrench = 1
name = "gas filter"
var/target_pressure = ONE_ATMOSPHERE
var/filter_type = 0
/*
Filter types:
-1: Nothing
0: Toxins: Toxins, Oxygen Agent B
1: Oxygen: Oxygen ONLY
2: Nitrogen: Nitrogen ONLY
3: Carbon Dioxide: Carbon Dioxide ONLY
4: Sleeping Agent (N2O)
*/
var/frequency = 0
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/trinary/filter/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/trinary/filter/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/filter/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/trinary/filter/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/filter/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/trinary/filter/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/trinary/filter/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/trinary/filter/flipped
icon_state = "mmap"
flipped = 1
/obj/machinery/atmospherics/trinary/filter/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/trinary/filter/update_icon()
..()
if(flipped)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += on ? "on" : "off"
else
icon_state += "off"
on = 0
/obj/machinery/atmospherics/trinary/filter/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, -180))
if(flipped)
add_underlay(T, node2, turn(dir, 90))
else
add_underlay(T, node2, turn(dir, -90))
add_underlay(T, node3, dir)
/obj/machinery/atmospherics/trinary/filter/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/trinary/filter/process_atmos()
..()
if(!on)
return 0
var/output_starting_pressure = air3.return_pressure()
if(output_starting_pressure >= target_pressure || air2.return_pressure() >= target_pressure )
//No need to mix if target is already full!
return 1
//Calculate necessary moles to transfer using PV=nRT
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles
if(air1.temperature > 0)
transfer_moles = pressure_delta*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
//Actually transfer the gas
if(transfer_moles > 0)
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
if(!removed)
return
var/datum/gas_mixture/filtered_out = new
filtered_out.temperature = removed.temperature
switch(filter_type)
if(0) //removing hydrocarbons
filtered_out.toxins = removed.toxins
removed.toxins = 0
if(removed.trace_gases.len>0)
for(var/datum/gas/trace_gas in removed.trace_gases)
if(istype(trace_gas, /datum/gas/oxygen_agent_b))
removed.trace_gases -= trace_gas
filtered_out.trace_gases += trace_gas
if(1) //removing O2
filtered_out.oxygen = removed.oxygen
removed.oxygen = 0
if(2) //removing N2
filtered_out.nitrogen = removed.nitrogen
removed.nitrogen = 0
if(3) //removing CO2
filtered_out.carbon_dioxide = removed.carbon_dioxide
removed.carbon_dioxide = 0
if(4)//removing N2O
if(removed.trace_gases.len>0)
for(var/datum/gas/trace_gas in removed.trace_gases)
if(istype(trace_gas, /datum/gas/sleeping_agent))
removed.trace_gases -= trace_gas
filtered_out.trace_gases += trace_gas
else
filtered_out = null
air2.merge(filtered_out)
air3.merge(removed)
parent2.update = 1
parent3.update = 1
parent1.update = 1
return 1
/obj/machinery/atmospherics/trinary/filter/atmos_init()
set_frequency(frequency)
..()
/obj/machinery/atmospherics/trinary/filter/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/filter/attack_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/filter/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_filter.tmpl", name, 475, 155, state = state)
ui.open()
/obj/machinery/atmospherics/trinary/filter/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
data["filter_type"] = filter_type
return data
/obj/machinery/atmospherics/trinary/filter/Topic(href, href_list) // -- TLE
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
if(href_list["filter"])
filter_type = text2num(href_list["filter"])
investigate_log("was set to filter [filter_type] by [key_name(usr)]", "atmos")
. = TRUE
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/trinary/filter/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the filter.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else
return ..()
/obj/machinery/atmospherics/trinary/filter
icon = 'icons/atmos/filter.dmi'
icon_state = "map"
can_unwrench = 1
name = "gas filter"
var/target_pressure = ONE_ATMOSPHERE
var/filter_type = 0
/*
Filter types:
-1: Nothing
0: Toxins: Toxins, Oxygen Agent B
1: Oxygen: Oxygen ONLY
2: Nitrogen: Nitrogen ONLY
3: Carbon Dioxide: Carbon Dioxide ONLY
4: Sleeping Agent (N2O)
*/
var/frequency = 0
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/trinary/filter/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/trinary/filter/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/filter/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/trinary/filter/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/filter/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/trinary/filter/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/trinary/filter/Destroy()
if(SSradio)
SSradio.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/atmospherics/trinary/filter/flipped
icon_state = "mmap"
flipped = 1
/obj/machinery/atmospherics/trinary/filter/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
if(frequency)
radio_connection = SSradio.add_object(src, frequency, RADIO_ATMOSIA)
/obj/machinery/atmospherics/trinary/filter/update_icon()
..()
if(flipped)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += on ? "on" : "off"
else
icon_state += "off"
on = 0
/obj/machinery/atmospherics/trinary/filter/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, -180))
if(flipped)
add_underlay(T, node2, turn(dir, 90))
else
add_underlay(T, node2, turn(dir, -90))
add_underlay(T, node3, dir)
/obj/machinery/atmospherics/trinary/filter/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/trinary/filter/process_atmos()
..()
if(!on)
return 0
var/output_starting_pressure = air3.return_pressure()
if(output_starting_pressure >= target_pressure || air2.return_pressure() >= target_pressure )
//No need to mix if target is already full!
return 1
//Calculate necessary moles to transfer using PV=nRT
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles
if(air1.temperature > 0)
transfer_moles = pressure_delta*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
//Actually transfer the gas
if(transfer_moles > 0)
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
if(!removed)
return
var/datum/gas_mixture/filtered_out = new
filtered_out.temperature = removed.temperature
switch(filter_type)
if(0) //removing hydrocarbons
filtered_out.toxins = removed.toxins
removed.toxins = 0
if(removed.trace_gases.len>0)
for(var/datum/gas/trace_gas in removed.trace_gases)
if(istype(trace_gas, /datum/gas/oxygen_agent_b))
removed.trace_gases -= trace_gas
filtered_out.trace_gases += trace_gas
if(1) //removing O2
filtered_out.oxygen = removed.oxygen
removed.oxygen = 0
if(2) //removing N2
filtered_out.nitrogen = removed.nitrogen
removed.nitrogen = 0
if(3) //removing CO2
filtered_out.carbon_dioxide = removed.carbon_dioxide
removed.carbon_dioxide = 0
if(4)//removing N2O
if(removed.trace_gases.len>0)
for(var/datum/gas/trace_gas in removed.trace_gases)
if(istype(trace_gas, /datum/gas/sleeping_agent))
removed.trace_gases -= trace_gas
filtered_out.trace_gases += trace_gas
else
filtered_out = null
air2.merge(filtered_out)
air3.merge(removed)
parent2.update = 1
parent3.update = 1
parent1.update = 1
return 1
/obj/machinery/atmospherics/trinary/filter/atmos_init()
set_frequency(frequency)
..()
/obj/machinery/atmospherics/trinary/filter/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/filter/attack_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/filter/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_filter.tmpl", name, 475, 155, state = state)
ui.open()
/obj/machinery/atmospherics/trinary/filter/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
data["filter_type"] = filter_type
return data
/obj/machinery/atmospherics/trinary/filter/Topic(href, href_list) // -- TLE
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
if(href_list["filter"])
filter_type = text2num(href_list["filter"])
investigate_log("was set to filter [filter_type] by [key_name(usr)]", "atmos")
. = TRUE
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/trinary/filter/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the filter.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else
return ..()
@@ -1,233 +1,233 @@
/obj/machinery/atmospherics/trinary/mixer
icon = 'icons/atmos/mixer.dmi'
icon_state = "map"
can_unwrench = 1
name = "gas mixer"
var/target_pressure = ONE_ATMOSPHERE
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/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/trinary/mixer/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/mixer/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/trinary/mixer/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/mixer/flipped
icon_state = "mmap"
flipped = 1
/obj/machinery/atmospherics/trinary/mixer/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/trinary/mixer/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/trinary/mixer/update_icon(safety = 0)
..()
if(flipped)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += on ? "on" : "off"
else
icon_state += "off"
on = 0
/obj/machinery/atmospherics/trinary/mixer/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, -180))
if(flipped)
add_underlay(T, node2, turn(dir, 90))
else
add_underlay(T, node2, turn(dir, -90))
add_underlay(T, node3, dir)
/obj/machinery/atmospherics/trinary/mixer/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/trinary/mixer/New()
..()
air3.volume = 300
/obj/machinery/atmospherics/trinary/mixer/process_atmos()
..()
if(!on)
return 0
var/output_starting_pressure = air3.return_pressure()
if(output_starting_pressure >= target_pressure)
//No need to mix if target is already full!
return 1
//Calculate necessary moles to transfer using PV=nRT
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles1 = 0
var/transfer_moles2 = 0
if(air1.temperature > 0)
transfer_moles1 = (node1_concentration*pressure_delta)*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
if(air2.temperature > 0)
transfer_moles2 = (node2_concentration*pressure_delta)*air3.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
var/air1_moles = air1.total_moles()
var/air2_moles = air2.total_moles()
if((air1_moles < transfer_moles1) || (air2_moles < transfer_moles2))
if(!transfer_moles1 || !transfer_moles2) return
var/ratio = min(air1_moles/transfer_moles1, air2_moles/transfer_moles2)
transfer_moles1 *= ratio
transfer_moles2 *= ratio
//Actually transfer the gas
if(transfer_moles1 > 0)
var/datum/gas_mixture/removed1 = air1.remove(transfer_moles1)
air3.merge(removed1)
if(transfer_moles2 > 0)
var/datum/gas_mixture/removed2 = air2.remove(transfer_moles2)
air3.merge(removed2)
if(transfer_moles1)
parent1.update = 1
if(transfer_moles2)
parent2.update = 1
parent3.update = 1
return 1
/obj/machinery/atmospherics/trinary/mixer/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/mixer/attack_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/mixer/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_mixer.tmpl", name, 370, 165, state = state)
ui.open()
/obj/machinery/atmospherics/trinary/mixer/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
data["node1_concentration"] = round(node1_concentration*100)
data["node2_concentration"] = round(node2_concentration*100)
return data
/obj/machinery/atmospherics/trinary/mixer/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
if(href_list["node1"])
var/value = text2num(href_list["node1"])
node1_concentration = max(0, min(1, node1_concentration + value))
node2_concentration = max(0, min(1, node2_concentration - value))
investigate_log("was set to [node1_concentration] % on node 1 by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["node2"])
var/value = text2num(href_list["node2"])
node2_concentration = max(0, min(1, node2_concentration + value))
node1_concentration = max(0, min(1, node1_concentration - value))
investigate_log("was set to [node2_concentration] % on node 2 by [key_name(usr)]", "atmos")
. = TRUE
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/trinary/mixer/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the mixer.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else
return ..()
/obj/machinery/atmospherics/trinary/mixer
icon = 'icons/atmos/mixer.dmi'
icon_state = "map"
can_unwrench = 1
name = "gas mixer"
var/target_pressure = ONE_ATMOSPHERE
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/CtrlClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
toggle()
return ..()
/obj/machinery/atmospherics/trinary/mixer/AICtrlClick()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/mixer/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user) && !issilicon(usr))
return
if(!ishuman(usr) && !issilicon(usr))
return
set_max()
return
/obj/machinery/atmospherics/trinary/mixer/AIAltClick()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/mixer/flipped
icon_state = "mmap"
flipped = 1
/obj/machinery/atmospherics/trinary/mixer/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/trinary/mixer/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/trinary/mixer/update_icon(safety = 0)
..()
if(flipped)
icon_state = "m"
else
icon_state = ""
if(!powered())
icon_state += "off"
else if(node2 && node3 && node1)
icon_state += on ? "on" : "off"
else
icon_state += "off"
on = 0
/obj/machinery/atmospherics/trinary/mixer/update_underlays()
if(..())
underlays.Cut()
var/turf/T = get_turf(src)
if(!istype(T))
return
add_underlay(T, node1, turn(dir, -180))
if(flipped)
add_underlay(T, node2, turn(dir, 90))
else
add_underlay(T, node2, turn(dir, -90))
add_underlay(T, node3, dir)
/obj/machinery/atmospherics/trinary/mixer/power_change()
var/old_stat = stat
..()
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/trinary/mixer/New()
..()
air3.volume = 300
/obj/machinery/atmospherics/trinary/mixer/process_atmos()
..()
if(!on)
return 0
var/output_starting_pressure = air3.return_pressure()
if(output_starting_pressure >= target_pressure)
//No need to mix if target is already full!
return 1
//Calculate necessary moles to transfer using PV=nRT
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles1 = 0
var/transfer_moles2 = 0
if(air1.temperature > 0)
transfer_moles1 = (node1_concentration*pressure_delta)*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
if(air2.temperature > 0)
transfer_moles2 = (node2_concentration*pressure_delta)*air3.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
var/air1_moles = air1.total_moles()
var/air2_moles = air2.total_moles()
if((air1_moles < transfer_moles1) || (air2_moles < transfer_moles2))
if(!transfer_moles1 || !transfer_moles2) return
var/ratio = min(air1_moles/transfer_moles1, air2_moles/transfer_moles2)
transfer_moles1 *= ratio
transfer_moles2 *= ratio
//Actually transfer the gas
if(transfer_moles1 > 0)
var/datum/gas_mixture/removed1 = air1.remove(transfer_moles1)
air3.merge(removed1)
if(transfer_moles2 > 0)
var/datum/gas_mixture/removed2 = air2.remove(transfer_moles2)
air3.merge(removed2)
if(transfer_moles1)
parent1.update = 1
if(transfer_moles2)
parent2.update = 1
parent3.update = 1
return 1
/obj/machinery/atmospherics/trinary/mixer/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/mixer/attack_hand(mob/user)
if(..())
return
if(!allowed(user))
to_chat(user, "<span class='alert'>Access denied.</span>")
return
add_fingerprint(user)
ui_interact(user)
/obj/machinery/atmospherics/trinary/mixer/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_mixer.tmpl", name, 370, 165, state = state)
ui.open()
/obj/machinery/atmospherics/trinary/mixer/ui_data(mob/user)
var/list/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
data["node1_concentration"] = round(node1_concentration*100)
data["node2_concentration"] = round(node2_concentration*100)
return data
/obj/machinery/atmospherics/trinary/mixer/Topic(href,href_list)
if(..())
return 1
if(href_list["power"])
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["pressure"])
var/pressure = href_list["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
if(href_list["node1"])
var/value = text2num(href_list["node1"])
node1_concentration = max(0, min(1, node1_concentration + value))
node2_concentration = max(0, min(1, node2_concentration - value))
investigate_log("was set to [node1_concentration] % on node 1 by [key_name(usr)]", "atmos")
. = TRUE
if(href_list["node2"])
var/value = text2num(href_list["node2"])
node2_concentration = max(0, min(1, node2_concentration + value))
node1_concentration = max(0, min(1, node1_concentration - value))
investigate_log("was set to [node2_concentration] % on node 2 by [key_name(usr)]", "atmos")
. = TRUE
update_icon()
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/trinary/mixer/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the mixer.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else
return ..()
@@ -1,213 +1,213 @@
/obj/machinery/atmospherics/trinary
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = IDLE_POWER_USE
var/on = 0
layer = GAS_FILTER_LAYER
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/datum/gas_mixture/air3
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/obj/machinery/atmospherics/node3
var/datum/pipeline/parent1
var/datum/pipeline/parent2
var/datum/pipeline/parent3
var/flipped = 0
/obj/machinery/atmospherics/trinary/New()
..()
if(!flipped)
switch(dir)
if(NORTH)
initialize_directions = EAST|NORTH|SOUTH
if(SOUTH)
initialize_directions = SOUTH|WEST|NORTH
if(EAST)
initialize_directions = EAST|WEST|SOUTH
if(WEST)
initialize_directions = WEST|NORTH|EAST
else
switch(dir)
if(NORTH)
initialize_directions = SOUTH|NORTH|WEST
if(SOUTH)
initialize_directions = NORTH|SOUTH|EAST
if(EAST)
initialize_directions = WEST|EAST|NORTH
if(WEST)
initialize_directions = EAST|WEST|SOUTH
air1 = new
air2 = new
air3 = new
air1.volume = 200
air2.volume = 200
air3.volume = 200
/obj/machinery/atmospherics/trinary/Destroy()
if(node1)
node1.disconnect(src)
node1 = null
nullifyPipenet(parent1)
if(node2)
node2.disconnect(src)
node2 = null
nullifyPipenet(parent2)
if(node3)
node3.disconnect(src)
node3 = null
nullifyPipenet(parent3)
return ..()
/obj/machinery/atmospherics/trinary/atmos_init()
..()
//Mixer:
//1 and 2 is input
//Node 3 is output
//If we flip the mixer, 1 and 3 shall exchange positions
//Filter:
//Node 1 is input
//Node 2 is filtered output
//Node 3 is rest output
//If we flip the filter, 1 and 3 shall exchange positions
var/node1_connect = turn(dir, -180)
var/node2_connect = turn(dir, -90)
var/node3_connect = dir
if(flipped)
node2_connect = turn(node2_connect, -180)
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
if(target.initialize_directions & get_dir(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node3_connect))
if(target.initialize_directions & get_dir(target,src))
node3 = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/trinary/build_network(remove_deferral = FALSE)
if(!parent1)
parent1 = new /datum/pipeline()
parent1.build_pipeline(src)
if(!parent2)
parent2 = new /datum/pipeline()
parent2.build_pipeline(src)
if(!parent3)
parent3 = new /datum/pipeline()
parent3.build_pipeline(src)
..()
/obj/machinery/atmospherics/trinary/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent1)
node1 = null
else if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent2)
node2 = null
else if(reference == node3)
if(istype(node3, /obj/machinery/atmospherics/pipe))
qdel(parent3)
node3 = null
update_icon()
/obj/machinery/atmospherics/trinary/nullifyPipenet(datum/pipeline/P)
..()
if(!P)
return
if(P == parent1)
parent1.other_airs -= air1
parent1 = null
else if(P == parent2)
parent2.other_airs -= air2
parent2 = null
else if(P == parent3)
parent3.other_airs -= air3
parent3 = null
/obj/machinery/atmospherics/trinary/returnPipenetAir(datum/pipeline/P)
if(P == parent1)
return air1
else if(P == parent2)
return air2
else if(P == parent3)
return air3
/obj/machinery/atmospherics/trinary/pipeline_expansion(datum/pipeline/P)
if(P)
if(parent1 == P)
return list(node1)
else if(parent2 == P)
return list(node2)
else if(parent3 == P)
return list(node3)
return list(node1, node2, node3)
/obj/machinery/atmospherics/trinary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
if(A == node1)
parent1 = P
else if(A == node2)
parent2 = P
else if(A == node3)
parent3 = P
/obj/machinery/atmospherics/trinary/returnPipenet(obj/machinery/atmospherics/A)
if(A == node1)
return parent1
else if(A == node2)
return parent2
else if(A == node3)
return parent3
/obj/machinery/atmospherics/trinary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent1)
parent1 = New
else if(Old == parent2)
parent2 = New
else if(Old == parent3)
parent3 = New
/obj/machinery/atmospherics/trinary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
var/turf/T = get_turf(src)
if(T)
//Remove the gas from air1+air2+air3 and assume it
var/datum/gas_mixture/environment = T.return_air()
var/lost = pressures*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
lost += pressures*environment.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
lost += pressures*environment.volume/(air3.temperature * R_IDEAL_GAS_EQUATION)
var/shared_loss = lost/3
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
to_release.merge(air2.remove(shared_loss))
to_release.merge(air3.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/trinary/process_atmos()
..()
return parent1 && parent2 && parent3
/obj/machinery/atmospherics/trinary
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = IDLE_POWER_USE
var/on = 0
layer = GAS_FILTER_LAYER
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/datum/gas_mixture/air3
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/obj/machinery/atmospherics/node3
var/datum/pipeline/parent1
var/datum/pipeline/parent2
var/datum/pipeline/parent3
var/flipped = 0
/obj/machinery/atmospherics/trinary/New()
..()
if(!flipped)
switch(dir)
if(NORTH)
initialize_directions = EAST|NORTH|SOUTH
if(SOUTH)
initialize_directions = SOUTH|WEST|NORTH
if(EAST)
initialize_directions = EAST|WEST|SOUTH
if(WEST)
initialize_directions = WEST|NORTH|EAST
else
switch(dir)
if(NORTH)
initialize_directions = SOUTH|NORTH|WEST
if(SOUTH)
initialize_directions = NORTH|SOUTH|EAST
if(EAST)
initialize_directions = WEST|EAST|NORTH
if(WEST)
initialize_directions = EAST|WEST|SOUTH
air1 = new
air2 = new
air3 = new
air1.volume = 200
air2.volume = 200
air3.volume = 200
/obj/machinery/atmospherics/trinary/Destroy()
if(node1)
node1.disconnect(src)
node1 = null
nullifyPipenet(parent1)
if(node2)
node2.disconnect(src)
node2 = null
nullifyPipenet(parent2)
if(node3)
node3.disconnect(src)
node3 = null
nullifyPipenet(parent3)
return ..()
/obj/machinery/atmospherics/trinary/atmos_init()
..()
//Mixer:
//1 and 2 is input
//Node 3 is output
//If we flip the mixer, 1 and 3 shall exchange positions
//Filter:
//Node 1 is input
//Node 2 is filtered output
//Node 3 is rest output
//If we flip the filter, 1 and 3 shall exchange positions
var/node1_connect = turn(dir, -180)
var/node2_connect = turn(dir, -90)
var/node3_connect = dir
if(flipped)
node2_connect = turn(node2_connect, -180)
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
if(target.initialize_directions & get_dir(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node3_connect))
if(target.initialize_directions & get_dir(target,src))
node3 = target
break
update_icon()
update_underlays()
/obj/machinery/atmospherics/trinary/build_network(remove_deferral = FALSE)
if(!parent1)
parent1 = new /datum/pipeline()
parent1.build_pipeline(src)
if(!parent2)
parent2 = new /datum/pipeline()
parent2.build_pipeline(src)
if(!parent3)
parent3 = new /datum/pipeline()
parent3.build_pipeline(src)
..()
/obj/machinery/atmospherics/trinary/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent1)
node1 = null
else if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent2)
node2 = null
else if(reference == node3)
if(istype(node3, /obj/machinery/atmospherics/pipe))
qdel(parent3)
node3 = null
update_icon()
/obj/machinery/atmospherics/trinary/nullifyPipenet(datum/pipeline/P)
..()
if(!P)
return
if(P == parent1)
parent1.other_airs -= air1
parent1 = null
else if(P == parent2)
parent2.other_airs -= air2
parent2 = null
else if(P == parent3)
parent3.other_airs -= air3
parent3 = null
/obj/machinery/atmospherics/trinary/returnPipenetAir(datum/pipeline/P)
if(P == parent1)
return air1
else if(P == parent2)
return air2
else if(P == parent3)
return air3
/obj/machinery/atmospherics/trinary/pipeline_expansion(datum/pipeline/P)
if(P)
if(parent1 == P)
return list(node1)
else if(parent2 == P)
return list(node2)
else if(parent3 == P)
return list(node3)
return list(node1, node2, node3)
/obj/machinery/atmospherics/trinary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
if(A == node1)
parent1 = P
else if(A == node2)
parent2 = P
else if(A == node3)
parent3 = P
/obj/machinery/atmospherics/trinary/returnPipenet(obj/machinery/atmospherics/A)
if(A == node1)
return parent1
else if(A == node2)
return parent2
else if(A == node3)
return parent3
/obj/machinery/atmospherics/trinary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent1)
parent1 = New
else if(Old == parent2)
parent2 = New
else if(Old == parent3)
parent3 = New
/obj/machinery/atmospherics/trinary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
var/turf/T = get_turf(src)
if(T)
//Remove the gas from air1+air2+air3 and assume it
var/datum/gas_mixture/environment = T.return_air()
var/lost = pressures*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
lost += pressures*environment.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
lost += pressures*environment.volume/(air3.temperature * R_IDEAL_GAS_EQUATION)
var/shared_loss = lost/3
var/datum/gas_mixture/to_release = air1.remove(shared_loss)
to_release.merge(air2.remove(shared_loss))
to_release.merge(air3.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/trinary/process_atmos()
..()
return parent1 && parent2 && parent3
@@ -177,4 +177,4 @@
switch_side()
#undef TVALVE_STATE_STRAIGHT
#undef TVALVE_STATE_SIDE
#undef TVALVE_STATE_SIDE
@@ -45,4 +45,4 @@
parent.update = 1
return 1
return 1
@@ -110,4 +110,4 @@
var/datum/gas/oxygen_agent_b/trace_gas = new
trace_gas.moles = (50 * ONE_ATMOSPHERE) * (air_contents.volume) / (R_IDEAL_GAS_EQUATION * air_contents.temperature)
air_contents.trace_gases += trace_gas
air_contents.trace_gases += trace_gas
@@ -77,4 +77,4 @@
parent.update = 1
return 1
return 1
@@ -102,4 +102,4 @@
/obj/machinery/atmospherics/unary/process_atmos()
..()
return parent
return parent
+276 -276
View File
@@ -1,276 +1,276 @@
/datum/pipeline
var/datum/gas_mixture/air
var/list/datum/gas_mixture/other_airs = list()
var/list/obj/machinery/atmospherics/pipe/members = list()
var/list/obj/machinery/atmospherics/other_atmosmch = list()
var/update = 1
var/alert_pressure = 0
/datum/pipeline/New()
SSair.networks += src
/datum/pipeline/Destroy()
SSair.networks -= src
if(air && air.volume)
temporarily_store_air()
for(var/obj/machinery/atmospherics/pipe/P in members)
P.parent = null
for(var/obj/machinery/atmospherics/A in other_atmosmch)
A.nullifyPipenet(src)
return ..()
/datum/pipeline/process()//This use to be called called from the pipe networks
if(update)
update = 0
reconcile_air()
return
var/pipenetwarnings = 10
/datum/pipeline/proc/build_pipeline(obj/machinery/atmospherics/base)
var/volume = 0
if(istype(base, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/E = base
volume = E.volume
alert_pressure = E.alert_pressure
members += E
if(E.air_temporary)
air = E.air_temporary
E.air_temporary = null
else
addMachineryMember(base)
if(!air)
air = new
var/list/possible_expansions = list(base)
while(possible_expansions.len>0)
for(var/obj/machinery/atmospherics/borderline in possible_expansions)
var/list/result = borderline.pipeline_expansion(src)
if(result.len>0)
for(var/obj/machinery/atmospherics/P in result)
if(istype(P, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/item = P
if(!members.Find(item))
if(item.parent)
log_runtime(EXCEPTION("[item.type] \[\ref[item]] added to a pipenet while still having one ([item.parent]) (pipes leading to the same spot stacking in one turf). Nearby: [item.x], [item.y], [item.z]."))
members += item
possible_expansions += item
volume += item.volume
item.parent = src
alert_pressure = min(alert_pressure, item.alert_pressure)
if(item.air_temporary)
air.merge(item.air_temporary)
item.air_temporary = null
else
P.setPipenet(src, borderline)
addMachineryMember(P)
possible_expansions -= borderline
air.volume = volume
/datum/pipeline/proc/addMachineryMember(obj/machinery/atmospherics/A)
other_atmosmch |= A
var/datum/gas_mixture/G = A.returnPipenetAir(src)
other_airs |= G
/datum/pipeline/proc/addMember(obj/machinery/atmospherics/A, obj/machinery/atmospherics/N)
if(istype(A, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/P = A
P.parent = src
var/list/adjacent = P.pipeline_expansion()
for(var/obj/machinery/atmospherics/pipe/I in adjacent)
if(I.parent == src)
continue
var/datum/pipeline/E = I.parent
merge(E)
if(!members.Find(P))
members += P
air.volume += P.volume
else
A.setPipenet(src, N)
addMachineryMember(A)
/datum/pipeline/proc/merge(datum/pipeline/E)
air.volume += E.air.volume
members.Add(E.members)
for(var/obj/machinery/atmospherics/pipe/S in E.members)
S.parent = src
air.merge(E.air)
for(var/obj/machinery/atmospherics/A in E.other_atmosmch)
A.replacePipenet(E, src)
other_atmosmch.Add(E.other_atmosmch)
other_airs.Add(E.other_airs)
E.members.Cut()
E.other_atmosmch.Cut()
qdel(E)
/obj/machinery/atmospherics/proc/addMember(obj/machinery/atmospherics/A)
var/datum/pipeline/P = returnPipenet(A)
P.addMember(A, src)
/obj/machinery/atmospherics/pipe/addMember(obj/machinery/atmospherics/A)
parent.addMember(A, src)
/datum/pipeline/proc/temporarily_store_air()
//Update individual gas_mixtures by volume ratio
for(var/obj/machinery/atmospherics/pipe/member in members)
member.air_temporary = new
member.air_temporary.volume = member.volume
member.air_temporary.oxygen = air.oxygen*member.volume/air.volume
member.air_temporary.nitrogen = air.nitrogen*member.volume/air.volume
member.air_temporary.toxins = air.toxins*member.volume/air.volume
member.air_temporary.carbon_dioxide = air.carbon_dioxide*member.volume/air.volume
member.air_temporary.temperature = air.temperature
if(air.trace_gases.len)
for(var/datum/gas/trace_gas in air.trace_gases)
var/datum/gas/corresponding = new trace_gas.type()
member.air_temporary.trace_gases += corresponding
corresponding.moles = trace_gas.moles*member.volume/air.volume
/datum/pipeline/proc/temperature_interact(turf/target, share_volume, thermal_conductivity)
var/total_heat_capacity = air.heat_capacity()
var/partial_heat_capacity = total_heat_capacity*(share_volume/air.volume)
if(istype(target, /turf/simulated))
var/turf/simulated/modeled_location = target
if(modeled_location.blocks_air)
if((modeled_location.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - modeled_location.temperature
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*modeled_location.heat_capacity/(partial_heat_capacity+modeled_location.heat_capacity))
air.temperature -= heat/total_heat_capacity
modeled_location.temperature += heat/modeled_location.heat_capacity
else
var/delta_temperature = 0
var/sharer_heat_capacity = 0
delta_temperature = (air.temperature - modeled_location.air.temperature)
sharer_heat_capacity = modeled_location.air.heat_capacity()
var/self_temperature_delta = 0
var/sharer_temperature_delta = 0
if((sharer_heat_capacity>0) && (partial_heat_capacity>0))
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*sharer_heat_capacity/(partial_heat_capacity+sharer_heat_capacity))
self_temperature_delta = -heat/total_heat_capacity
sharer_temperature_delta = heat/sharer_heat_capacity
else
return 1
air.temperature += self_temperature_delta
modeled_location.air.temperature += sharer_temperature_delta
else
if((target.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - target.temperature
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*target.heat_capacity/(partial_heat_capacity+target.heat_capacity))
air.temperature -= heat/total_heat_capacity
update = 1
/datum/pipeline/proc/reconcile_air()
var/list/datum/gas_mixture/GL = list()
var/list/datum/pipeline/PL = list()
PL += src
for(var/i=1;i<=PL.len;i++)
var/datum/pipeline/P = PL[i]
if(!P)
return
GL += P.air
GL += P.other_airs
for(var/obj/machinery/atmospherics/binary/valve/V in P.other_atmosmch)
if(V.open)
PL |= V.parent1
PL |= V.parent2
for(var/obj/machinery/atmospherics/trinary/tvalve/T in P.other_atmosmch)
if(!T.state)
if(src != T.parent2) // otherwise dc'd side connects to both other sides!
PL |= T.parent1
PL |= T.parent3
else
if(src != T.parent3)
PL |= T.parent1
PL |= T.parent2
for(var/obj/machinery/atmospherics/unary/portables_connector/C in P.other_atmosmch)
if(C.connected_device)
GL += C.portableConnectorReturnAir()
var/total_volume = 0
var/total_thermal_energy = 0
var/total_heat_capacity = 0
var/total_oxygen = 0
var/total_nitrogen = 0
var/total_toxins = 0
var/total_carbon_dioxide = 0
var/list/total_trace_gases = list()
for(var/datum/gas_mixture/G in GL)
total_volume += G.volume
total_thermal_energy += G.thermal_energy()
total_heat_capacity += G.heat_capacity()
total_oxygen += G.oxygen
total_nitrogen += G.nitrogen
total_toxins += G.toxins
total_carbon_dioxide += G.carbon_dioxide
if(G.trace_gases.len)
for(var/datum/gas/trace_gas in G.trace_gases)
var/datum/gas/corresponding = locate(trace_gas.type) in total_trace_gases
if(!corresponding)
corresponding = new trace_gas.type()
total_trace_gases += corresponding
corresponding.moles += trace_gas.moles
if(total_volume > 0)
//Calculate temperature
var/temperature = 0
if(total_heat_capacity > 0)
temperature = total_thermal_energy/total_heat_capacity
//Update individual gas_mixtures by volume ratio
for(var/datum/gas_mixture/G in GL)
G.oxygen = total_oxygen*G.volume/total_volume
G.nitrogen = total_nitrogen*G.volume/total_volume
G.toxins = total_toxins*G.volume/total_volume
G.carbon_dioxide = total_carbon_dioxide*G.volume/total_volume
G.temperature = temperature
if(total_trace_gases.len)
for(var/datum/gas/trace_gas in total_trace_gases)
var/datum/gas/corresponding = locate(trace_gas.type) in G.trace_gases
if(!corresponding)
corresponding = new trace_gas.type()
G.trace_gases += corresponding
corresponding.moles = trace_gas.moles*G.volume/total_volume
/datum/pipeline
var/datum/gas_mixture/air
var/list/datum/gas_mixture/other_airs = list()
var/list/obj/machinery/atmospherics/pipe/members = list()
var/list/obj/machinery/atmospherics/other_atmosmch = list()
var/update = 1
var/alert_pressure = 0
/datum/pipeline/New()
SSair.networks += src
/datum/pipeline/Destroy()
SSair.networks -= src
if(air && air.volume)
temporarily_store_air()
for(var/obj/machinery/atmospherics/pipe/P in members)
P.parent = null
for(var/obj/machinery/atmospherics/A in other_atmosmch)
A.nullifyPipenet(src)
return ..()
/datum/pipeline/process()//This use to be called called from the pipe networks
if(update)
update = 0
reconcile_air()
return
var/pipenetwarnings = 10
/datum/pipeline/proc/build_pipeline(obj/machinery/atmospherics/base)
var/volume = 0
if(istype(base, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/E = base
volume = E.volume
alert_pressure = E.alert_pressure
members += E
if(E.air_temporary)
air = E.air_temporary
E.air_temporary = null
else
addMachineryMember(base)
if(!air)
air = new
var/list/possible_expansions = list(base)
while(possible_expansions.len>0)
for(var/obj/machinery/atmospherics/borderline in possible_expansions)
var/list/result = borderline.pipeline_expansion(src)
if(result.len>0)
for(var/obj/machinery/atmospherics/P in result)
if(istype(P, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/item = P
if(!members.Find(item))
if(item.parent)
log_runtime(EXCEPTION("[item.type] \[\ref[item]] added to a pipenet while still having one ([item.parent]) (pipes leading to the same spot stacking in one turf). Nearby: [item.x], [item.y], [item.z]."))
members += item
possible_expansions += item
volume += item.volume
item.parent = src
alert_pressure = min(alert_pressure, item.alert_pressure)
if(item.air_temporary)
air.merge(item.air_temporary)
item.air_temporary = null
else
P.setPipenet(src, borderline)
addMachineryMember(P)
possible_expansions -= borderline
air.volume = volume
/datum/pipeline/proc/addMachineryMember(obj/machinery/atmospherics/A)
other_atmosmch |= A
var/datum/gas_mixture/G = A.returnPipenetAir(src)
other_airs |= G
/datum/pipeline/proc/addMember(obj/machinery/atmospherics/A, obj/machinery/atmospherics/N)
if(istype(A, /obj/machinery/atmospherics/pipe))
var/obj/machinery/atmospherics/pipe/P = A
P.parent = src
var/list/adjacent = P.pipeline_expansion()
for(var/obj/machinery/atmospherics/pipe/I in adjacent)
if(I.parent == src)
continue
var/datum/pipeline/E = I.parent
merge(E)
if(!members.Find(P))
members += P
air.volume += P.volume
else
A.setPipenet(src, N)
addMachineryMember(A)
/datum/pipeline/proc/merge(datum/pipeline/E)
air.volume += E.air.volume
members.Add(E.members)
for(var/obj/machinery/atmospherics/pipe/S in E.members)
S.parent = src
air.merge(E.air)
for(var/obj/machinery/atmospherics/A in E.other_atmosmch)
A.replacePipenet(E, src)
other_atmosmch.Add(E.other_atmosmch)
other_airs.Add(E.other_airs)
E.members.Cut()
E.other_atmosmch.Cut()
qdel(E)
/obj/machinery/atmospherics/proc/addMember(obj/machinery/atmospherics/A)
var/datum/pipeline/P = returnPipenet(A)
P.addMember(A, src)
/obj/machinery/atmospherics/pipe/addMember(obj/machinery/atmospherics/A)
parent.addMember(A, src)
/datum/pipeline/proc/temporarily_store_air()
//Update individual gas_mixtures by volume ratio
for(var/obj/machinery/atmospherics/pipe/member in members)
member.air_temporary = new
member.air_temporary.volume = member.volume
member.air_temporary.oxygen = air.oxygen*member.volume/air.volume
member.air_temporary.nitrogen = air.nitrogen*member.volume/air.volume
member.air_temporary.toxins = air.toxins*member.volume/air.volume
member.air_temporary.carbon_dioxide = air.carbon_dioxide*member.volume/air.volume
member.air_temporary.temperature = air.temperature
if(air.trace_gases.len)
for(var/datum/gas/trace_gas in air.trace_gases)
var/datum/gas/corresponding = new trace_gas.type()
member.air_temporary.trace_gases += corresponding
corresponding.moles = trace_gas.moles*member.volume/air.volume
/datum/pipeline/proc/temperature_interact(turf/target, share_volume, thermal_conductivity)
var/total_heat_capacity = air.heat_capacity()
var/partial_heat_capacity = total_heat_capacity*(share_volume/air.volume)
if(istype(target, /turf/simulated))
var/turf/simulated/modeled_location = target
if(modeled_location.blocks_air)
if((modeled_location.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - modeled_location.temperature
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*modeled_location.heat_capacity/(partial_heat_capacity+modeled_location.heat_capacity))
air.temperature -= heat/total_heat_capacity
modeled_location.temperature += heat/modeled_location.heat_capacity
else
var/delta_temperature = 0
var/sharer_heat_capacity = 0
delta_temperature = (air.temperature - modeled_location.air.temperature)
sharer_heat_capacity = modeled_location.air.heat_capacity()
var/self_temperature_delta = 0
var/sharer_temperature_delta = 0
if((sharer_heat_capacity>0) && (partial_heat_capacity>0))
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*sharer_heat_capacity/(partial_heat_capacity+sharer_heat_capacity))
self_temperature_delta = -heat/total_heat_capacity
sharer_temperature_delta = heat/sharer_heat_capacity
else
return 1
air.temperature += self_temperature_delta
modeled_location.air.temperature += sharer_temperature_delta
else
if((target.heat_capacity>0) && (partial_heat_capacity>0))
var/delta_temperature = air.temperature - target.temperature
var/heat = thermal_conductivity*delta_temperature* \
(partial_heat_capacity*target.heat_capacity/(partial_heat_capacity+target.heat_capacity))
air.temperature -= heat/total_heat_capacity
update = 1
/datum/pipeline/proc/reconcile_air()
var/list/datum/gas_mixture/GL = list()
var/list/datum/pipeline/PL = list()
PL += src
for(var/i=1;i<=PL.len;i++)
var/datum/pipeline/P = PL[i]
if(!P)
return
GL += P.air
GL += P.other_airs
for(var/obj/machinery/atmospherics/binary/valve/V in P.other_atmosmch)
if(V.open)
PL |= V.parent1
PL |= V.parent2
for(var/obj/machinery/atmospherics/trinary/tvalve/T in P.other_atmosmch)
if(!T.state)
if(src != T.parent2) // otherwise dc'd side connects to both other sides!
PL |= T.parent1
PL |= T.parent3
else
if(src != T.parent3)
PL |= T.parent1
PL |= T.parent2
for(var/obj/machinery/atmospherics/unary/portables_connector/C in P.other_atmosmch)
if(C.connected_device)
GL += C.portableConnectorReturnAir()
var/total_volume = 0
var/total_thermal_energy = 0
var/total_heat_capacity = 0
var/total_oxygen = 0
var/total_nitrogen = 0
var/total_toxins = 0
var/total_carbon_dioxide = 0
var/list/total_trace_gases = list()
for(var/datum/gas_mixture/G in GL)
total_volume += G.volume
total_thermal_energy += G.thermal_energy()
total_heat_capacity += G.heat_capacity()
total_oxygen += G.oxygen
total_nitrogen += G.nitrogen
total_toxins += G.toxins
total_carbon_dioxide += G.carbon_dioxide
if(G.trace_gases.len)
for(var/datum/gas/trace_gas in G.trace_gases)
var/datum/gas/corresponding = locate(trace_gas.type) in total_trace_gases
if(!corresponding)
corresponding = new trace_gas.type()
total_trace_gases += corresponding
corresponding.moles += trace_gas.moles
if(total_volume > 0)
//Calculate temperature
var/temperature = 0
if(total_heat_capacity > 0)
temperature = total_thermal_energy/total_heat_capacity
//Update individual gas_mixtures by volume ratio
for(var/datum/gas_mixture/G in GL)
G.oxygen = total_oxygen*G.volume/total_volume
G.nitrogen = total_nitrogen*G.volume/total_volume
G.toxins = total_toxins*G.volume/total_volume
G.carbon_dioxide = total_carbon_dioxide*G.volume/total_volume
G.temperature = temperature
if(total_trace_gases.len)
for(var/datum/gas/trace_gas in total_trace_gases)
var/datum/gas/corresponding = locate(trace_gas.type) in G.trace_gases
if(!corresponding)
corresponding = new trace_gas.type()
G.trace_gases += corresponding
corresponding.moles = trace_gas.moles*G.volume/total_volume
+1 -1
View File
@@ -123,4 +123,4 @@
connect_types = list(2)
layer = 2.39
icon_connect_type = "-supply"
color = PIPE_COLOR_BLUE
color = PIPE_COLOR_BLUE
@@ -68,4 +68,4 @@
color = PIPE_COLOR_GREEN
/obj/machinery/atmospherics/pipe/simple/hidden/purple
color = PIPE_COLOR_PURPLE
color = PIPE_COLOR_PURPLE
@@ -8,4 +8,4 @@
fatigue_pressure = 900*ONE_ATMOSPHERE
alert_pressure = 900*ONE_ATMOSPHERE
level = 2
level = 2
@@ -65,4 +65,4 @@
/obj/machinery/atmospherics/pipe/simple/visible/universal/update_underlays()
..()
update_icon()
update_icon()