diff --git a/code/ATMOSPHERICS/_atmos_setup.dm b/code/ATMOSPHERICS/_atmos_setup.dm
index f1f560a00d..6af102cf38 100644
--- a/code/ATMOSPHERICS/_atmos_setup.dm
+++ b/code/ATMOSPHERICS/_atmos_setup.dm
@@ -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)
diff --git a/code/ATMOSPHERICS/atmospherics.dm b/code/ATMOSPHERICS/atmospherics.dm
index 59163e1b82..940c5edf1c 100644
--- a/code/ATMOSPHERICS/atmospherics.dm
+++ b/code/ATMOSPHERICS/atmospherics.dm
@@ -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
\ No newline at end of file
+ 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)
diff --git a/code/ATMOSPHERICS/components/binary_devices/algae_generator_vr.dm b/code/ATMOSPHERICS/components/binary_devices/algae_generator_vr.dm
index 1429b9b30a..adafb2ed17 100644
--- a/code/ATMOSPHERICS/components/binary_devices/algae_generator_vr.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/algae_generator_vr.dm
@@ -14,6 +14,7 @@
idle_power_usage = 100 // Minimal lights to keep algae alive
active_power_usage = 5000 // Powerful grow lights to stimulate oxygen production
//power_rating = 7500 //7500 W ~ 10 HP
+ pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/list/stored_material = list(MATERIAL_ALGAE = 0, MATERIAL_CARBON = 0)
// Capacity increases with matter bin quality
diff --git a/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm b/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm
index 6e6662f39c..4698c613a9 100644
--- a/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm
@@ -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()
diff --git a/code/ATMOSPHERICS/components/binary_devices/circulator.dm b/code/ATMOSPHERICS/components/binary_devices/circulator.dm
index 68ce37d088..ff1089e6f8 100644
--- a/code/ATMOSPHERICS/components/binary_devices/circulator.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/circulator.dm
@@ -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
diff --git a/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm b/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
index 840d2bdf8b..d696aad039 100644
--- a/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
@@ -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
diff --git a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
index b4f25459c1..c08c82f6b9 100644
--- a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"You hear ratchet.")
- new /obj/item/pipe(loc, make_from=src)
- qdel(src)
+ deconstruct()
#undef REGULATE_NONE
#undef REGULATE_INPUT
diff --git a/code/ATMOSPHERICS/components/binary_devices/pipeturbine.dm b/code/ATMOSPHERICS/components/binary_devices/pipeturbine.dm
index b8c7883796..a7127a4dc6 100644
--- a/code/ATMOSPHERICS/components/binary_devices/pipeturbine.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/pipeturbine.dm
@@ -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
diff --git a/code/ATMOSPHERICS/components/binary_devices/pump.dm b/code/ATMOSPHERICS/components/binary_devices/pump.dm
index 6320ddf8a3..a89b1c5659 100644
--- a/code/ATMOSPHERICS/components/binary_devices/pump.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/pump.dm
@@ -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():
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"You hear ratchet.")
- new /obj/item/pipe(loc, make_from=src)
- qdel(src)
+ deconstruct()
diff --git a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
index 42b02282cc..b4493a1566 100644
--- a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
@@ -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"
diff --git a/code/ATMOSPHERICS/components/omni_devices/filter.dm b/code/ATMOSPHERICS/components/omni_devices/filter.dm
index 8710623dfd..57889c463e 100644
--- a/code/ATMOSPHERICS/components/omni_devices/filter.dm
+++ b/code/ATMOSPHERICS/components/omni_devices/filter.dm
@@ -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
diff --git a/code/ATMOSPHERICS/components/omni_devices/mixer.dm b/code/ATMOSPHERICS/components/omni_devices/mixer.dm
index 6340397870..c833b5bb2a 100644
--- a/code/ATMOSPHERICS/components/omni_devices/mixer.dm
+++ b/code/ATMOSPHERICS/components/omni_devices/mixer.dm
@@ -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
diff --git a/code/ATMOSPHERICS/components/omni_devices/omni_base.dm b/code/ATMOSPHERICS/components/omni_devices/omni_base.dm
index a469b4e9ee..0981ff6b44 100644
--- a/code/ATMOSPHERICS/components/omni_devices/omni_base.dm
+++ b/code/ATMOSPHERICS/components/omni_devices/omni_base.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"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
diff --git a/code/ATMOSPHERICS/components/portables_connector.dm b/code/ATMOSPHERICS/components/portables_connector.dm
index 6911288c93..7dca3f52d4 100644
--- a/code/ATMOSPHERICS/components/portables_connector.dm
+++ b/code/ATMOSPHERICS/components/portables_connector.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"You hear a ratchet.")
- new /obj/item/pipe(loc, make_from=src)
- qdel(src)
+ deconstruct()
diff --git a/code/ATMOSPHERICS/components/trinary_devices/filter.dm b/code/ATMOSPHERICS/components/trinary_devices/filter.dm
index 94924baedc..49cb05e9af 100755
--- a/code/ATMOSPHERICS/components/trinary_devices/filter.dm
+++ b/code/ATMOSPHERICS/components/trinary_devices/filter.dm
@@ -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
diff --git a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm
index 2a70fe1591..84c5d49daa 100644
--- a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm
+++ b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm
@@ -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
diff --git a/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm b/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm
index 79aa77dc6f..0a68f74c71 100644
--- a/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm
+++ b/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"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()
diff --git a/code/ATMOSPHERICS/components/tvalve.dm b/code/ATMOSPHERICS/components/tvalve.dm
index 2b64d6f5bb..b65c615174 100644
--- a/code/ATMOSPHERICS/components/tvalve.dm
+++ b/code/ATMOSPHERICS/components/tvalve.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"You hear a ratchet.")
- new /obj/item/pipe(loc, make_from=src)
- qdel(src)
+ deconstruct()
/obj/machinery/atmospherics/tvalve/mirrored
icon_state = "map_tvalvem0"
diff --git a/code/ATMOSPHERICS/components/unary/cold_sink.dm b/code/ATMOSPHERICS/components/unary/cold_sink.dm
index 5759c39dcf..07b0052910 100644
--- a/code/ATMOSPHERICS/components/unary/cold_sink.dm
+++ b/code/ATMOSPHERICS/components/unary/cold_sink.dm
@@ -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)
diff --git a/code/ATMOSPHERICS/components/unary/heat_exchanger.dm b/code/ATMOSPHERICS/components/unary/heat_exchanger.dm
index 8a7fba153a..ed4010f81e 100644
--- a/code/ATMOSPHERICS/components/unary/heat_exchanger.dm
+++ b/code/ATMOSPHERICS/components/unary/heat_exchanger.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"You hear a ratchet.")
- new /obj/item/pipe(loc, make_from=src)
- qdel(src)
+ deconstruct()
diff --git a/code/ATMOSPHERICS/components/unary/heat_source.dm b/code/ATMOSPHERICS/components/unary/heat_source.dm
index a1e933b96a..bc1aaae118 100644
--- a/code/ATMOSPHERICS/components/unary/heat_source.dm
+++ b/code/ATMOSPHERICS/components/unary/heat_source.dm
@@ -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()
diff --git a/code/ATMOSPHERICS/components/unary/outlet_injector.dm b/code/ATMOSPHERICS/components/unary/outlet_injector.dm
index 7c52cea895..9d980647a8 100644
--- a/code/ATMOSPHERICS/components/unary/outlet_injector.dm
+++ b/code/ATMOSPHERICS/components/unary/outlet_injector.dm
@@ -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"
diff --git a/code/ATMOSPHERICS/components/unary/unary_base.dm b/code/ATMOSPHERICS/components/unary/unary_base.dm
index 77b135cdc5..db395ad6fc 100644
--- a/code/ATMOSPHERICS/components/unary/unary_base.dm
+++ b/code/ATMOSPHERICS/components/unary/unary_base.dm
@@ -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
\ No newline at end of file
+ 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("\The [src]'s cannot be connected, something is hogging the tile!")
+ 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("\The [src]'s connector can't be connected, there is already a pipe at that location!")
+ return TRUE
+ return FALSE
diff --git a/code/ATMOSPHERICS/components/unary/vent_pump.dm b/code/ATMOSPHERICS/components/unary/vent_pump.dm
index 17da4afcf7..9338516343 100644
--- a/code/ATMOSPHERICS/components/unary/vent_pump.dm
+++ b/code/ATMOSPHERICS/components/unary/vent_pump.dm
@@ -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"
@@ -426,8 +427,7 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"You hear a ratchet.")
- new /obj/item/pipe(loc, make_from=src)
- qdel(src)
+ deconstruct()
#undef DEFAULT_PRESSURE_DELTA
diff --git a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm
index ad78f5a1f4..09b5fde7c1 100644
--- a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm
+++ b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"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))
diff --git a/code/ATMOSPHERICS/components/valve.dm b/code/ATMOSPHERICS/components/valve.dm
index 77aedf94e0..93e5da7c32 100644
--- a/code/ATMOSPHERICS/components/valve.dm
+++ b/code/ATMOSPHERICS/components/valve.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"You hear a ratchet.")
- new /obj/item/pipe(loc, make_from=src)
- qdel(src)
+ deconstruct()
/obj/machinery/atmospherics/valve/examine(mob/user)
..()
diff --git a/code/ATMOSPHERICS/mainspipe.dm b/code/ATMOSPHERICS/mainspipe.dm
index 1b0c617564..a38587baf5 100644
--- a/code/ATMOSPHERICS/mainspipe.dm
+++ b/code/ATMOSPHERICS/mainspipe.dm
@@ -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)
diff --git a/code/ATMOSPHERICS/pipes/cap.dm b/code/ATMOSPHERICS/pipes/cap.dm
index de81c60200..8e56319d69 100644
--- a/code/ATMOSPHERICS/pipes/cap.dm
+++ b/code/ATMOSPHERICS/pipes/cap.dm
@@ -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)
diff --git a/code/ATMOSPHERICS/pipes/he_pipes.dm b/code/ATMOSPHERICS/pipes/he_pipes.dm
index 8953739a9c..fe6580b1ce 100644
--- a/code/ATMOSPHERICS/pipes/he_pipes.dm
+++ b/code/ATMOSPHERICS/pipes/he_pipes.dm
@@ -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))
diff --git a/code/ATMOSPHERICS/pipes/manifold.dm b/code/ATMOSPHERICS/pipes/manifold.dm
index 1b9afd9c63..8df3b4326a 100644
--- a/code/ATMOSPHERICS/pipes/manifold.dm
+++ b/code/ATMOSPHERICS/pipes/manifold.dm
@@ -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
diff --git a/code/ATMOSPHERICS/pipes/manifold4w.dm b/code/ATMOSPHERICS/pipes/manifold4w.dm
index ba360eefd8..1bd556b3fb 100644
--- a/code/ATMOSPHERICS/pipes/manifold4w.dm
+++ b/code/ATMOSPHERICS/pipes/manifold4w.dm
@@ -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)
diff --git a/code/ATMOSPHERICS/pipes/pipe_base.dm b/code/ATMOSPHERICS/pipes/pipe_base.dm
index 94167e01f6..4e852ed0c8 100644
--- a/code/ATMOSPHERICS/pipes/pipe_base.dm
+++ b/code/ATMOSPHERICS/pipes/pipe_base.dm
@@ -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 @@
"\The [user] unfastens \the [src].", \
"You have unfastened \the [src].", \
"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
diff --git a/code/ATMOSPHERICS/pipes/simple.dm b/code/ATMOSPHERICS/pipes/simple.dm
index f676c1ac38..289e8b4274 100644
--- a/code/ATMOSPHERICS/pipes/simple.dm
+++ b/code/ATMOSPHERICS/pipes/simple.dm
@@ -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
diff --git a/code/ATMOSPHERICS/pipes/tank.dm b/code/ATMOSPHERICS/pipes/tank.dm
index 07ce8d5b71..c96f4ddf1d 100644
--- a/code/ATMOSPHERICS/pipes/tank.dm
+++ b/code/ATMOSPHERICS/pipes/tank.dm
@@ -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()
diff --git a/code/ATMOSPHERICS/pipes/universal.dm b/code/ATMOSPHERICS/pipes/universal.dm
index 1017751aa1..2d8bd09dff 100644
--- a/code/ATMOSPHERICS/pipes/universal.dm
+++ b/code/ATMOSPHERICS/pipes/universal.dm
@@ -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())
@@ -28,7 +31,7 @@
universal_underlays(node2)
else
universal_underlays(,dir)
- universal_underlays(dir, -180)
+ universal_underlays(,turn(dir, -180))
/obj/machinery/atmospherics/pipe/simple/visible/universal/update_underlays()
..()
@@ -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())
diff --git a/code/ATMOSPHERICS/pipes/vent.dm b/code/ATMOSPHERICS/pipes/vent.dm
index 74eebb29a1..4a1dc5696d 100644
--- a/code/ATMOSPHERICS/pipes/vent.dm
+++ b/code/ATMOSPHERICS/pipes/vent.dm
@@ -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()
diff --git a/code/__defines/construction.dm b/code/__defines/construction.dm
index 7aceb1ffc4..837ad7ed38 100644
--- a/code/__defines/construction.dm
+++ b/code/__defines/construction.dm
@@ -1,4 +1,6 @@
-
+//
+// Frame construction
+//
// Frame construction states
#define FRAME_PLACED 0 // Has been placed (can be anchored or not).
@@ -16,3 +18,44 @@
// Does the frame get built on the floor or a wall?
#define FRAME_STYLE_FLOOR "floor"
#define FRAME_STYLE_WALL "wall"
+
+//
+// Pipe Construction
+//
+
+//Construction Orientation Types - Each of these categories has a different selection of how pipes can rotate and flip. Used for RPD.
+#define PIPE_STRAIGHT 0 //2 directions: N/S, E/W
+#define PIPE_BENDABLE 1 //6 directions: N/S, E/W, N/E, N/W, S/E, S/W
+#define PIPE_TRINARY 2 //4 directions: N/E/S, E/S/W, S/W/N, W/N/E
+#define PIPE_TRIN_M 3 //8 directions: N->S+E, S->N+E, N->S+W, S->N+W, E->W+S, W->E+S, E->W+N, W->E+N
+#define PIPE_DIRECTIONAL 4 //4 directions: N, S, E, W
+#define PIPE_ONEDIR 5 //1 direction: N/S/E/W
+#define PIPE_UNARY_FLIPPABLE 6 //8 directions: N, S, E, W, N-flipped, S-flipped, E-flipped, W-flipped
+#define PIPE_TRIN_T 7 //8 directions: N->S+E, S->N+E, N->S+W, S->N+W, E->W+S, W->E+S, E->W+N, W->E+N
+
+// Pipe connectivity bit flags
+#define CONNECT_TYPE_REGULAR 1
+#define CONNECT_TYPE_SUPPLY 2
+#define CONNECT_TYPE_SCRUBBER 4
+#define CONNECT_TYPE_HE 8
+
+// We are based on the three named layers of supply, regular, and scrubber.
+#define PIPING_LAYER_SUPPLY 1
+#define PIPING_LAYER_REGULAR 2
+#define PIPING_LAYER_SCRUBBER 3
+#define PIPING_LAYER_DEFAULT PIPING_LAYER_REGULAR
+
+// Pipe flags
+#define PIPING_ALL_LAYER 1 //intended to connect with all layers, check for all instead of just one.
+#define PIPING_ONE_PER_TURF 2 //can only be built if nothing else with this flag is on the tile already.
+#define PIPING_DEFAULT_LAYER_ONLY 4 //can only exist at PIPING_LAYER_DEFAULT
+#define PIPING_CARDINAL_AUTONORMALIZE 8 //north/south east/west doesn't matter, auto normalize on build.
+
+// Macro for easy use of boilerplate code for searching for a valid node connection.
+#define STANDARD_ATMOS_CHOOSE_NODE(node_num, direction) \
+ for(var/obj/machinery/atmospherics/target in get_step(src, direction)) { \
+ if(can_be_node(target, node_num)) { \
+ node##node_num = target; \
+ break; \
+ } \
+ }
diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm
index f03e56e642..9c67a9bc5d 100644
--- a/code/game/machinery/pipe/construction.dm
+++ b/code/game/machinery/pipe/construction.dm
@@ -2,1317 +2,273 @@
Buildable pipes
Buildable meters
*/
-#define PIPE_SIMPLE_STRAIGHT 0
-#define PIPE_SIMPLE_BENT 1
-#define PIPE_HE_STRAIGHT 2
-#define PIPE_HE_BENT 3
-#define PIPE_CONNECTOR 4
-#define PIPE_MANIFOLD 5
-#define PIPE_JUNCTION 6
-#define PIPE_UVENT 7
-#define PIPE_MVALVE 8
-#define PIPE_PUMP 9
-#define PIPE_SCRUBBER 10
-#define PIPE_INSULATED_STRAIGHT 11
-#define PIPE_INSULATED_BENT 12
-#define PIPE_GAS_FILTER 13
-#define PIPE_GAS_MIXER 14
-#define PIPE_PASSIVE_GATE 15
-#define PIPE_VOLUME_PUMP 16
-#define PIPE_HEAT_EXCHANGE 17
-#define PIPE_MTVALVE 18
-#define PIPE_MANIFOLD4W 19
-#define PIPE_CAP 20
-///// Z-Level stuff
-#define PIPE_UP 21
-#define PIPE_DOWN 22
-///// Z-Level stuff
-#define PIPE_GAS_FILTER_M 23
-#define PIPE_GAS_MIXER_T 24
-#define PIPE_GAS_MIXER_M 25
-#define PIPE_OMNI_MIXER 26
-#define PIPE_OMNI_FILTER 27
-///// Supply, scrubbers and universal pipes
-#define PIPE_UNIVERSAL 28
-#define PIPE_SUPPLY_STRAIGHT 29
-#define PIPE_SUPPLY_BENT 30
-#define PIPE_SCRUBBERS_STRAIGHT 31
-#define PIPE_SCRUBBERS_BENT 32
-#define PIPE_SUPPLY_MANIFOLD 33
-#define PIPE_SCRUBBERS_MANIFOLD 34
-#define PIPE_SUPPLY_MANIFOLD4W 35
-#define PIPE_SCRUBBERS_MANIFOLD4W 36
-#define PIPE_SUPPLY_UP 37
-#define PIPE_SCRUBBERS_UP 38
-#define PIPE_SUPPLY_DOWN 39
-#define PIPE_SCRUBBERS_DOWN 40
-#define PIPE_SUPPLY_CAP 41
-#define PIPE_SCRUBBERS_CAP 42
-///// Mirrored T-valve ~ because I couldn't be bothered re-sorting all of the defines
-#define PIPE_MTVALVEM 43
-///// Digital Valves sit here because otherwise we're resorting every define.
-#define PIPE_DVALVE 44
-#define PIPE_DTVALVE 45
-#define PIPE_DTVALVEM 46
-
-#define PIPE_PASSIVE_VENT 47
/obj/item/pipe
name = "pipe"
- desc = "A pipe"
- var/pipe_type = 0
- //var/pipe_dir = 0
+ desc = "A pipe."
+ var/pipe_type
var/pipename
- var/connect_types = CONNECT_TYPE_REGULAR
force = 7
+ throwforce = 7
icon = 'icons/obj/pipe-item.dmi'
icon_state = "simple"
item_state = "buildpipe"
w_class = ITEMSIZE_NORMAL
level = 2
+ var/piping_layer = PIPING_LAYER_DEFAULT
+ var/dispenser_class // Tells the dispenser what orientations we support, so RPD can show previews.
-/obj/item/pipe/New(var/loc, var/pipe_type as num, var/dir as num, var/obj/machinery/atmospherics/make_from = null)
- ..()
- if (make_from)
- src.set_dir(make_from.dir)
- src.pipename = make_from.name
- if(make_from.req_access)
- src.req_access = make_from.req_access
- if(make_from.req_one_access)
- src.req_one_access = make_from.req_one_access
- color = make_from.pipe_color
- var/is_bent
- if (make_from.initialize_directions in list(NORTH|SOUTH, WEST|EAST))
- is_bent = 0
- else
- is_bent = 1
- if (istype(make_from, /obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction))
- src.pipe_type = PIPE_JUNCTION
- connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_HE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/heat_exchanging))
- src.pipe_type = PIPE_HE_STRAIGHT + is_bent
- connect_types = CONNECT_TYPE_HE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/insulated))
- src.pipe_type = PIPE_INSULATED_STRAIGHT + is_bent
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/visible/supply) || istype(make_from, /obj/machinery/atmospherics/pipe/simple/hidden/supply))
- src.pipe_type = PIPE_SUPPLY_STRAIGHT + is_bent
- connect_types = CONNECT_TYPE_SUPPLY
- src.color = PIPE_COLOR_BLUE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/visible/scrubbers) || istype(make_from, /obj/machinery/atmospherics/pipe/simple/hidden/scrubbers))
- src.pipe_type = PIPE_SCRUBBERS_STRAIGHT + is_bent
- connect_types = CONNECT_TYPE_SCRUBBER
- src.color = PIPE_COLOR_RED
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/visible/universal) || istype(make_from, /obj/machinery/atmospherics/pipe/simple/hidden/universal))
- src.pipe_type = PIPE_UNIVERSAL
- connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple))
- src.pipe_type = PIPE_SIMPLE_STRAIGHT + is_bent
- else if(istype(make_from, /obj/machinery/atmospherics/portables_connector))
- src.pipe_type = PIPE_CONNECTOR
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/manifold/visible/supply) || istype(make_from, /obj/machinery/atmospherics/pipe/manifold/hidden/supply))
- src.pipe_type = PIPE_SUPPLY_MANIFOLD
- connect_types = CONNECT_TYPE_SUPPLY
- src.color = PIPE_COLOR_BLUE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/manifold/visible/scrubbers) || istype(make_from, /obj/machinery/atmospherics/pipe/manifold/hidden/scrubbers))
- src.pipe_type = PIPE_SCRUBBERS_MANIFOLD
- connect_types = CONNECT_TYPE_SCRUBBER
- src.color = PIPE_COLOR_RED
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/manifold))
- src.pipe_type = PIPE_MANIFOLD
- else if(istype(make_from, /obj/machinery/atmospherics/unary/vent_pump))
- src.pipe_type = PIPE_UVENT
- else if(istype(make_from, /obj/machinery/atmospherics/valve/digital))
- src.pipe_type = PIPE_DVALVE
- else if(istype(make_from, /obj/machinery/atmospherics/valve))
- src.pipe_type = PIPE_MVALVE
- else if(istype(make_from, /obj/machinery/atmospherics/binary/pump/high_power))
- src.pipe_type = PIPE_VOLUME_PUMP
- else if(istype(make_from, /obj/machinery/atmospherics/binary/pump))
- src.pipe_type = PIPE_PUMP
- else if(istype(make_from, /obj/machinery/atmospherics/trinary/atmos_filter/m_filter))
- src.pipe_type = PIPE_GAS_FILTER_M
- else if(istype(make_from, /obj/machinery/atmospherics/trinary/mixer/t_mixer))
- src.pipe_type = PIPE_GAS_MIXER_T
- else if(istype(make_from, /obj/machinery/atmospherics/trinary/mixer/m_mixer))
- src.pipe_type = PIPE_GAS_MIXER_M
- else if(istype(make_from, /obj/machinery/atmospherics/trinary/atmos_filter))
- src.pipe_type = PIPE_GAS_FILTER
- else if(istype(make_from, /obj/machinery/atmospherics/trinary/mixer))
- src.pipe_type = PIPE_GAS_MIXER
- else if(istype(make_from, /obj/machinery/atmospherics/unary/vent_scrubber))
- src.pipe_type = PIPE_SCRUBBER
- else if(istype(make_from, /obj/machinery/atmospherics/binary/passive_gate))
- src.pipe_type = PIPE_PASSIVE_GATE
- else if(istype(make_from, /obj/machinery/atmospherics/unary/heat_exchanger))
- src.pipe_type = PIPE_HEAT_EXCHANGE
- else if(istype(make_from, /obj/machinery/atmospherics/tvalve/digital/mirrored))
- src.pipe_type = PIPE_DTVALVEM
- else if(istype(make_from, /obj/machinery/atmospherics/tvalve/mirrored))
- src.pipe_type = PIPE_MTVALVEM
- else if(istype(make_from, /obj/machinery/atmospherics/tvalve/digital))
- src.pipe_type = PIPE_DTVALVE
- else if(istype(make_from, /obj/machinery/atmospherics/tvalve))
- src.pipe_type = PIPE_MTVALVE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/manifold4w/visible/supply) || istype(make_from, /obj/machinery/atmospherics/pipe/manifold4w/hidden/supply))
- src.pipe_type = PIPE_SUPPLY_MANIFOLD4W
- connect_types = CONNECT_TYPE_SUPPLY
- src.color = PIPE_COLOR_BLUE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/manifold4w/visible/scrubbers) || istype(make_from, /obj/machinery/atmospherics/pipe/manifold4w/hidden/scrubbers))
- src.pipe_type = PIPE_SCRUBBERS_MANIFOLD4W
- connect_types = CONNECT_TYPE_SCRUBBER
- src.color = PIPE_COLOR_RED
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/manifold4w))
- src.pipe_type = PIPE_MANIFOLD4W
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/cap/visible/supply) || istype(make_from, /obj/machinery/atmospherics/pipe/cap/hidden/supply))
- src.pipe_type = PIPE_SUPPLY_CAP
- connect_types = CONNECT_TYPE_SUPPLY
- src.color = PIPE_COLOR_BLUE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/cap/visible/scrubbers) || istype(make_from, /obj/machinery/atmospherics/pipe/cap/hidden/scrubbers))
- src.pipe_type = PIPE_SCRUBBERS_CAP
- connect_types = CONNECT_TYPE_SCRUBBER
- src.color = PIPE_COLOR_RED
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/cap))
- src.pipe_type = PIPE_CAP
- else if(istype(make_from, /obj/machinery/atmospherics/omni/mixer))
- src.pipe_type = PIPE_OMNI_MIXER
- else if(istype(make_from, /obj/machinery/atmospherics/omni/atmos_filter))
- src.pipe_type = PIPE_OMNI_FILTER
-///// Z-Level stuff
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/zpipe/up/supply))
- src.pipe_type = PIPE_SUPPLY_UP
- connect_types = CONNECT_TYPE_SUPPLY
- src.color = PIPE_COLOR_BLUE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/zpipe/up/scrubbers))
- src.pipe_type = PIPE_SCRUBBERS_UP
- connect_types = CONNECT_TYPE_SCRUBBER
- src.color = PIPE_COLOR_RED
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/zpipe/up))
- src.pipe_type = PIPE_UP
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/zpipe/down/supply))
- src.pipe_type = PIPE_SUPPLY_DOWN
- connect_types = CONNECT_TYPE_SUPPLY
- src.color = PIPE_COLOR_BLUE
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/zpipe/down/scrubbers))
- src.pipe_type = PIPE_SCRUBBERS_DOWN
- connect_types = CONNECT_TYPE_SCRUBBER
- src.color = PIPE_COLOR_RED
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/zpipe/down))
- src.pipe_type = PIPE_DOWN
-///// Z-Level stuff
- else if(istype(make_from, /obj/machinery/atmospherics/pipe/vent))
- src.pipe_type = PIPE_PASSIVE_VENT
+// One subtype for each way components connect to neighbors
+/obj/item/pipe/directional
+ dispenser_class = PIPE_DIRECTIONAL
+/obj/item/pipe/binary
+ dispenser_class = PIPE_STRAIGHT
+/obj/item/pipe/binary/bendable
+ dispenser_class = PIPE_BENDABLE
+/obj/item/pipe/trinary
+ dispenser_class = PIPE_TRINARY
+/obj/item/pipe/trinary/flippable
+ dispenser_class = PIPE_TRIN_M
+ var/mirrored = FALSE
+/obj/item/pipe/quaternary
+ dispenser_class = PIPE_ONEDIR
+
+/**
+ * Call constructor with:
+ * @param loc Location
+ * @pipe_type
+ */
+/obj/item/pipe/initialize(var/mapload, var/_pipe_type, var/_dir, var/obj/machinery/atmospherics/make_from)
+ if(make_from)
+ make_from_existing(make_from)
else
- src.pipe_type = pipe_type
- src.set_dir(dir)
- if (pipe_type == 29 || pipe_type == 30 || pipe_type == 33 || pipe_type == 35 || pipe_type == 37 || pipe_type == 39 || pipe_type == 41)
- connect_types = CONNECT_TYPE_SUPPLY
- src.color = PIPE_COLOR_BLUE
- else if (pipe_type == 31 || pipe_type == 32 || pipe_type == 34 || pipe_type == 36 || pipe_type == 38 || pipe_type == 40 || pipe_type == 42)
- connect_types = CONNECT_TYPE_SCRUBBER
- src.color = PIPE_COLOR_RED
- else if (pipe_type == 2 || pipe_type == 3)
- connect_types = CONNECT_TYPE_HE
- else if (pipe_type == 6)
- connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_HE
- else if (pipe_type == 28)
- connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER
- //src.pipe_dir = get_pipe_dir()
- update()
- src.pixel_x = rand(-5, 5)
- src.pixel_y = rand(-5, 5)
+ pipe_type = _pipe_type
+ set_dir(_dir)
-//update the name and icon of the pipe item depending on the type
+ update()
+ pixel_x += rand(-5, 5)
+ pixel_y += rand(-5, 5)
+ return ..()
+
+/obj/item/pipe/proc/make_from_existing(obj/machinery/atmospherics/make_from)
+ set_dir(make_from.dir)
+ pipename = make_from.name
+ if(make_from.req_access)
+ src.req_access = make_from.req_access
+ if(make_from.req_one_access)
+ src.req_one_access = make_from.req_one_access
+ color = make_from.pipe_color
+ pipe_type = make_from.type
+
+/obj/item/pipe/trinary/flippable/make_from_existing(obj/machinery/atmospherics/trinary/make_from)
+ ..()
+ if(make_from.mirrored)
+ do_a_flip()
+
+/obj/item/pipe/dropped()
+ if(loc)
+ setPipingLayer(piping_layer)
+ return ..()
+
+/obj/item/pipe/proc/setPipingLayer(new_layer = PIPING_LAYER_DEFAULT)
+ var/obj/machinery/atmospherics/fakeA = pipe_type
+ if(initial(fakeA.pipe_flags) & (PIPING_ALL_LAYER|PIPING_DEFAULT_LAYER_ONLY))
+ new_layer = PIPING_LAYER_DEFAULT
+ piping_layer = new_layer
+ // Do it the Polaris way
+ switch(piping_layer)
+ if(PIPING_LAYER_SCRUBBER)
+ color = PIPE_COLOR_RED
+ name = "[initial(fakeA.name)] scrubber fitting"
+ if(PIPING_LAYER_SUPPLY)
+ color = PIPE_COLOR_BLUE
+ name = "[initial(fakeA.name)] supply fitting"
+ // 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)
/obj/item/pipe/proc/update()
- var/list/nlist = list( \
- "pipe", \
- "bent pipe", \
- "h/e pipe", \
- "bent h/e pipe", \
- "connector", \
- "manifold", \
- "junction", \
- "uvent", \
- "mvalve", \
- "pump", \
- "scrubber", \
- "insulated pipe", \
- "bent insulated pipe", \
- "gas filter", \
- "gas mixer", \
- "pressure regulator", \
- "high power pump", \
- "heat exchanger", \
- "t-valve", \
- "4-way manifold", \
- "pipe cap", \
-///// Z-Level stuff
- "pipe up", \
- "pipe down", \
-///// Z-Level stuff
- "gas filter m", \
- "gas mixer t", \
- "gas mixer m", \
- "omni mixer", \
- "omni filter", \
-///// Supply and scrubbers pipes
- "universal pipe adapter", \
- "supply pipe", \
- "bent supply pipe", \
- "scrubbers pipe", \
- "bent scrubbers pipe", \
- "supply manifold", \
- "scrubbers manifold", \
- "supply 4-way manifold", \
- "scrubbers 4-way manifold", \
- "supply pipe up", \
- "scrubbers pipe up", \
- "supply pipe down", \
- "scrubbers pipe down", \
- "supply pipe cap", \
- "scrubbers pipe cap", \
- "t-valve m", \
- "dvalve", \
- "dt-valve", \
- "dt-valve m", \
- "passive vent", \
- )
- name = nlist[pipe_type+1] + " fitting"
- var/list/islist = list( \
- "simple", \
- "simple", \
- "he", \
- "he", \
- "connector", \
- "manifold", \
- "junction", \
- "uvent", \
- "mvalve", \
- "pump", \
- "scrubber", \
- "insulated", \
- "insulated", \
- "filter", \
- "mixer", \
- "passivegate", \
- "volumepump", \
- "heunary", \
- "mtvalve", \
- "manifold4w", \
- "cap", \
-///// Z-Level stuff
- "cap", \
- "cap", \
-///// Z-Level stuff
- "m_filter", \
- "t_mixer", \
- "m_mixer", \
- "omni_mixer", \
- "omni_filter", \
-///// Supply and scrubbers pipes
- "universal", \
- "simple", \
- "simple", \
- "simple", \
- "simple", \
- "manifold", \
- "manifold", \
- "manifold4w", \
- "manifold4w", \
- "cap", \
- "cap", \
- "cap", \
- "cap", \
- "cap", \
- "cap", \
- "mtvalvem", \
- "dvalve", \
- "dtvalve", \
- "dtvalvem", \
- "passive vent", \
- )
- icon_state = islist[pipe_type + 1]
+ var/obj/machinery/atmospherics/fakeA = pipe_type
+ name = "[initial(fakeA.name)] fitting"
+ icon_state = initial(fakeA.pipe_state)
-//called when a turf is attacked with a pipe item
-/obj/item/pipe/afterattack(turf/simulated/floor/target, mob/user, proximity)
- if(!proximity) return
- if(istype(target))
- user.drop_from_inventory(src, target)
- else
- return ..()
+/obj/item/pipe/verb/flip()
+ set category = "Object"
+ set name = "Flip Pipe"
+ set src in view(1)
-// rotate the pipe item clockwise
+ if ( usr.stat || usr.restrained() || !usr.canmove )
+ return
+
+ do_a_flip()
+
+/obj/item/pipe/proc/do_a_flip()
+ set_dir(turn(dir, -180))
+ fixdir()
+
+/obj/item/pipe/trinary/flippable/do_a_flip()
+ // set_dir(turn(dir, flipped ? 45 : -45))
+ // TG has a magic icon set with the flipped versions in the diagonals.
+ // We may switch to this later, but for now gotta do some magic.
+ mirrored = !mirrored
+ var/obj/machinery/atmospherics/fakeA = pipe_type
+ icon_state = "[initial(fakeA.pipe_state)][mirrored ? "m" : ""]"
/obj/item/pipe/verb/rotate()
set category = "Object"
set name = "Rotate Pipe"
set src in view(1)
- if ( usr.stat || usr.restrained() )
+ if ( usr.stat || usr.restrained() || !usr.canmove )
return
- src.set_dir(turn(src.dir, -90))
-
- if (pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_SUPPLY_STRAIGHT, PIPE_SCRUBBERS_STRAIGHT, PIPE_UNIVERSAL, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
- if(dir==2)
- set_dir(1)
- else if(dir==8)
- set_dir(4)
- else if (pipe_type in list (PIPE_MANIFOLD4W, PIPE_SUPPLY_MANIFOLD4W, PIPE_SCRUBBERS_MANIFOLD4W))
- set_dir(2)
- //src.pipe_set_dir(get_pipe_dir())
- return
+ set_dir(turn(src.dir, -90)) // Rotate clockwise
+ fixdir()
/obj/item/pipe/Move()
- ..()
- if ((pipe_type in list (PIPE_SIMPLE_BENT, PIPE_SUPPLY_BENT, PIPE_SCRUBBERS_BENT, PIPE_HE_BENT, PIPE_INSULATED_BENT)) \
- && (src.dir in cardinal))
- src.set_dir(src.dir|turn(src.dir, 90))
- else if (pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_SUPPLY_STRAIGHT, PIPE_SCRUBBERS_STRAIGHT, PIPE_UNIVERSAL, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
- if(dir==2)
- set_dir(1)
- else if(dir==8)
- set_dir(4)
+ var/old_dir = dir
+ . = ..()
+ set_dir(old_dir) //pipes changing direction when moved is just annoying and buggy
+
+//Helper to clean up dir
+/obj/item/pipe/proc/fixdir()
return
-// returns all pipe's endpoints
+/obj/item/pipe/binary/fixdir()
+ if(dir == SOUTH)
+ set_dir(NORTH)
+ else if(dir == WEST)
+ set_dir(EAST)
-/obj/item/pipe/proc/get_pipe_dir()
- if (!dir)
- return 0
- var/flip = turn(dir, 180)
- var/cw = turn(dir, -90)
- var/acw = turn(dir, 90)
+/obj/item/pipe/trinary/flippable/fixdir()
+ if(dir in cornerdirs)
+ set_dir(turn(dir, 45))
- switch(pipe_type)
- if( PIPE_SIMPLE_STRAIGHT, \
- PIPE_INSULATED_STRAIGHT, \
- PIPE_HE_STRAIGHT, \
- PIPE_JUNCTION ,\
- PIPE_PUMP ,\
- PIPE_VOLUME_PUMP ,\
- PIPE_PASSIVE_GATE ,\
- PIPE_MVALVE, \
- PIPE_SUPPLY_STRAIGHT, \
- PIPE_SCRUBBERS_STRAIGHT, \
- PIPE_UNIVERSAL, \
- PIPE_DVALVE, \
- )
- return dir|flip
- if(PIPE_SIMPLE_BENT, PIPE_INSULATED_BENT, PIPE_HE_BENT, PIPE_SUPPLY_BENT, PIPE_SCRUBBERS_BENT)
- return dir //dir|acw
- if(PIPE_CONNECTOR,PIPE_UVENT,PIPE_SCRUBBER,PIPE_HEAT_EXCHANGE)
- return dir
- if(PIPE_MANIFOLD4W, PIPE_SUPPLY_MANIFOLD4W, PIPE_SCRUBBERS_MANIFOLD4W, PIPE_OMNI_MIXER, PIPE_OMNI_FILTER)
- return dir|flip|cw|acw
- if(PIPE_MANIFOLD, PIPE_SUPPLY_MANIFOLD, PIPE_SCRUBBERS_MANIFOLD)
- return flip|cw|acw
- if(PIPE_GAS_FILTER, PIPE_GAS_MIXER, PIPE_MTVALVE, PIPE_DTVALVE)
- return dir|flip|cw
- if(PIPE_GAS_FILTER_M, PIPE_GAS_MIXER_M, PIPE_MTVALVEM, PIPE_DTVALVEM)
- return dir|flip|acw
- if(PIPE_GAS_MIXER_T)
- return dir|cw|acw
- if(PIPE_CAP, PIPE_SUPPLY_CAP, PIPE_SCRUBBERS_CAP)
- return dir
-///// Z-Level stuff
- if(PIPE_UP,PIPE_DOWN,PIPE_SUPPLY_UP,PIPE_SUPPLY_DOWN,PIPE_SCRUBBERS_UP,PIPE_SCRUBBERS_DOWN)
- return dir
-///// Z-Level stuff
- if(PIPE_PASSIVE_VENT)
- return dir
- return 0
+/obj/item/pipe/attack_self(mob/user)
+ set_dir(turn(dir,-90))
+ fixdir()
-/obj/item/pipe/proc/get_pdir() //endpoints for regular pipes
-
- var/flip = turn(dir, 180)
-// var/cw = turn(dir, -90)
-// var/acw = turn(dir, 90)
-
- if (!(pipe_type in list(PIPE_HE_STRAIGHT, PIPE_HE_BENT, PIPE_JUNCTION)))
- return get_pipe_dir()
- switch(pipe_type)
- if(PIPE_HE_STRAIGHT,PIPE_HE_BENT)
- return 0
- if(PIPE_JUNCTION)
- return flip
- return 0
-
-// return the h_dir (heat-exchange pipes) from the type and the dir
-
-/obj/item/pipe/proc/get_hdir() //endpoints for h/e pipes
-
-// var/flip = turn(dir, 180)
-// var/cw = turn(dir, -90)
-
- switch(pipe_type)
- if(PIPE_HE_STRAIGHT)
- return get_pipe_dir()
- if(PIPE_HE_BENT)
- return get_pipe_dir()
- if(PIPE_JUNCTION)
- return dir
- else
- return 0
-
-/obj/item/pipe/attack_self(mob/user as mob)
- return rotate()
+//called when a turf is attacked with a pipe item
+/obj/item/pipe/afterattack(turf/simulated/floor/target, mob/user, proximity)
+ if(!proximity) return
+ if(istype(target) && user.canUnEquip(src))
+ user.drop_from_inventory(src, target)
+ else
+ return ..()
/obj/item/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
- ..()
- //*
- if (!istype(W, /obj/item/weapon/wrench))
- return ..()
- if (!isturf(src.loc))
- return 1
- if (pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_SUPPLY_STRAIGHT, PIPE_SCRUBBERS_STRAIGHT, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
- if(dir==2)
- set_dir(1)
- else if(dir==8)
- set_dir(4)
- else if (pipe_type in list(PIPE_MANIFOLD4W, PIPE_SUPPLY_MANIFOLD4W, PIPE_SCRUBBERS_MANIFOLD4W, PIPE_OMNI_MIXER, PIPE_OMNI_FILTER))
- set_dir(2)
- var/pipe_dir = get_pipe_dir()
+ if(iswrench(W))
+ return wrench_act(user, W)
+ return ..()
- for(var/obj/machinery/atmospherics/M in src.loc)
- if((M.initialize_directions & pipe_dir) && M.check_connect_types_construction(M,src)) // matches at least one direction on either type of pipe & same connection type
- user << "There is already a pipe of the same type at this location."
- return 1
+/obj/item/pipe/proc/wrench_act(var/mob/living/user, var/obj/item/weapon/wrench/W)
+ if(!isturf(loc))
+ return TRUE
+
+ add_fingerprint(user)
+ fixdir()
+
+ var/obj/machinery/atmospherics/fakeA = pipe_type
+ var/flags = initial(fakeA.pipe_flags)
+ for(var/obj/machinery/atmospherics/M in loc)
+ if((M.pipe_flags & flags & PIPING_ONE_PER_TURF)) //Only one dense/requires density object per tile, eg connectors/cryo/heater/coolers.
+ to_chat(user, "Something is hogging the tile!")
+ 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() & SSmachines.get_init_dirs(pipe_type, dir)) // matches at least one direction on either type of pipe
+ to_chat(user, "There is already a pipe at that location!")
+ return TRUE
// no conflicts found
- var/pipefailtext = "There's nothing to connect this pipe section to!" //(with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
-
- //TODO: Move all of this stuff into the various pipe constructors.
- switch(pipe_type)
- if(PIPE_SIMPLE_STRAIGHT, PIPE_SIMPLE_BENT)
- var/obj/machinery/atmospherics/pipe/simple/P = new( src.loc )
- P.pipe_color = color
- P.set_dir(src.dir)
- P.initialize_directions = pipe_dir
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- if (QDELETED(P))
- usr << pipefailtext
- return 1
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_SUPPLY_STRAIGHT, PIPE_SUPPLY_BENT)
- var/obj/machinery/atmospherics/pipe/simple/hidden/supply/P = new( src.loc )
- P.pipe_color = color
- P.set_dir(src.dir)
- P.initialize_directions = pipe_dir
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- if (QDELETED(P))
- usr << pipefailtext
- return 1
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_SCRUBBERS_STRAIGHT, PIPE_SCRUBBERS_BENT)
- var/obj/machinery/atmospherics/pipe/simple/hidden/scrubbers/P = new( src.loc )
- P.pipe_color = color
- P.set_dir(src.dir)
- P.initialize_directions = pipe_dir
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- if (QDELETED(P))
- usr << pipefailtext
- return 1
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_UNIVERSAL)
- var/obj/machinery/atmospherics/pipe/simple/hidden/universal/P = new( src.loc )
- P.pipe_color = color
- P.set_dir(src.dir)
- P.initialize_directions = pipe_dir
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- if (QDELETED(P))
- usr << pipefailtext
- return 1
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_HE_STRAIGHT, PIPE_HE_BENT)
- var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/P = new ( src.loc )
- P.set_dir(src.dir)
- P.initialize_directions = pipe_dir //this var it's used to know if the pipe is bent or not
- P.initialize_directions_he = pipe_dir
- P.atmos_init()
- if (QDELETED(P))
- usr << pipefailtext
- return 1
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_CONNECTOR) // connector
- var/obj/machinery/atmospherics/portables_connector/C = new( src.loc )
- C.set_dir(dir)
- C.initialize_directions = pipe_dir
- if (pipename)
- C.name = pipename
- var/turf/T = C.loc
- C.level = !T.is_plating() ? 2 : 1
- C.atmos_init()
- C.build_network()
- if (C.node)
- C.node.atmos_init()
- C.node.build_network()
-
-
- if(PIPE_MANIFOLD) //manifold
- var/obj/machinery/atmospherics/pipe/manifold/M = new( src.loc )
- M.pipe_color = color
- M.set_dir(dir)
- M.initialize_directions = pipe_dir
- //M.New()
- var/turf/T = M.loc
- M.level = !T.is_plating() ? 2 : 1
- M.atmos_init()
- if (QDELETED(M))
- usr << pipefailtext
- return 1
- M.build_network()
- if (M.node1)
- M.node1.atmos_init()
- M.node1.build_network()
- if (M.node2)
- M.node2.atmos_init()
- M.node2.build_network()
- if (M.node3)
- M.node3.atmos_init()
- M.node3.build_network()
-
- if(PIPE_SUPPLY_MANIFOLD) //manifold
- var/obj/machinery/atmospherics/pipe/manifold/hidden/supply/M = new( src.loc )
- M.pipe_color = color
- M.set_dir(dir)
- M.initialize_directions = pipe_dir
- //M.New()
- var/turf/T = M.loc
- M.level = !T.is_plating() ? 2 : 1
- M.atmos_init()
- if (!M)
- usr << "There's nothing to connect this manifold to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
- return 1
- M.build_network()
- if (M.node1)
- M.node1.atmos_init()
- M.node1.build_network()
- if (M.node2)
- M.node2.atmos_init()
- M.node2.build_network()
- if (M.node3)
- M.node3.atmos_init()
- M.node3.build_network()
-
- if(PIPE_SCRUBBERS_MANIFOLD) //manifold
- var/obj/machinery/atmospherics/pipe/manifold/hidden/scrubbers/M = new( src.loc )
- M.pipe_color = color
- M.set_dir(dir)
- M.initialize_directions = pipe_dir
- //M.New()
- var/turf/T = M.loc
- M.level = !T.is_plating() ? 2 : 1
- M.atmos_init()
- if (!M)
- usr << "There's nothing to connect this manifold to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
- return 1
- M.build_network()
- if (M.node1)
- M.node1.atmos_init()
- M.node1.build_network()
- if (M.node2)
- M.node2.atmos_init()
- M.node2.build_network()
- if (M.node3)
- M.node3.atmos_init()
- M.node3.build_network()
- M.node3.build_network()
-
- if(PIPE_MANIFOLD4W) //4-way manifold
- var/obj/machinery/atmospherics/pipe/manifold4w/M = new( src.loc )
- M.pipe_color = color
- M.set_dir(dir)
- M.initialize_directions = pipe_dir
- //M.New()
- var/turf/T = M.loc
- M.level = !T.is_plating() ? 2 : 1
- M.atmos_init()
- if (QDELETED(M))
- usr << pipefailtext
- return 1
- M.build_network()
- if (M.node1)
- M.node1.atmos_init()
- M.node1.build_network()
- if (M.node2)
- M.node2.atmos_init()
- M.node2.build_network()
- if (M.node3)
- M.node3.atmos_init()
- M.node3.build_network()
- if (M.node4)
- M.node4.atmos_init()
- M.node4.build_network()
-
- if(PIPE_SUPPLY_MANIFOLD4W) //4-way manifold
- var/obj/machinery/atmospherics/pipe/manifold4w/hidden/supply/M = new( src.loc )
- M.pipe_color = color
- M.set_dir(dir)
- M.initialize_directions = pipe_dir
- M.connect_types = src.connect_types
- //M.New()
- var/turf/T = M.loc
- M.level = !T.is_plating() ? 2 : 1
- M.atmos_init()
- if (!M)
- usr << "There's nothing to connect this manifold to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
- return 1
- M.build_network()
- if (M.node1)
- M.node1.atmos_init()
- M.node1.build_network()
- if (M.node2)
- M.node2.atmos_init()
- M.node2.build_network()
- if (M.node3)
- M.node3.atmos_init()
- M.node3.build_network()
- if (M.node4)
- M.node4.atmos_init()
- M.node4.build_network()
-
- if(PIPE_SCRUBBERS_MANIFOLD4W) //4-way manifold
- var/obj/machinery/atmospherics/pipe/manifold4w/hidden/scrubbers/M = new( src.loc )
- M.pipe_color = color
- M.set_dir(dir)
- M.initialize_directions = pipe_dir
- M.connect_types = src.connect_types
- //M.New()
- var/turf/T = M.loc
- M.level = !T.is_plating() ? 2 : 1
- M.atmos_init()
- if (!M)
- usr << "There's nothing to connect this manifold to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
- return 1
- M.build_network()
- if (M.node1)
- M.node1.atmos_init()
- M.node1.build_network()
- if (M.node2)
- M.node2.atmos_init()
- M.node2.build_network()
- if (M.node3)
- M.node3.atmos_init()
- M.node3.build_network()
- if (M.node4)
- M.node4.atmos_init()
- M.node4.build_network()
-
- if(PIPE_JUNCTION)
- var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction/P = new ( src.loc )
- P.set_dir(src.dir)
- P.initialize_directions = src.get_pdir()
- P.initialize_directions_he = src.get_hdir()
- P.atmos_init()
- if (QDELETED(P))
- usr << pipefailtext //"There's nothing to connect this pipe to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
- return 1
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_UVENT) //unary vent
- var/obj/machinery/atmospherics/unary/vent_pump/V = new( src.loc )
- V.set_dir(dir)
- V.initialize_directions = pipe_dir
- if (pipename)
- V.name = pipename
- var/turf/T = V.loc
- V.level = !T.is_plating() ? 2 : 1
- V.atmos_init()
- V.build_network()
- if (V.node)
- V.node.atmos_init()
- V.node.build_network()
-
- if(PIPE_MVALVE) //manual valve
- var/obj/machinery/atmospherics/valve/V = new( src.loc)
- V.set_dir(dir)
- V.initialize_directions = pipe_dir
- if (pipename)
- V.name = pipename
- var/turf/T = V.loc
- V.level = !T.is_plating() ? 2 : 1
- V.atmos_init()
- V.build_network()
- if (V.node1)
-// world << "[V.node1.name] is connected to valve, forcing it to update its nodes."
- V.node1.atmos_init()
- V.node1.build_network()
- if (V.node2)
-// world << "[V.node2.name] is connected to valve, forcing it to update its nodes."
- V.node2.atmos_init()
- V.node2.build_network()
-
- if(PIPE_PUMP) //gas pump
- var/obj/machinery/atmospherics/binary/pump/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_GAS_FILTER) //gas filter
- var/obj/machinery/atmospherics/trinary/atmos_filter/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if (P.node3)
- P.node3.atmos_init()
- P.node3.build_network()
-
- if(PIPE_GAS_MIXER) //gas mixer
- var/obj/machinery/atmospherics/trinary/mixer/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if (P.node3)
- P.node3.atmos_init()
- P.node3.build_network()
-
- if(PIPE_GAS_FILTER_M) //gas filter mirrored
- var/obj/machinery/atmospherics/trinary/atmos_filter/m_filter/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if (P.node3)
- P.node3.atmos_init()
- P.node3.build_network()
-
- if(PIPE_GAS_MIXER_T) //gas mixer-t
- var/obj/machinery/atmospherics/trinary/mixer/t_mixer/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if (P.node3)
- P.node3.atmos_init()
- P.node3.build_network()
-
- if(PIPE_GAS_MIXER_M) //gas mixer mirrored
- var/obj/machinery/atmospherics/trinary/mixer/m_mixer/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if (P.node3)
- P.node3.atmos_init()
- P.node3.build_network()
-
- if(PIPE_SCRUBBER) //scrubber
- var/obj/machinery/atmospherics/unary/vent_scrubber/S = new(src.loc)
- S.set_dir(dir)
- S.initialize_directions = pipe_dir
- if (pipename)
- S.name = pipename
- var/turf/T = S.loc
- S.level = !T.is_plating() ? 2 : 1
- S.atmos_init()
- S.build_network()
- if (S.node)
- S.node.atmos_init()
- S.node.build_network()
-
- if(PIPE_INSULATED_STRAIGHT, PIPE_INSULATED_BENT)
- var/obj/machinery/atmospherics/pipe/simple/insulated/P = new( src.loc )
- P.set_dir(src.dir)
- P.initialize_directions = pipe_dir
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- if (QDELETED(P))
- usr << pipefailtext
- return 1
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_MTVALVE) //manual t-valve
- var/obj/machinery/atmospherics/tvalve/V = new(src.loc)
- V.set_dir(dir)
- V.initialize_directions = pipe_dir
- if (pipename)
- V.name = pipename
- var/turf/T = V.loc
- V.level = !T.is_plating() ? 2 : 1
- V.atmos_init()
- V.build_network()
- if (V.node1)
- V.node1.atmos_init()
- V.node1.build_network()
- if (V.node2)
- V.node2.atmos_init()
- V.node2.build_network()
- if (V.node3)
- V.node3.atmos_init()
- V.node3.build_network()
-
- if(PIPE_MTVALVEM) //manual t-valve
- var/obj/machinery/atmospherics/tvalve/mirrored/V = new(src.loc)
- V.set_dir(dir)
- V.initialize_directions = pipe_dir
- if (pipename)
- V.name = pipename
- var/turf/T = V.loc
- V.level = !T.is_plating() ? 2 : 1
- V.atmos_init()
- V.build_network()
- if (V.node1)
- V.node1.atmos_init()
- V.node1.build_network()
- if (V.node2)
- V.node2.atmos_init()
- V.node2.build_network()
- if (V.node3)
- V.node3.atmos_init()
- V.node3.build_network()
-
- if(PIPE_CAP)
- var/obj/machinery/atmospherics/pipe/cap/C = new(src.loc)
- C.set_dir(dir)
- C.initialize_directions = pipe_dir
- C.atmos_init()
- C.build_network()
- if(C.node)
- C.node.atmos_init()
- C.node.build_network()
-
- if(PIPE_SUPPLY_CAP)
- var/obj/machinery/atmospherics/pipe/cap/hidden/supply/C = new(src.loc)
- C.set_dir(dir)
- C.initialize_directions = pipe_dir
- C.atmos_init()
- C.build_network()
- if(C.node)
- C.node.atmos_init()
- C.node.build_network()
-
- if(PIPE_SCRUBBERS_CAP)
- var/obj/machinery/atmospherics/pipe/cap/hidden/scrubbers/C = new(src.loc)
- C.set_dir(dir)
- C.initialize_directions = pipe_dir
- C.atmos_init()
- C.build_network()
- if(C.node)
- C.node.atmos_init()
- C.node.build_network()
-
- if(PIPE_PASSIVE_GATE) //passive gate
- var/obj/machinery/atmospherics/binary/passive_gate/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_VOLUME_PUMP) //volume pump
- var/obj/machinery/atmospherics/binary/pump/high_power/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-
- if(PIPE_HEAT_EXCHANGE) // heat exchanger
- var/obj/machinery/atmospherics/unary/heat_exchanger/C = new( src.loc )
- C.set_dir(dir)
- C.initialize_directions = pipe_dir
- if (pipename)
- C.name = pipename
- var/turf/T = C.loc
- C.level = !T.is_plating() ? 2 : 1
- C.atmos_init()
- C.build_network()
- if (C.node)
- C.node.atmos_init()
- C.node.build_network()
-
- if(PIPE_DVALVE) //digital valve
- var/obj/machinery/atmospherics/valve/digital/V = new( src.loc)
- if(src.req_access)
- V.req_access = src.req_access
- if(src.req_one_access)
- V.req_one_access = src.req_one_access
- V.set_dir(dir)
- V.initialize_directions = pipe_dir
- if (pipename)
- V.name = pipename
- var/turf/T = V.loc
- V.level = !T.is_plating() ? 2 : 1
- V.atmos_init()
- V.build_network()
- if (V.node1)
- V.node1.atmos_init()
- V.node1.build_network()
- if (V.node2)
- V.node2.atmos_init()
- V.node2.build_network()
-
- if(PIPE_DTVALVE) //digital t-valve
- var/obj/machinery/atmospherics/tvalve/digital/V = new(src.loc)
- if(src.req_access)
- V.req_access = src.req_access
- if(src.req_one_access)
- V.req_one_access = src.req_one_access
- V.set_dir(dir)
- V.initialize_directions = pipe_dir
- if (pipename)
- V.name = pipename
- var/turf/T = V.loc
- V.level = !T.is_plating() ? 2 : 1
- V.atmos_init()
- V.build_network()
- if (V.node1)
- V.node1.atmos_init()
- V.node1.build_network()
- if (V.node2)
- V.node2.atmos_init()
- V.node2.build_network()
- if (V.node3)
- V.node3.atmos_init()
- V.node3.build_network()
-
- if(PIPE_DTVALVEM) //mirrored digital t-valve
- var/obj/machinery/atmospherics/tvalve/digital/mirrored/V = new(src.loc)
- if(src.req_access)
- V.req_access = src.req_access
- if(src.req_one_access)
- V.req_one_access = src.req_one_access
- V.set_dir(dir)
- V.initialize_directions = pipe_dir
- if (pipename)
- V.name = pipename
- var/turf/T = V.loc
- V.level = !T.is_plating() ? 2 : 1
- V.atmos_init()
- V.build_network()
- if (V.node1)
- V.node1.atmos_init()
- V.node1.build_network()
- if (V.node2)
- V.node2.atmos_init()
- V.node2.build_network()
- if (V.node3)
- V.node3.atmos_init()
- V.node3.build_network()
-
-///// Z-Level stuff
- if(PIPE_UP)
- var/obj/machinery/atmospherics/pipe/zpipe/up/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if(PIPE_DOWN)
- var/obj/machinery/atmospherics/pipe/zpipe/down/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if(PIPE_SUPPLY_UP)
- var/obj/machinery/atmospherics/pipe/zpipe/up/supply/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if(PIPE_SUPPLY_DOWN)
- var/obj/machinery/atmospherics/pipe/zpipe/down/supply/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if(PIPE_SCRUBBERS_UP)
- var/obj/machinery/atmospherics/pipe/zpipe/up/scrubbers/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
- if(PIPE_SCRUBBERS_DOWN)
- var/obj/machinery/atmospherics/pipe/zpipe/down/scrubbers/P = new(src.loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- if (pipename)
- P.name = pipename
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
- if (P.node2)
- P.node2.atmos_init()
- P.node2.build_network()
-///// Z-Level stuff
- if(PIPE_OMNI_MIXER)
- var/obj/machinery/atmospherics/omni/mixer/P = new(loc)
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if(PIPE_OMNI_FILTER)
- var/obj/machinery/atmospherics/omni/atmos_filter/P = new(loc)
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if(PIPE_PASSIVE_VENT)
- var/obj/machinery/atmospherics/pipe/vent/P = new(loc)
- P.set_dir(dir)
- P.initialize_directions = pipe_dir
- var/turf/T = P.loc
- P.level = !T.is_plating() ? 2 : 1
- P.atmos_init()
- P.build_network()
- if (P.node1)
- P.node1.atmos_init()
- P.node1.build_network()
+ var/obj/machinery/atmospherics/A = new pipe_type(loc)
+ build_pipe(A)
+ // TODO - Evaluate and remove the "need at least one thing to connect to" thing ~Leshana
+ // With how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment.
+ if (QDELETED(A))
+ to_chat(user, "There's nothing to connect this pipe section to!")
+ return TRUE
+ transfer_fingerprints_to(A)
playsound(src, W.usesound, 50, 1)
user.visible_message( \
- "[user] fastens the [src].", \
- "You have fastened the [src].", \
- "You hear ratchet.")
- qdel(src) // remove the pipe item
+ "[user] fastens \the [src].", \
+ "You fasten \the [src].", \
+ "You hear ratcheting.")
- return
- //TODO: DEFERRED
+ qdel(src)
-// ensure that setterm() is called for a newly connected pipeline
+/obj/item/pipe/proc/build_pipe(obj/machinery/atmospherics/A)
+ A.set_dir(dir)
+ A.init_dir()
+ if(pipename)
+ A.name = pipename
+ if(req_access)
+ A.req_access = req_access
+ if(req_one_access)
+ A.req_one_access = req_one_access
+ A.on_construction(color, piping_layer)
+
+/obj/item/pipe/trinary/flippable/build_pipe(obj/machinery/atmospherics/trinary/T)
+ T.mirrored = mirrored
+ . = ..()
+
+// Lookup the initialize_directions for a given atmos machinery instance facing dir.
+// TODO - Right now this determines the answer by instantiating an instance and checking!
+// There has to be a better way... ~Leshana
+/datum/controller/subsystem/machines/proc/get_init_dirs(type, dir)
+ var/static/list/pipe_init_dirs_cache = list()
+ if(!pipe_init_dirs_cache[type])
+ pipe_init_dirs_cache[type] = list()
+
+ if(!pipe_init_dirs_cache[type]["[dir]"])
+ var/obj/machinery/atmospherics/temp = new type(null, FALSE, dir)
+ pipe_init_dirs_cache[type]["[dir]"] = temp.get_init_dirs()
+ qdel(temp)
+
+ return pipe_init_dirs_cache[type]["[dir]"]
+
+
+//
+// Meters are special - not like any other pipes or components
+//
+
/obj/item/pipe_meter
name = "meter"
- desc = "A meter that can be laid on pipes"
+ desc = "A meter that can be laid on pipes."
icon = 'icons/obj/pipe-item.dmi'
icon_state = "meter"
item_state = "buildpipe"
w_class = ITEMSIZE_LARGE
+ var/piping_layer = PIPING_LAYER_DEFAULT
/obj/item/pipe_meter/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
- ..()
+ if(iswrench(W))
+ return wrench_act(user, W)
+ return ..()
- if (!istype(W, /obj/item/weapon/wrench))
- return ..()
- if(!locate(/obj/machinery/atmospherics/pipe, src.loc))
- user << "You need to fasten it to a pipe"
- return 1
- new/obj/machinery/meter( src.loc )
+/obj/item/pipe_meter/proc/wrench_act(var/mob/living/user, var/obj/item/weapon/wrench/W)
+ var/obj/machinery/atmospherics/pipe/pipe
+ for(var/obj/machinery/atmospherics/pipe/P in loc)
+ if(P.piping_layer == piping_layer)
+ pipe = P
+ break
+ if(!pipe)
+ to_chat(user, "You need to fasten it to a pipe!")
+ return TRUE
+ new /obj/machinery/meter(loc, piping_layer)
playsound(src, W.usesound, 50, 1)
- user << "You have fastened the meter to the pipe"
+ to_chat(user, "You fasten the meter to the pipe.")
qdel(src)
-//not sure why these are necessary
-#undef PIPE_SIMPLE_STRAIGHT
-#undef PIPE_SIMPLE_BENT
-#undef PIPE_HE_STRAIGHT
-#undef PIPE_HE_BENT
-#undef PIPE_CONNECTOR
-#undef PIPE_MANIFOLD
-#undef PIPE_JUNCTION
-#undef PIPE_UVENT
-#undef PIPE_MVALVE
-#undef PIPE_PUMP
-#undef PIPE_SCRUBBER
-#undef PIPE_INSULATED_STRAIGHT
-#undef PIPE_INSULATED_BENT
-#undef PIPE_GAS_FILTER
-#undef PIPE_GAS_MIXER
-#undef PIPE_PASSIVE_GATE
-#undef PIPE_VOLUME_PUMP
-#undef PIPE_OUTLET_INJECT
-#undef PIPE_MTVALVE
-#undef PIPE_MTVALVEM
-#undef PIPE_GAS_FILTER_M
-#undef PIPE_GAS_MIXER_T
-#undef PIPE_GAS_MIXER_M
-#undef PIPE_SUPPLY_STRAIGHT
-#undef PIPE_SUPPLY_BENT
-#undef PIPE_SCRUBBERS_STRAIGHT
-#undef PIPE_SCRUBBERS_BENT
-#undef PIPE_SUPPLY_MANIFOLD
-#undef PIPE_SCRUBBERS_MANIFOLD
-#undef PIPE_UNIVERSAL
-//#undef PIPE_MANIFOLD4W
+
+/obj/item/pipe_meter/dropped()
+ . = ..()
+ if(loc)
+ setAttachLayer(piping_layer)
+
+/obj/item/pipe_meter/proc/setAttachLayer(new_layer = PIPING_LAYER_DEFAULT)
+ piping_layer = new_layer
diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm
index 8bc779adf3..6675a5ca15 100644
--- a/code/game/machinery/pipe/pipe_dispenser.dm
+++ b/code/game/machinery/pipe/pipe_dispenser.dm
@@ -6,74 +6,32 @@
anchored = 1
var/unwrenched = 0
var/wait = 0
+ var/p_layer = PIPING_LAYER_REGULAR
-/obj/machinery/pipedispenser/attack_hand(user as mob)
- if(..())
+// TODO - Its about time to make this NanoUI don't we think?
+/obj/machinery/pipedispenser/attack_hand(var/mob/user as mob)
+ if((. = ..()))
return
-///// Z-Level stuff
- var/dat = {"
-Regular pipes:
-Pipe
-Bent Pipe
-Manifold
-Digital Valve
-Manual Valve
-Pipe Cap
-4-Way Manifold
-Digital T-Valve
-Digital T-Valve - Mirrored
-Manual T-Valve
-Manual T-Valve - Mirrored
-Upward Pipe
-Downward Pipe
-Supply pipes:
-Pipe
-Bent Pipe
-Manifold
-Pipe Cap
-4-Way Manifold
-Upward Pipe
-Downward Pipe
-Scrubbers pipes:
-Pipe
-Bent Pipe
-Manifold
-Pipe Cap
-4-Way Manifold
-Upward Pipe
-Downward Pipe
-Devices:
-Universal pipe adapter
-Connector
-Unary Vent
-Passive Vent
-Gas Pump
-Pressure Regulator
-High Power Gas Pump
-Scrubber
-Meter
-Gas Filter
-Gas Filter - Mirrored
-Gas Mixer
-Gas Mixer - Mirrored
-Gas Mixer - T
-Omni Gas Mixer
-Omni Gas Filter
-Heat exchange:
-Pipe
-Bent Pipe
-Junction
-Heat Exchanger
-Insulated pipes:
-Pipe
-Bent Pipe
+ src.interact(user)
-"}
-///// Z-Level stuff
-//What number the make points to is in the define # at the top of construction.dm in same folder
+/obj/machinery/pipedispenser/interact(mob/user)
+ user.set_machine(src)
- user << browse("