- Moved pipe construction defines into __defines/construction.dm

- Unified pipe *unwrenching* by creating a standard proc along with the `construction_type` var.
- Eliminated the pipe fitting name & icon_state lookup tables by adding `pipe_state` var on atmos machinery and referencing that.
    - Each pipe which can be made from a fitting object should override `pipe_state` with the icon state to be used on the pipe fitting object.
- Eliminated the giant switch statement of doom in pipe construction by delegating that work to `on_construction` proc.
    - To make this work, every pipe must implement `get_neighbor_nodes_for_init` which returns a list of nodes which should be re-initialized on that pipe's construction.
- Combined the SCRUBBERS, SUPPLY and REGULAR pipe fitting classes together by storing the `piping_layer` variable and using the `setPipingLayer` procs
- Standardized the code for searching for node neighbors into the `can_be_node` proc.
    - This proc is also improved in that is a mutual check, `check_connectable` is called on BOTH objects, so they have to mutually agree to connect as nodes. Eliminates lots of special edge case logic.
    - Updated all the `amos_init` procs to use `can_be_node`.  In the most common cases, even that boilerplate code is consolidated into the `STANDARD_ATMOS_CHOOSE_NODE` macro.
- Implemented `pipe_flags` which lets pipes declare (or override) certain requirements.
- Adds a "pipe_recipe" datum to help out things that construct pipes.  By taking it out of the dispenser, we open the road for multiple dispenser types.  No, no RPD yet.  Soon.
    - Enhances the pipe dispenser to operate on pipe recipe datums instead of hard coded lists of pipes it can construct.   These datums are also (partially) initialized from the pipe machine types themselves, reducing having to define stuff in multiple places.
    - Switched pipe dispenser UI to use browse().   Not a NanoUI, but makes it a bit prettier with low effort.
    - Changed pipe dispenser to use a button selector to switch between Regular/Scrubbers/Supply instead of having separate list items.
- Added icon states to HE pipes to support the "connected on neither side" state.
This commit is contained in:
Leshana
2018-03-04 14:40:16 -05:00
parent 2123255667
commit 63a1dd0143
45 changed files with 718 additions and 1519 deletions

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -5,6 +5,8 @@
/obj/machinery/atmospherics/binary/passive_gate
icon = 'icons/atmos/passive_gate.dmi'
icon_state = "map"
construction_type = /obj/item/pipe/directional
pipe_state = "passivegate"
level = 1
name = "pressure regulator"
@@ -257,8 +259,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
#undef REGULATE_NONE
#undef REGULATE_INPUT

View File

@@ -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

View File

