Files
Bubberstation/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm
MrStonedOne bd6d51a0b5 Massive MC and subsystem rewrite
MC:
	No longer tracks a subsystem's cpu usage. This was basically worthless and took up space on the stat panel
	Can calculate wait down to a tenth of a decisecond to make it fps/world.ticklag agnostic
	Now allows subsystems to have a dynamic wait, that is based on a ratio of how long that subsystem has been taking to process(cost). (This system allows for upper and lower bounds, and an changeable cost delta for each subsystem)
	MC can now be told to init a zlevel

All Subsystems:
	Stats panel now allows child subsystems to pass it a message to add to its stats entry. All subsystems have been moved over to this system - This should cut down on subsystems having to copy and paste the stats proc in order to add to it
	All subsystems now properlly handle being given a zlevel in their init proc

Subsystem changes:
	Air:
		Added air to the dynamic wait subsystem. upper bound: 50, lower bound: 5, cost delta: 3 times process cost
		Air now fires 4 times faster when it can do so without lagging things up
		Pipenet has been merged into air
		Atmos machinery now processes with process_atmos(), ticked by air, not machinery.
		Hotspots (the fire object) are now object pooled
	Pipenet:
		Deleted, added to air
	Machinery:
		Moved all atmos calcualtions in all objects's process() to process_atmos().
	Lighting:
		Added Lighting to the dynamic wait subsystem. upper bound: 20, lower bound: 5, cost delta: 3 times process cost
	Ticker:
		Fixed ticker not updating the lobby panel when game start delayed
		Fixed the game start timer updating rapidly from queued fires when game start delay is removed
	Garbage/qdel:
		qdel will now limit its process time to 2ds a fire.
		qdel can now be given hints as a return to Destroy() as to what should be done with the object.
		the options are:
			queue: (default) this is the normal behavior.
			letmelive: old default to non-null/zero. does nothing with the object
			iwillgc: functionally the same as above, mainly to let people working with objects know that the object will not be queued for GC checking
			harddel: this will queue the object to be deleted without storing a soft reference, mainly to save locate() processing time.
			harddel_now: this will del() the object. To allow for a clean removal of every del() not in qdel
		All objects have been updated to the new system, harddel and iwillgc was not added to any new objects.
		Fixed some objects not GCing because they didn't properlly clear references in Destory()
		Fixed some objects getting qdel'ed preventing other objects from getting GCed because they did not null their reference to that object.
2015-04-29 02:00:25 -07:00

163 lines
3.8 KiB
Plaintext

/obj/machinery/atmospherics/binary
icon = 'icons/obj/atmospherics/binary_devices.dmi'
dir = SOUTH
initialize_directions = SOUTH|NORTH
use_power = 1
var/datum/gas_mixture/air1
var/datum/gas_mixture/air2
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/datum/pipeline/parent1
var/datum/pipeline/parent2
var/showpipe = 0
/obj/machinery/atmospherics/binary/New()
..()
air1 = new
air2 = new
air1.volume = 200
air2.volume = 200
/obj/machinery/atmospherics/binary/SetInitDirections()
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
//Separate this because we don't need to update pipe icons if we just are going to change the state
/obj/machinery/atmospherics/binary/proc/update_icon_nopipes()
return
/obj/machinery/atmospherics/binary/update_icon()
update_icon_nopipes()
underlays.Cut()
if(showpipe)
var/connected = 0
//Add intact pieces
if(node1)
connected = icon_addintact(node1, connected)
if(node2)
connected = icon_addintact(node2, connected)
//Add broken pieces
icon_addbroken(connected)
/obj/machinery/atmospherics/binary/hide(var/intact)
showpipe = !intact
update_icon()
..(intact)
// Housekeeping and pipe network stuff below
/obj/machinery/atmospherics/binary/Destroy()
if(node1)
node1.disconnect(src)
node1 = null
nullifyPipenet(parent1)
if(node2)
node2.disconnect(src)
node2 = null
nullifyPipenet(parent2)
..()
/obj/machinery/atmospherics/binary/atmosinit()
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))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
if(target.initialize_directions & get_dir(target,src))
node2 = target
break
if(level == 2)
showpipe = 1
update_icon()
..()
/obj/machinery/atmospherics/binary/construction()
..()
parent1.update = 1
parent2.update = 1
/obj/machinery/atmospherics/binary/build_network()
if(!parent1)
parent1 = new /datum/pipeline()
parent1.build_pipeline(src)
if(!parent2)
parent2 = new /datum/pipeline()
parent2.build_pipeline(src)
/obj/machinery/atmospherics/binary/disconnect(obj/machinery/atmospherics/reference)
if(reference == node1)
if(istype(node1, /obj/machinery/atmospherics/pipe))
qdel(parent1)
node1 = null
else if(reference == node2)
if(istype(node2, /obj/machinery/atmospherics/pipe))
qdel(parent2)
node2 = null
update_icon()
/obj/machinery/atmospherics/binary/nullifyPipenet(datum/pipeline/P)
..()
if(P == parent1)
parent1.other_airs -= air1
parent1 = null
else if(P == parent2)
parent2.other_airs -= air2
parent2 = null
/obj/machinery/atmospherics/binary/returnPipenetAir(datum/pipeline/P)
if(P == parent1)
return air1
else if(P == parent2)
return air2
/obj/machinery/atmospherics/binary/pipeline_expansion(datum/pipeline/P)
if(P)
if(parent1 == P)
return list(node1)
else if(parent2 == P)
return list(node2)
else
return list(node1, node2)
/obj/machinery/atmospherics/binary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
if(A == node1)
parent1 = P
else if(A == node2)
parent2 = P
/obj/machinery/atmospherics/binary/returnPipenet(obj/machinery/atmospherics/A)
if(A == node1)
return parent1
else if(A == node2)
return parent2
/obj/machinery/atmospherics/binary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent1)
parent1 = New
else if(Old == parent2)
parent2 = New