mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 11:13:16 +00:00
* to_chat() replacement. * Revert calling target.init_dir() before connecting. * This change was added in https://github.com/PolarisSS13/Polaris/pull/3775 to counteract `dir` not being set prior to New() for dynamically loaded maps. The root cause was /atom/New() not calling _preloader.load(). Undoing the change now that /atom/New() is fixed. * The addition of the init_dir() proc itself however, is useful, because there ARE other times some atmos machinery will want to re-initialize its dir, specifically whenever it is rotated. * init_dir() must be called in the constructor of all atmospherics machines capable of connecting to another. Since it has to happen for ALL machines, lets move that call to /obj/machinery/atmospherics/New() * Rename /obj/machinery/atmospherics initialize() to atmos_init() * These days `initialize()` is used to handle general object initialization that is moved outside of New(). The node connection discovery of atmos machinery needs to happen after all that, and so needs to be in a separate proc. * Make sure to actually call atmos_init during system startup.
135 lines
3.0 KiB
Plaintext
135 lines
3.0 KiB
Plaintext
/obj/machinery/atmospherics/binary
|
|
dir = SOUTH
|
|
initialize_directions = SOUTH|NORTH
|
|
use_power = 1
|
|
|
|
var/datum/gas_mixture/air1
|
|
var/datum/gas_mixture/air2
|
|
|
|
var/datum/pipe_network/network1
|
|
var/datum/pipe_network/network2
|
|
|
|
/obj/machinery/atmospherics/binary/New()
|
|
..()
|
|
|
|
air1 = new
|
|
air2 = new
|
|
|
|
air1.volume = 200
|
|
air2.volume = 200
|
|
|
|
/obj/machinery/atmospherics/binary/init_dir()
|
|
switch(dir)
|
|
if(NORTH)
|
|
initialize_directions = NORTH|SOUTH
|
|
if(SOUTH)
|
|
initialize_directions = NORTH|SOUTH
|
|
if(EAST)
|
|
initialize_directions = EAST|WEST
|
|
if(WEST)
|
|
initialize_directions = EAST|WEST
|
|
|
|
// Housekeeping and pipe network stuff below
|
|
/obj/machinery/atmospherics/binary/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
|
|
|
|
if(new_network.normal_members.Find(src))
|
|
return 0
|
|
|
|
new_network.normal_members += src
|
|
|
|
return null
|
|
|
|
/obj/machinery/atmospherics/binary/Destroy()
|
|
. = ..()
|
|
|
|
if(node1)
|
|
node1.disconnect(src)
|
|
qdel(network1)
|
|
if(node2)
|
|
node2.disconnect(src)
|
|
qdel(network2)
|
|
|
|
node1 = null
|
|
node2 = null
|
|
|
|
/obj/machinery/atmospherics/binary/atmos_init()
|
|
if(node1 && node2)
|
|
return
|
|
|
|
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
|
|
|
|
update_icon()
|
|
update_underlays()
|
|
|
|
/obj/machinery/atmospherics/binary/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)
|
|
|
|
|
|
/obj/machinery/atmospherics/binary/return_network(obj/machinery/atmospherics/reference)
|
|
build_network()
|
|
|
|
if(reference==node1)
|
|
return network1
|
|
|
|
if(reference==node2)
|
|
return network2
|
|
|
|
return null
|
|
|
|
/obj/machinery/atmospherics/binary/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
|
|
|
|
return 1
|
|
|
|
/obj/machinery/atmospherics/binary/return_network_air(datum/pipe_network/reference)
|
|
var/list/results = list()
|
|
|
|
if(network1 == reference)
|
|
results += air1
|
|
if(network2 == reference)
|
|
results += air2
|
|
|
|
return results
|
|
|
|
/obj/machinery/atmospherics/binary/disconnect(obj/machinery/atmospherics/reference)
|
|
if(reference==node1)
|
|
qdel(network1)
|
|
node1 = null
|
|
|
|
else if(reference==node2)
|
|
qdel(network2)
|
|
node2 = null
|
|
|
|
update_icon()
|
|
update_underlays()
|
|
|
|
return null |