mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Went even farther in consolidation of trinary atmospherics.
- We can eliminate any overridden methods at all on flipped trinary devices by making a `mirrored` and `tee` variable! This allows us to do things like flip them without delete/spawning. - T-Valves are also basically trinary. Sadly they are not a subtype, so to share code with them I have to put it into an outside proc. But still worth it.
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
initialize_directions = SOUTH|NORTH|WEST
|
||||
use_power = 0
|
||||
|
||||
var/mirrored = FALSE
|
||||
var/tee = FALSE
|
||||
|
||||
var/datum/gas_mixture/air1
|
||||
var/datum/gas_mixture/air2
|
||||
var/datum/gas_mixture/air3
|
||||
@@ -25,15 +28,7 @@
|
||||
air3.volume = 200
|
||||
|
||||
/obj/machinery/atmospherics/trinary/init_dir()
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
initialize_directions = EAST|NORTH|SOUTH
|
||||
if(SOUTH)
|
||||
initialize_directions = SOUTH|WEST|NORTH
|
||||
if(EAST)
|
||||
initialize_directions = EAST|WEST|SOUTH
|
||||
if(WEST)
|
||||
initialize_directions = WEST|NORTH|EAST
|
||||
initialize_directions = get_initialize_directions_trinary(dir, mirrored, tee)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/update_underlays()
|
||||
if(..())
|
||||
@@ -55,6 +50,23 @@
|
||||
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.")
|
||||
new /obj/item/pipe(loc, make_from=src)
|
||||
qdel(src)
|
||||
|
||||
// Housekeeping and pipe network stuff below
|
||||
/obj/machinery/atmospherics/trinary/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
|
||||
if(reference == node1)
|
||||
@@ -93,10 +105,7 @@
|
||||
// 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()
|
||||
var/node1_connect = turn(dir, 180)
|
||||
var/node2_connect = turn(dir, -90)
|
||||
var/node3_connect = dir
|
||||
return list(node1_connect, node2_connect, node3_connect)
|
||||
return get_node_connect_dirs_trinary(dir, mirrored, tee)
|
||||
|
||||
/obj/machinery/atmospherics/trinary/atmos_init()
|
||||
if(node1 && node2 && node3)
|
||||
@@ -191,4 +200,58 @@
|
||||
|
||||
update_underlays()
|
||||
|
||||
return null
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user