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