Files
CHOMPStation2/code/ATMOSPHERICS/datum_pipe_network.dm
Leshana a97a574278 Transformed the machinery processor into an StonedMC subsystem
* This is PHASE 1 of a multi-phase conversion.  In this first phase we implement the subsystem, but leave it processing the existing global list variables.  In the next phase we will switch to use datum variables in the subsystem.  The main reason for splitting into two phases is ease of code review; change the meaningful code without the hundreds of machines -> SSmachines.machinery substitutions.
* We did declare macros for adding/removing things to the processing lists, and convert everywhere to use the macros.
* Added var/is_processing to /datum to keep track of whether an instance is already in a processing list (prevents it being in the list twice!) and also debugging, making sure its not in two lists etc.
* NOTE: The global machines list is **no longer sorted** for performance reasons.  As far as I know, the only module that actually ever cared was cameras.   Our camera system already handles its own sorting in the cameranets anyway, so it should no longer be needed.
2017-12-29 15:31:59 -05:00

84 lines
2.6 KiB
Plaintext

var/global/list/datum/pipe_network/pipe_networks = list() // TODO - Move into SSmachines
/datum/pipe_network
var/list/datum/gas_mixture/gases = list() //All of the gas_mixtures continuously connected in this network
var/volume = 0 //caches the total volume for atmos machines to use in gas calculations
var/list/obj/machinery/atmospherics/normal_members = list()
var/list/datum/pipeline/line_members = list()
//membership roster to go through for updates and what not
var/update = 1
//var/datum/gas_mixture/air_transient = null
Destroy()
STOP_PROCESSING_PIPENET(src)
for(var/datum/pipeline/line_member in line_members)
line_member.network = null
for(var/obj/machinery/atmospherics/normal_member in normal_members)
normal_member.reassign_network(src, null)
gases.Cut() // Do not qdel the gases, we don't own them
return ..()
proc/process()
//Equalize gases amongst pipe if called for
if(update)
update = 0
reconcile_air() //equalize_gases(gases)
//Give pipelines their process call for pressure checking and what not. Have to remove pressure checks for the time being as pipes dont radiate heat - Mport
//for(var/datum/pipeline/line_member in line_members)
// line_member.process()
proc/build_network(obj/machinery/atmospherics/start_normal, obj/machinery/atmospherics/reference)
//Purpose: Generate membership roster
//Notes: Assuming that members will add themselves to appropriate roster in network_expand()
if(!start_normal)
qdel(src)
return
start_normal.network_expand(src, reference)
update_network_gases()
if((normal_members.len>0)||(line_members.len>0))
START_PROCESSING_PIPENET(src)
else
qdel(src)
proc/merge(datum/pipe_network/giver)
if(giver==src) return 0
normal_members |= giver.normal_members
line_members |= giver.line_members
for(var/obj/machinery/atmospherics/normal_member in giver.normal_members)
normal_member.reassign_network(giver, src)
for(var/datum/pipeline/line_member in giver.line_members)
line_member.network = src
update_network_gases()
return 1
proc/update_network_gases()
//Go through membership roster and make sure gases is up to date
gases = list()
volume = 0
for(var/obj/machinery/atmospherics/normal_member in normal_members)
var/result = normal_member.return_network_air(src)
if(result) gases += result
for(var/datum/pipeline/line_member in line_members)
gases += line_member.air
for(var/datum/gas_mixture/air in gases)
volume += air.volume
proc/reconcile_air()
equalize_gases(gases)