@@ -15,6 +15,8 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/binary/pump
icon = 'icons/atmos/pump.dmi'
icon_state = "map_off"
construction_type = /obj/item/pipe/directional
pipe_state = "pump"
level = 1
name = "gas pump"
@@ -236,5 +238,4 @@ Thus, the two variables affect pump operation are set in New():
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -7,6 +7,7 @@
icon_state = "base"
use_power = 1
initialize_directions = 0
construction_type = /obj/item/pipe/quaternary
level = 1
var/configuring = 0
@@ -93,8 +94,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/omni/can_unwrench()
var/int_pressure = 0
@@ -222,6 +222,11 @@
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/omni/get_neighbor_nodes_for_init()
var/list/neighbor_nodes = list()
for(var/datum/omni_port/P in ports)
neighbor_nodes += P.node
return neighbor_nodes
/obj/machinery/atmospherics/omni/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
for(var/datum/omni_port/P in ports)
@@ -252,10 +257,9 @@
if(P.node || P.mode == 0)
continue
for(var/obj/machinery/atmospherics/target in get_step(src, P.dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
P.node = target
break
if(can_be_node(target, 1))
P.node = target
break
for(var/datum/omni_port/P in ports)
P.update = 1

View File

@@ -7,6 +7,9 @@
dir = SOUTH
initialize_directions = SOUTH
construction_type = /obj/item/pipe/directional
pipe_state = "connector"
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/obj/machinery/portable_atmospherics/connected_device
@@ -47,6 +50,9 @@
return 1
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/portables_connector/get_neighbor_nodes_for_init()
return list(node)
/obj/machinery/atmospherics/portables_connector/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node)
network = new_network
@@ -77,10 +83,9 @@
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node = target
break
if(can_be_node(target, 1))
node = target
break
update_icon()
update_underlays()
@@ -146,5 +151,4 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()

View File

@@ -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

View File

@@ -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

View File

@@ -2,6 +2,7 @@
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = 0
pipe_flags = PIPING_DEFAULT_LAYER_ONLY|PIPING_ONE_PER_TURF
var/mirrored = FALSE
var/tee = FALSE
@@ -64,10 +65,12 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/trinary/get_neighbor_nodes_for_init()
return list(node1, node2, node3)
/obj/machinery/atmospherics/trinary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network1 = new_network
@@ -113,21 +116,9 @@
var/list/node_connects = get_node_connect_dirs()
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[1]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[2]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[3]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node3 = target
break
STANDARD_ATMOS_CHOOSE_NODE(1, node_connects[1])
STANDARD_ATMOS_CHOOSE_NODE(2, node_connects[2])
STANDARD_ATMOS_CHOOSE_NODE(3, node_connects[3])
update_icon()
update_underlays()

View File

@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/tvalve
icon = 'icons/atmos/tvalve.dmi'
icon_state = "map_tvalve0"
construction_type = /obj/item/pipe/trinary/flippable
pipe_state = "mtvalve"
name = "manual switching valve"
desc = "A pipe valve"
@@ -12,6 +14,7 @@
var/state = 0 // 0 = go straight, 1 = go to side
var/mirrored = FALSE
var/tee = FALSE // Note: Tee not actually supported for T-valves: no sprites
// like a trinary component, node1 is input, node2 is side output, node3 is straight output
var/obj/machinery/atmospherics/node3
@@ -47,6 +50,9 @@
/obj/machinery/atmospherics/tvalve/init_dir()
initialize_directions = get_initialize_directions_trinary(dir, mirrored)
/obj/machinery/atmospherics/tvalve/get_neighbor_nodes_for_init()
return list(node1, node2, node3)
/obj/machinery/atmospherics/tvalve/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network_node1 = new_network
@@ -178,21 +184,9 @@
var/list/node_connects = get_node_connect_dirs()
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[1]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[2]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[3]))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node3 = target
break
STANDARD_ATMOS_CHOOSE_NODE(1, node_connects[1])
STANDARD_ATMOS_CHOOSE_NODE(2, node_connects[2])
STANDARD_ATMOS_CHOOSE_NODE(3, node_connects[3])
update_icon()
update_underlays()
@@ -262,6 +256,7 @@
name = "digital switching valve"
desc = "A digitally controlled valve."
icon = 'icons/atmos/digital_tvalve.dmi'
pipe_state = "dtvalve"
var/frequency = 0
var/id = null
@@ -348,8 +343,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/tvalve/mirrored
icon_state = "map_tvalvem0"

View File

@@ -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)

View File

@@ -2,6 +2,7 @@
icon = 'icons/obj/atmospherics/heat_exchanger.dmi'
icon_state = "intact"
pipe_state = "heunary"
density = 1
name = "Heat Exchanger"
@@ -83,5 +84,4 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()

View File

@@ -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()

View File

@@ -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"

View File

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

View File

@@ -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 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
#undef DEFAULT_PRESSURE_DELTA

View File

@@ -1,6 +1,7 @@
/obj/machinery/atmospherics/unary/vent_scrubber
icon = 'icons/atmos/vent_scrubber.dmi'
icon_state = "map_scrubber_off"
pipe_state = "scrubber"
name = "Air Scrubber"
desc = "Has a valve and pump attached to it"
@@ -283,8 +284,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/unary/vent_scrubber/examine(mob/user)
if(..(user, 1))

View File

@@ -1,6 +1,8 @@
/obj/machinery/atmospherics/valve
icon = 'icons/atmos/valve.dmi'
icon_state = "map_valve0"
construction_type = /obj/item/pipe/binary
pipe_state = "mvalve"
name = "manual valve"
desc = "A pipe valve"
@@ -45,6 +47,9 @@
if(EAST || WEST)
initialize_directions = EAST|WEST
/obj/machinery/atmospherics/valve/get_neighbor_nodes_for_init()
return list(node1, node2)
/obj/machinery/atmospherics/valve/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(reference == node1)
network_node1 = new_network
@@ -153,16 +158,8 @@
else if (!node2_dir)
node2_dir = direction
for(var/obj/machinery/atmospherics/target in get_step(src,node1_dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_dir))
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
STANDARD_ATMOS_CHOOSE_NODE(1, node1_dir)
STANDARD_ATMOS_CHOOSE_NODE(2, node2_dir)
build_network()
@@ -224,6 +221,7 @@
name = "digital valve"
desc = "A digitally controlled valve."
icon = 'icons/atmos/digital_valve.dmi'
pipe_state = "dvalve"
var/frequency = 0
var/id = null
@@ -306,8 +304,7 @@
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
new /obj/item/pipe(loc, make_from=src)
qdel(src)
deconstruct()
/obj/machinery/atmospherics/valve/examine(mob/user)
..()