Rewrite pipe construction

- Moved pipe construction defines into __defines/construction.dm
- Unified pipe *unwrenching* by creating a standard proc along with the `construction_type` var.
- Eliminated the pipe fitting name & icon_state lookup tables by adding `pipe_state` var on atmos machinery and referencing that.
    - Each pipe which can be made from a fitting object should override `pipe_state` with the icon state to be used on the pipe fitting object.
- Eliminated the giant switch statement of doom in pipe construction by delegating that work to `on_construction` proc.
    - To make this work, every pipe must implement `get_neighbor_nodes_for_init` which returns a list of nodes which should be re-initialized on that pipe's construction.
- Combined the SCRUBBERS, SUPPLY and REGULAR pipe fitting classes together by storing the `piping_layer` variable and using the `setPipingLayer` procs
- Standardized the code for searching for node neighbors into the `can_be_node` proc.
    - This proc is also improved in that is a mutual check, `check_connectable` is called on BOTH objects, so they have to mutually agree to connect as nodes. Eliminates lots of special edge case logic.
    - Updated all the `amos_init` procs to use `can_be_node`.  In the most common cases, even that boilerplate code is consolidated into the `STANDARD_ATMOS_CHOOSE_NODE` macro.
- Implemented `pipe_flags` which lets pipes declare (or override) certain requirements.
- Adds a "pipe_recipe" datum to help out things that construct pipes.  By taking it out of the dispenser, we open the road for multiple dispenser types.  No, no RPD yet.  Soon.
    - Enhances the pipe dispenser to operate on pipe recipe datums instead of hard coded lists of pipes it can construct.   These datums are also (partially) initialized from the pipe machine types themselves, reducing having to define stuff in multiple places.
    - Switched pipe dispenser UI to use browse().   Not a NanoUI, but makes it a bit prettier with low effort.
    - Changed pipe dispenser to use a button selector to switch between Regular/Scrubbers/Supply instead of having separate list items.
