first pass of cleanup

makes simple pipes more OOP
adjusts defines; puts them in __DEFINES/atmospherics.dm
adds DEVICE_TYPE_LOOP define, which is used in a bunch of the for loops
This commit is contained in:
duncathan
2015-08-16 23:10:57 -06:00
parent ad5f723890
commit 99234185de
33 changed files with 279 additions and 281 deletions
+44 -83
View File
@@ -3,41 +3,19 @@ So much of atmospherics.dm was used solely by components, so separating this mak
On top of that, now people can add component-speciic procs/vars if they want!
*/
#define UNARY 1
#define BINARY 2
#define TRINARY 3
#define AIR1 "a1"
#define AIR2 "a2"
#define AIR3 "a3"
#define PARENT1 "p1"
#define PARENT2 "p2"
#define PARENT3 "p3"
#define NODE1 "n1"
#define NODE2 "n2"
#define NODE3 "n3"
/obj/machinery/atmospherics/components/
var/welded //Used on pumps and scrubbers
var/showpipe = 0
var/device_type = 0//used for initialization stuff
//UNARY = 1
//BINARY = 2
//TRINARY = 3
var/list/obj/machinery/atmospherics/nodes = list()
var/list/datum/pipeline/parents = list()
var/list/datum/gas_mixture/airs = list()
/obj/machinery/atmospherics/components/New()
..()
for(var/I = 1; I <= device_type; I++)
for(DEVICE_TYPE_LOOP)
var/datum/gas_mixture/A = new
A.volume = 200
airs["a[I]"] = A
AIR_I = A
/*
Iconnery
*/
@@ -57,7 +35,7 @@ Iconnery
/obj/machinery/atmospherics/components/proc/update_icon_nopipes()
return
/obj/machinery/atmospherics/components/update_icon() //not working
/obj/machinery/atmospherics/components/update_icon()
update_icon_nopipes()
underlays.Cut()
@@ -66,9 +44,9 @@ Iconnery
var/connected = 0
for(var/I = 1; I <= device_type; I++) //adds intact pieces
if(nodes["n[I]"])
connected = icon_addintact(nodes["n[I]"], connected)
for(DEVICE_TYPE_LOOP) //adds intact pieces
if(NODE_I)
connected = icon_addintact(NODE_I, connected)
icon_addbroken(connected) //adds broken pieces
@@ -77,83 +55,66 @@ Iconnery
Pipenet stuff; housekeeping
*/
/obj/machinery/atmospherics/components/Destroy()
for(var/I = 1; I <= device_type; I++)
var/obj/machinery/atmospherics/N = nodes["n[I]"]
for(DEVICE_TYPE_LOOP)
var/obj/machinery/atmospherics/N = NODE_I
if(N)
N.disconnect(src)
nodes["n[I]"] = null
nullifyPipenet(parents["p[I]"])
NODE_I = null
nullifyPipenet(PARENT_I)
..()
/obj/machinery/atmospherics/components/atmosinit(var/list/node_connects)
for(var/I = 1; I <= device_type; I++)
for(var/obj/machinery/atmospherics/target in get_step(src,node_connects[I]))
if(target.initialize_directions & get_dir(target,src))
nodes["n[I]"] = target
break
/obj/machinery/atmospherics/components/atmosinit()
if(level == 2)
showpipe = 1
update_icon()
..()
/obj/machinery/atmospherics/components/construction()
..()
update_parents()
/obj/machinery/atmospherics/components/build_network()
for(var/I = 1; I <= device_type; I++)
if(!parents["p[I]"])
parents["p[I]"] = new /datum/pipeline()
var/datum/pipeline/P = parents["p[I]"]
for(DEVICE_TYPE_LOOP)
if(!PARENT_I)
PARENT_I = new /datum/pipeline()
var/datum/pipeline/P = PARENT_I
P.build_pipeline(src)
/obj/machinery/atmospherics/components/disconnect(obj/machinery/atmospherics/reference)
for(var/I = 1; I <= device_type; I++)
if(reference == nodes["n[I]"])
if(istype(nodes["n[I]"], /obj/machinery/atmospherics/pipe))
qdel(parents["p[I]"])
nodes["n[I]"] = null
break
update_icon()
/obj/machinery/atmospherics/components/nullifyPipenet(datum/pipeline/reference)
..()
for(var/I = 1; I <= device_type; I++)
if(reference == parents["p[I]"])
var/datum/pipeline/P = parents["p[I]"]
P.other_airs -= airs["a[I]"]
parents["p[I]"] = null
for(DEVICE_TYPE_LOOP)
if(reference == PARENT_I)
var/datum/pipeline/P = PARENT_I
P.other_airs -= AIR_I
PARENT_I = null
/obj/machinery/atmospherics/components/returnPipenetAir(datum/pipeline/reference)
for(var/I = 1; I <= device_type; I++)
if(reference == parents["p[I]"])
return airs["a[I]"]
for(DEVICE_TYPE_LOOP)
if(reference == PARENT_I)
return AIR_I
/obj/machinery/atmospherics/components/pipeline_expansion(datum/pipeline/reference)
if(reference)
for(var/I = 1; I <= device_type; I++)
if(parents["p[I]"] == reference)
return list(nodes["n[I]"])
for(DEVICE_TYPE_LOOP)
if(PARENT_I == reference)
return list(NODE_I)
else
var/list/obj/machinery/atmospherics/return_nodes = list()
for(var/I = 1; I <= device_type; I++)
return_nodes += nodes["n[I]"]
return return_nodes
return ..()
/obj/machinery/atmospherics/components/setPipenet(datum/pipeline/reference, obj/machinery/atmospherics/A)
for(var/I = 1; I <= device_type; I++)
if(A == nodes["n[I]"])
parents["p[I]"] = reference
for(DEVICE_TYPE_LOOP)
if(A == NODE_I)
PARENT_I = reference
break
/obj/machinery/atmospherics/components/returnPipenet(obj/machinery/atmospherics/A = nodes[NODE1]) //returns PARENT1 if called without argument
for(var/I = 1; I <= device_type; I++)
if(A == nodes["n[I]"])
return parents["p[I]"]
/obj/machinery/atmospherics/components/returnPipenet(obj/machinery/atmospherics/A = NODE1) //returns PARENT1 if called without argument
for(DEVICE_TYPE_LOOP)
if(A == NODE_I)
return PARENT_I
/obj/machinery/atmospherics/components/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
for(var/I = 1; I <= device_type; I++)
if(parents["p[I]"] == Old)
parents["p[I]"] = New
for(DEVICE_TYPE_LOOP)
if(PARENT_I == Old)
PARENT_I = New
/obj/machinery/atmospherics/components/unsafe_pressure_release(var/mob/user, var/pressures)
..()
@@ -164,15 +125,15 @@ Pipenet stuff; housekeeping
var/datum/gas_mixture/environment = T.return_air()
var/lost = null
var/times_lost = 0
for(var/I = 1; I <= device_type; I++)
var/datum/gas_mixture/air = airs["a[I]"]
for(DEVICE_TYPE_LOOP)
var/datum/gas_mixture/air = AIR_I
lost += pressures*environment.volume/(air.temperature * R_IDEAL_GAS_EQUATION)
times_lost++
var/shared_loss = lost/times_lost
var/datum/gas_mixture/to_release
for(var/I = 1; I <= device_type; I++)
var/datum/gas_mixture/air = airs["a[I]"]
for(DEVICE_TYPE_LOOP)
var/datum/gas_mixture/air = AIR_I
if(!to_release)
to_release = air.remove(shared_loss)
continue
@@ -195,6 +156,6 @@ Helpers
*/
/obj/machinery/atmospherics/components/proc/update_parents()
for(var/I = 1; I <= device_type; I++)
var/datum/pipeline/parent = parents["p[I]"]
for(DEVICE_TYPE_LOOP)
var/datum/pipeline/parent = PARENT_I
parent.update = 1