- Added icon states to HE pipes to support the "connected on neither side" state.
This commit is contained in:
Leshana
2018-03-20 23:29:27 -04:00
parent 70ac478aea
commit 776b221828
44 changed files with 716 additions and 1518 deletions
-5
View File
@@ -15,11 +15,6 @@
#define PIPE_COLOR_BLACK "#444444"
#define PIPE_COLOR_PURPLE "#5c1ec0"
#define CONNECT_TYPE_REGULAR 1
#define CONNECT_TYPE_SUPPLY 2
#define CONNECT_TYPE_SCRUBBER 4
#define CONNECT_TYPE_HE 8
var/global/list/pipe_colors = list("grey" = PIPE_COLOR_GREY, "red" = PIPE_COLOR_RED, "blue" = PIPE_COLOR_BLUE, "cyan" = PIPE_COLOR_CYAN, "green" = PIPE_COLOR_GREEN, "yellow" = PIPE_COLOR_YELLOW, "black" = PIPE_COLOR_BLACK, "purple" = PIPE_COLOR_PURPLE)
/proc/pipe_color_lookup(var/color)
+73 -7
View File
@@ -19,8 +19,12 @@ Pipelines + Other Objects -> Pipe network
layer = 2.4 //under wires with their 2.44
var/pipe_flags = PIPING_DEFAULT_LAYER_ONLY // Allow other layers by exception basis.
var/connect_types = CONNECT_TYPE_REGULAR
var/piping_layer = PIPING_LAYER_DEFAULT // This will replace icon_connect_type at some point ~Leshana
var/icon_connect_type = "" //"-supply" or "-scrubbers"
var/construction_type = null // Type path of the pipe item when this is deconstructed.
var/pipe_state // icon_state as a pipe item
var/initialize_directions = 0
var/pipe_color
@@ -46,6 +50,10 @@ Pipelines + Other Objects -> Pipe network
/obj/machinery/atmospherics/proc/init_dir()
return
// Get ALL initialize_directions - Some types (HE pipes etc) combine two vars together for this.
/obj/machinery/atmospherics/proc/get_init_dirs()
return initialize_directions
// Get the direction each node is facing to connect.
// It now returns as a list so it can be fetched nicely, each entry corresponds to node of same number.
/obj/machinery/atmospherics/proc/get_node_connect_dirs()
@@ -59,6 +67,14 @@ Pipelines + Other Objects -> Pipe network
/obj/machinery/atmospherics/proc/atmos_init()
return
/** Check if target is an acceptable target to connect as a node from this machine. */
/obj/machinery/atmospherics/proc/can_be_node(obj/machinery/atmospherics/target, node_num)
return (target.initialize_directions & get_dir(target,src)) && check_connectable(target) && target.check_connectable(src)
/** Check if this machine is willing to connect with the target machine. */
/obj/machinery/atmospherics/proc/check_connectable(obj/machinery/atmospherics/target)
return (src.connect_types & target.connect_types)
/obj/machinery/atmospherics/attackby(atom/A, mob/user as mob)
if(istype(A, /obj/item/device/pipe_painter))
return
@@ -82,12 +98,6 @@ Pipelines + Other Objects -> Pipe network
else
return 0
obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/atmos1, obj/machinery/atmospherics/atmos2)
return (atmos1.connect_types & atmos2.connect_types)
/obj/machinery/atmospherics/proc/check_connect_types_construction(obj/machinery/atmospherics/atmos1, obj/item/pipe/pipe2)
return (atmos1.connect_types & pipe2.connect_types)
/obj/machinery/atmospherics/proc/check_icon_cache(var/safety = 0)
if(!istype(icon_manager))
if(!safety) //to prevent infinite loops
@@ -146,4 +156,60 @@ obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/a
var/datum/gas_mixture/env_air = loc.return_air()
if((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE)
return 0
return 1
return 1
// Deconstruct into a pipe item.
/obj/machinery/atmospherics/proc/deconstruct()
if(QDELETED(src))
return
if(construction_type)
var/obj/item/pipe/I = new construction_type(loc, null, null, src)
I.setPipingLayer(piping_layer)
transfer_fingerprints_to(I)
qdel(src)
// Return a list of nodes which we should call atmos_init() and build_network() during on_construction()
/obj/machinery/atmospherics/proc/get_neighbor_nodes_for_init()
return null
// Called on construction (i.e from pipe item) but not on initialization
/obj/machinery/atmospherics/proc/on_construction(obj_color, set_layer)
pipe_color = obj_color
setPipingLayer(set_layer)
// TODO - M.connect_types = src.connect_types - Or otherwise copy from item? Or figure it out from piping layer?
var/turf/T = get_turf(src)
level = !T.is_plating() ? 2 : 1
atmos_init()
if(QDELETED(src))
return // TODO - Eventually should get rid of the need for this.
build_network()
var/list/nodes = get_neighbor_nodes_for_init()
for(var/obj/machinery/atmospherics/A in nodes)
A.atmos_init()
A.build_network()
// TODO - Should we do src.build_network() before or after the nodes?
// We've historically done before, but /tg does after. TODO research if there is a difference.
// This sets our piping layer. Hopefully its cool.
/obj/machinery/atmospherics/proc/setPipingLayer(new_layer)
if(pipe_flags & (PIPING_DEFAULT_LAYER_ONLY|PIPING_ALL_LAYER))
new_layer = PIPING_LAYER_DEFAULT
piping_layer = new_layer
// Do it the Polaris way
switch(piping_layer)
if(PIPING_LAYER_SCRUBBER)
icon_state = "[icon_state]-scrubbers"
connect_types = CONNECT_TYPE_SCRUBBER
layer = 2.38
icon_connect_type = "-scrubbers"
if(PIPING_LAYER_SUPPLY)
icon_state = "[icon_state]-supply"
connect_types = CONNECT_TYPE_SUPPLY
layer = 2.39
icon_connect_type = "-supply"
if(pipe_flags & PIPING_ALL_LAYER)
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER
// Or if we were to do it the TG way...
// pixel_x = PIPE_PIXEL_OFFSET_X(piping_layer)
// pixel_y = PIPE_PIXEL_OFFSET_Y(piping_layer)
// layer = initial(layer) + PIPE_LAYER_OFFSET(piping_layer)
@@ -30,6 +30,9 @@
initialize_directions = EAST|WEST
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/binary/get_neighbor_nodes_for_init()
return list(node1, node2)
/obj/machinery/atmospherics/binary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
@@ -64,17 +67,8 @@
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))
if (check_connect_types(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))
if (check_connect_types(target,src))
node2 = target
break
STANDARD_ATMOS_CHOOSE_NODE(1, node1_connect)
STANDARD_ATMOS_CHOOSE_NODE(2, node2_connect)
update_icon()
update_underlays()
@@ -9,6 +9,7 @@
icon = 'icons/obj/pipes.dmi'
icon_state = "circ-off"
anchored = 0
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/kinetic_efficiency = 0.04 //combined kinetic and kinetic-to-electric efficiency
var/volume_ratio = 0.2
@@ -24,6 +24,7 @@
idle_power_usage = 150 //internal circuitry, friction losses and stuff
power_rating = 7500 //7500 W ~ 10 HP
pipe_flags = PIPING_ALL_LAYER
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER //connects to regular, supply and scrubbers pipes
var/pump_direction = 1 //0 = siphoning, 1 = releasing
@@ -5,6 +5,8 @@
/obj/machinery/atmospherics/binary/passive_gate
icon = 'icons/atmos/passive_gate.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/directional
pipe_state = "passivegate"
level = 1
name = "pressure regulator"
@@ -257,8 +259,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
#undef REGULATE_NONE
#undef REGULATE_INPUT
@@ -139,6 +139,9 @@
src.set_dir(turn(src.dir, 90))
//Goddamn copypaste from binary base class because atmospherics machinery API is not damn flexible
get_neighbor_nodes_for_init()
return list(node1, node2)
network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
@@ -15,6 +15,8 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/binary/pump
icon = 'icons/atmos/pump.dmi'
icon_state = "map_off"
construction_type = /obj/item/pipe/directional
pipe_state = "pump"
level = 1
name = "gas pump"
@@ -236,5 +238,4 @@ Thus, the two variables affect pump operation are set in New():
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/binary/pump/high_power
icon = 'icons/atmos/volume_pump.dmi'
icon_state = "map_off"
construction_type = /obj/item/pipe/directional
pipe_state = "volumepump"
level = 1
name = "high power gas pump"
@@ -4,6 +4,7 @@
/obj/machinery/atmospherics/omni/atmos_filter
name = "omni gas filter"
icon_state = "map_filter"
pipe_state = "omni_filter"
var/list/atmos_filters = new()
var/datum/omni_port/input
@@ -4,6 +4,7 @@
/obj/machinery/atmospherics/omni/mixer
name = "omni gas mixer"
icon_state = "map_mixer"
pipe_state = "omni_mixer"
use_power = 1
idle_power_usage = 150 //internal circuitry, friction losses and stuff
@@ -7,6 +7,7 @@
icon_state = "base"
use_power = 1
initialize_directions = 0
construction_type = /obj/item/pipe/quaternary
level = 1
var/configuring = 0
@@ -93,8 +94,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/omni/can_unwrench()
var/int_pressure = 0
@@ -222,6 +222,11 @@
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/omni/get_neighbor_nodes_for_init()
var/list/neighbor_nodes = list()
for(var/datum/omni_port/P in ports)
neighbor_nodes += P.node
return neighbor_nodes
/obj/machinery/atmospherics/omni/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
for(var/datum/omni_port/P in ports)
@@ -252,10 +257,9 @@
if(P.node || P.mode == 0)
continue
for(var/obj/machinery/atmospherics/target in get_step(src, P.dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
P.node = target
break
if(can_be_node(target, 1))
P.node = target
break
for(var/datum/omni_port/P in ports)
P.update = 1
@@ -7,6 +7,9 @@
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_state = "connector"
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/obj/machinery/portable_atmospherics/connected_device
@@ -47,6 +50,9 @@
return 1
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/portables_connector/get_neighbor_nodes_for_init()
return list(node)
/obj/machinery/atmospherics/portables_connector/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node)
network = new_network
@@ -77,10 +83,9 @@
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node = target
break
if(can_be_node(target, 1))
node = target
break
update_icon()
update_underlays()
@@ -146,5 +151,4 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/trinary/atmos_filter
icon = 'icons/atmos/filter.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "filter"
density = 0
level = 1
@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/trinary/mixer
icon = 'icons/atmos/mixer.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "mixer"
density = 0
level = 1
@@ -133,6 +135,8 @@
//
obj/machinery/atmospherics/trinary/mixer/t_mixer
icon_state = "tmap"
construction_type = /obj/item/pipe/trinary // Can't flip a "T", its symmetrical
pipe_state = "t_mixer"
dir = SOUTH
initialize_directions = SOUTH|EAST|WEST
tee = TRUE
@@ -2,6 +2,7 @@
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = 0
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/mirrored = FALSE
var/tee = FALSE
@@ -64,10 +65,12 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/trinary/get_neighbor_nodes_for_init()
return list(node1, node2, node3)
/obj/machinery/atmospherics/trinary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
@@ -113,21 +116,9 @@
var/list/node_connects = get_node_connect_dirs()
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[1]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[2]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[3]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node3 = target
break
STANDARD_ATMOS_CHOOSE_NODE(1, node_connects[1])
STANDARD_ATMOS_CHOOSE_NODE(2, node_connects[2])
STANDARD_ATMOS_CHOOSE_NODE(3, node_connects[3])
update_icon()
update_underlays()
+11 -17
View File
@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/tvalve
icon = 'icons/atmos/tvalve.dmi'
icon_state = "map_tvalve0"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "mtvalve"
name = "manual switching valve"
desc = "A pipe valve"
@@ -12,6 +14,7 @@
var/state = 0 // 0 = go straight, 1 = go to side
var/mirrored = FALSE
var/tee = FALSE // Note: Tee not actually supported for T-valves: no sprites
// like a trinary component, node1 is input, node2 is side output, node3 is straight output
var/obj/machinery/atmospherics/node3
@@ -47,6 +50,9 @@
/obj/machinery/atmospherics/tvalve/init_dir()
initialize_directions = get_initialize_directions_trinary(dir, mirrored)
/obj/machinery/atmospherics/tvalve/get_neighbor_nodes_for_init()
return list(node1, node2, node3)
/obj/machinery/atmospherics/tvalve/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network_node1 = new_network
@@ -178,21 +184,9 @@
var/list/node_connects = get_node_connect_dirs()
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[1]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[2]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[3]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node3 = target
break
STANDARD_ATMOS_CHOOSE_NODE(1, node_connects[1])
STANDARD_ATMOS_CHOOSE_NODE(2, node_connects[2])
STANDARD_ATMOS_CHOOSE_NODE(3, node_connects[3])
update_icon()
update_underlays()
@@ -262,6 +256,7 @@
name = "digital switching valve"
desc = "A digitally controlled valve."
icon = 'icons/atmos/digital_tvalve.dmi'
pipe_state = "dtvalve"
var/frequency = 0
var/id = null
@@ -348,8 +343,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/tvalve/mirrored
icon_state = "map_tvalvem0"
@@ -38,18 +38,15 @@
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src, node_connect))
if(target.initialize_directions & get_dir(target, src))
if(can_be_node(target, 1))
node = target
break
//copied from pipe construction code since heaters/freezers don't use fittings and weren't doing this check - this all really really needs to be refactored someday.
//check that there are no incompatible pipes/machinery in our own location
for(var/obj/machinery/atmospherics/M in src.loc)
if(M != src && (M.initialize_directions & node_connect) && M.check_connect_types(M,src)) // matches at least one direction on either type of pipe & same connection type
node = null
break
if(check_for_obstacles())
node = null
update_icon()
if(node)
update_icon()
/obj/machinery/atmospherics/unary/freezer/update_icon()
if(node)
@@ -2,6 +2,7 @@
icon = 'icons/obj/atmospherics/heat_exchanger.dmi'
icon_state = "intact"
pipe_state = "heunary"
density = 1
name = "Heat Exchanger"
@@ -83,5 +84,4 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
@@ -39,18 +39,15 @@
//check that there is something to connect to
for(var/obj/machinery/atmospherics/target in get_step(src, node_connect))
if(target.initialize_directions & get_dir(target, src))
if(can_be_node(target, 1))
node = target
break
//copied from pipe construction code since heaters/freezers don't use fittings and weren't doing this check - this all really really needs to be refactored someday.
//check that there are no incompatible pipes/machinery in our own location
for(var/obj/machinery/atmospherics/M in src.loc)
if(M != src && (M.initialize_directions & node_connect) && M.check_connect_types(M,src)) // matches at least one direction on either type of pipe & same connection type
node = null
break
if(check_for_obstacles())
node = null
update_icon()
if(node)
update_icon()
/obj/machinery/atmospherics/unary/heater/update_icon()
@@ -5,6 +5,7 @@
/obj/machinery/atmospherics/unary/outlet_injector
icon = 'icons/atmos/injector.dmi'
icon_state = "map_injector"
pipe_state = "injector"
layer = 3
name = "air injector"
@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/unary
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
//layer = TURF_LAYER+0.1
var/datum/gas_mixture/air_contents
@@ -21,6 +23,9 @@
initialize_directions = dir
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/unary/get_neighbor_nodes_for_init()
return list(node)
/obj/machinery/atmospherics/unary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node)
network = new_network
@@ -48,10 +53,9 @@
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node = target
break
if(can_be_node(target, 1))
node = target
break
update_icon()
update_underlays()
@@ -93,4 +97,19 @@
update_icon()
update_underlays()
return null
return null
// Check if there are any other atmos machines in the same turf that will block this machine from initializing.
// Intended for use when a frame-constructable machine (i.e. not made from pipe fittings) wants to wrench down and connect.
// Returns TRUE if something is blocking, FALSE if its okay to continue.
/obj/machinery/atmospherics/unary/proc/check_for_obstacles()
for(var/obj/machinery/atmospherics/M in loc)
if((M.pipe_flags & pipe_flags & PIPING_ONE_PER_TURF)) //Only one dense/requires density object per tile, eg connectors/cryo/heater/coolers.
visible_message("<span class='warning'>\The [src]'s cannot be connected, something is hogging the tile!</span>")
return TRUE
if((M.piping_layer != piping_layer) && !((M.pipe_flags | flags) & PIPING_ALL_LAYER)) // Pipes on different layers can't block each other unless they are ALL_LAYER
continue
if(M.get_init_dirs() & get_init_dirs()) // matches at least one direction on either type of pipe
visible_message("<span class='warning'>\The [src]'s connector can't be connected, there is already a pipe at that location!</span>")
return TRUE
return FALSE
@@ -10,6 +10,7 @@
/obj/machinery/atmospherics/unary/vent_pump
icon = 'icons/atmos/vent_pump.dmi'
icon_state = "map_vent"
pipe_state = "uvent"
name = "Air Vent"
desc = "Has a valve and pump attached to it"
@@ -410,8 +411,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
#undef DEFAULT_PRESSURE_DELTA
@@ -1,6 +1,7 @@
/obj/machinery/atmospherics/unary/vent_scrubber
icon = 'icons/atmos/vent_scrubber.dmi'
icon_state = "map_scrubber_off"
pipe_state = "scrubber"
name = "Air Scrubber"
desc = "Has a valve and pump attached to it"
@@ -283,8 +284,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/unary/vent_scrubber/examine(mob/user)
if(..(user, 1))
+9 -12
View File
@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/valve
icon = 'icons/atmos/valve.dmi'
icon_state = "map_valve0"
construction_type = /obj/item/pipe/binary
pipe_state = "mvalve"
name = "manual valve"
desc = "A pipe valve"
@@ -45,6 +47,9 @@
if(EAST || WEST)
initialize_directions = EAST|WEST
/obj/machinery/atmospherics/valve/get_neighbor_nodes_for_init()
return list(node1, node2)
/obj/machinery/atmospherics/valve/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network_node1 = new_network
@@ -153,16 +158,8 @@
else if (!node2_dir)
node2_dir = direction
for(var/obj/machinery/atmospherics/target in get_step(src,node1_dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
STANDARD_ATMOS_CHOOSE_NODE(1, node1_dir)
STANDARD_ATMOS_CHOOSE_NODE(2, node2_dir)
build_network()
@@ -224,6 +221,7 @@
name = "digital valve"
desc = "A digitally controlled valve."
icon = 'icons/atmos/digital_valve.dmi'
pipe_state = "dvalve"
var/frequency = 0
var/id = null
@@ -306,8 +304,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/valve/examine(mob/user)
..()
+3
View File
@@ -92,6 +92,9 @@ obj/machinery/atmospherics/mains_pipe
else return 1
get_neighbor_nodes_for_init()
return nodes
disconnect()
..()
for(var/obj/machinery/atmospherics/pipe/mains_component/node in nodes)
+6 -4
View File
@@ -14,6 +14,9 @@
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_state = "cap"
var/obj/machinery/atmospherics/node
/obj/machinery/atmospherics/pipe/cap/init_dir()
@@ -56,10 +59,9 @@
/obj/machinery/atmospherics/pipe/cap/atmos_init()
for(var/obj/machinery/atmospherics/target in get_step(src, dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node = target
break
if (can_be_node(target, 1))
node = target
break
var/turf/T = src.loc // hide if turf is not intact
if(level == 1 && !T.is_plating()) hide(1)
+30 -2
View File
@@ -8,6 +8,10 @@
color = "#404040"
level = 2
connect_types = CONNECT_TYPE_HE
pipe_flags = PIPING_DEFAULT_LAYER_ONLY
construction_type = /obj/item/pipe/binary/bendable
pipe_state = "he"
layer = 2.41
var/initialize_directions_he
var/surface = 2 //surface area in m^2
@@ -27,6 +31,16 @@
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/init_dir()
..()
initialize_directions_he = initialize_directions // The auto-detection from /pipe is good enough for a simple HE pipe
initialize_directions = 0
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/get_init_dirs()
return ..() | initialize_directions_he
// Use initialize_directions_he to connect to neighbors instead.
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/can_be_node(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target)
if(!istype(target))
return FALSE
return (target.initialize_directions_he & get_dir(target,src)) && check_connectable(target) && target.check_connectable(src)
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/atmos_init()
normalize_dir()
@@ -41,11 +55,11 @@
node2_dir = direction
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,node1_dir))
if(target.initialize_directions_he & get_dir(target,src))
if(can_be_node(target, 1))
node1 = target
break
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,node2_dir))
if(target.initialize_directions_he & get_dir(target,src))
if(can_be_node(target, 2))
node2 = target
break
if(!node1 && !node2)
@@ -117,6 +131,8 @@
pipe_icon = "hejunction"
level = 2
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_HE
construction_type = /obj/item/pipe/directional
pipe_state = "junction"
minimum_temperature_difference = 300
thermal_conductivity = WALL_HEAT_TRANSFER_COEFFICIENT
@@ -136,6 +152,18 @@
initialize_directions = EAST
initialize_directions_he = WEST
// Allow ourselves to make connections to either HE or normal pipes depending on which node we are doing.
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction/can_be_node(obj/machinery/atmospherics/target, node_num)
var/target_initialize_directions
switch(node_num)
if(1)
target_initialize_directions = target.initialize_directions // Node1 is towards normal pipes
if(2)
var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/H = target
if(!istype(H))
return FALSE
target_initialize_directions = H.initialize_directions_he // Node2 is towards HE pies.
return (target_initialize_directions & get_dir(target,src)) && check_connectable(target) && target.check_connectable(src)
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction/atmos_init()
for(var/obj/machinery/atmospherics/target in get_step(src,initialize_directions))
+15 -15
View File
@@ -12,6 +12,9 @@
dir = SOUTH
initialize_directions = EAST|NORTH|WEST
construction_type = /obj/item/pipe/trinary
pipe_state = "manifold"
var/obj/machinery/atmospherics/node3
level = 1
@@ -116,11 +119,10 @@
for(var/direction in cardinal)
if(direction&connect_directions)
for(var/obj/machinery/atmospherics/target in get_step(src,direction))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
connect_directions &= ~direction
break
if (can_be_node(target, 1))
node1 = target
connect_directions &= ~direction
break
if (node1)
break
@@ -128,11 +130,10 @@
for(var/direction in cardinal)
if(direction&connect_directions)
for(var/obj/machinery/atmospherics/target in get_step(src,direction))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
connect_directions &= ~direction
break
if (can_be_node(target, 2))
node2 = target
connect_directions &= ~direction
break
if (node2)
break
@@ -140,11 +141,10 @@
for(var/direction in cardinal)
if(direction&connect_directions)
for(var/obj/machinery/atmospherics/target in get_step(src,direction))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node3 = target
connect_directions &= ~direction
break
if (can_be_node(target, 3))
node3 = target
connect_directions &= ~direction
break
if (node3)
break
+19 -20
View File
@@ -12,6 +12,9 @@
dir = SOUTH
initialize_directions = NORTH|SOUTH|EAST|WEST
construction_type = /obj/item/pipe/quaternary
pipe_state = "manifold4w"
var/obj/machinery/atmospherics/node3
var/obj/machinery/atmospherics/node4
@@ -127,29 +130,25 @@
/obj/machinery/atmospherics/pipe/manifold4w/atmos_init()
for(var/obj/machinery/atmospherics/target in get_step(src,1))
if(target.initialize_directions & 2)
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src, NORTH))
if (can_be_node(target, 1))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,2))
if(target.initialize_directions & 1)
if (check_connect_types(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src, SOUTH))
if (can_be_node(target, 2))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,4))
if(target.initialize_directions & 8)
if (check_connect_types(target,src))
node3 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src, EAST))
if (can_be_node(target, 3))
node3 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,8))
if(target.initialize_directions & 4)
if (check_connect_types(target,src))
node4 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src, WEST))
if (can_be_node(target, 4))
node4 = target
break
if(!node1 && !node2 && !node3 && !node4)
qdel(src)
+12 -7
View File
@@ -10,6 +10,8 @@
layer = 2.4 //under wires with their 2.44
use_power = 0
pipe_flags = 0 // Does not have PIPING_DEFAULT_LAYER_ONLY flag.
var/alert_pressure = 80*ONE_ATMOSPHERE
//minimum pressure before check_pressure(...) should be called
@@ -31,6 +33,10 @@
/obj/machinery/atmospherics/pipe/proc/pipeline_expansion()
return null
// For pipes this is the same as pipeline_expansion()
/obj/machinery/atmospherics/pipe/get_neighbor_nodes_for_init()
return pipeline_expansion()
/obj/machinery/atmospherics/pipe/proc/check_pressure(pressure)
//Return 1 if parent should continue checking other pipes
//Return null if parent should stop checking other pipes. Recall: qdel(src) will by default return null
@@ -69,7 +75,11 @@
qdel_null(parent)
if(air_temporary)
loc.assume_air(air_temporary)
for(var/obj/machinery/meter/meter in loc)
if(meter.target == src)
var/obj/item/pipe_meter/PM = new /obj/item/pipe_meter(loc)
meter.transfer_fingerprints_to(PM)
qdel(meter)
. = ..()
/obj/machinery/atmospherics/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
@@ -96,12 +106,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
for (var/obj/machinery/meter/meter in T)
if (meter.target == src)
new /obj/item/pipe_meter(T)
qdel(meter)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/pipe/proc/change_color(var/new_color)
//only pass valid pipe colors please ~otherwise your pipe will turn invisible
+19 -10
View File
@@ -13,6 +13,10 @@
dir = SOUTH
initialize_directions = SOUTH|NORTH
pipe_flags = PIPING_CARDINAL_AUTONORMALIZE
construction_type = /obj/item/pipe/binary/bendable
pipe_state = "simple"
var/minimum_temperature_difference = 300
var/thermal_conductivity = 0 //WALL_HEAT_TRANSFER_COEFFICIENT No
@@ -47,9 +51,13 @@
/obj/machinery/atmospherics/pipe/simple/init_dir()
switch(dir)
if(SOUTH || NORTH)
if(SOUTH)
initialize_directions = SOUTH|NORTH
if(EAST || WEST)
if(NORTH)
initialize_directions = SOUTH|NORTH
if(EAST)
initialize_directions = EAST|WEST
if(WEST)
initialize_directions = EAST|WEST
if(NORTHEAST)
initialize_directions = NORTH|EAST
@@ -124,15 +132,13 @@
node2_dir = direction
for(var/obj/machinery/atmospherics/target in get_step(src,node1_dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
if(can_be_node(target, 1))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
if(can_be_node(target, 2))
node2 = target
break
if(!node1 && !node2)
qdel(src)
@@ -248,6 +254,9 @@
icon = 'icons/obj/atmospherics/red_pipe.dmi'
icon_state = "intact"
construction_type = /obj/item/pipe/binary/bendable
pipe_state = "insulated"
minimum_temperature_difference = 10000
thermal_conductivity = 0
maximum_pressure = 1000*ONE_ATMOSPHERE
+4 -4
View File
@@ -14,6 +14,7 @@
level = 1
dir = SOUTH
initialize_directions = SOUTH
pipe_flags = PIPING_DEFAULT_LAYER_ONLY
density = 1
/obj/machinery/atmospherics/pipe/tank/New()
@@ -48,10 +49,9 @@
var/connect_direction = dir
for(var/obj/machinery/atmospherics/target in get_step(src,connect_direction))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
if (can_be_node(target, 1))
node1 = target
break
update_underlays()
+6
View File
@@ -6,6 +6,9 @@
desc = "An adapter for regular, supply and scrubbers pipes"
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER
icon_state = "map_universal"
pipe_flags = PIPING_ALL_LAYER|PIPING_CARDINAL_AUTONORMALIZE
construction_type = /obj/item/pipe/binary
pipe_state = "universal"
/obj/machinery/atmospherics/pipe/simple/visible/universal/update_icon(var/safety = 0)
if(!check_icon_cache())
@@ -41,6 +44,9 @@
desc = "An adapter for regular, supply and scrubbers pipes"
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER
icon_state = "map_universal"
pipe_flags = PIPING_ALL_LAYER|PIPING_CARDINAL_AUTONORMALIZE
construction_type = /obj/item/pipe/binary
pipe_state = "universal"
/obj/machinery/atmospherics/pipe/simple/hidden/universal/update_icon(var/safety = 0)
if(!check_icon_cache())
+6 -4
View File
@@ -14,6 +14,9 @@
dir = SOUTH
initialize_directions = SOUTH
pipe_flags = PIPING_DEFAULT_LAYER_ONLY
construction_type = /obj/item/pipe/directional
pipe_state = "passive vent"
var/build_killswitch = 1
@@ -58,10 +61,9 @@
var/connect_direction = dir
for(var/obj/machinery/atmospherics/target in get_step(src,connect_direction))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
if (can_be_node(target, 1))
node1 = target
break
update_icon()