APC Area update initial commit.

Conflicts:
	code/modules/mob/mob.dm
	code/modules/power/power.dm
This commit is contained in:
Ccomp5950
2014-03-07 23:42:28 -06:00
committed by ZomgPonies
parent 0b47e16828
commit b97434054f
9 changed files with 57 additions and 15 deletions
+6 -4
View File
@@ -78,6 +78,7 @@
powernet = 0 // set so that APCs aren't found as powernet nodes //Hackish, Horrible, was like this before I changed it :(
var/malfhack = 0 //New var for my changes to AI malf. --NeoFite
var/mob/living/silicon/ai/malfai = null //See above --NeoFite
var/debug= 0
// luminosity = 1
var/has_electronics = 0 // 0 - none, 1 - plugged in, 2 - secured by screwdriver
var/overload = 1 //used for the Blackout malf module
@@ -1049,7 +1050,8 @@
lastused_light = area.usage(LIGHT)
lastused_equip = area.usage(EQUIP)
lastused_environ = area.usage(ENVIRON)
area.clear_usage()
if(area.powerupdate)
area.clear_usage()
lastused_total = lastused_light + lastused_equip + lastused_environ
@@ -1072,8 +1074,8 @@
if(terminal && terminal.powernet)
perapc = terminal.powernet.perapc
//if(debug)
// world.log << "Status: [main_status] - Excess: [excess] - Last Equip: [lastused_equip] - Last Light: [lastused_light] - Longterm: [longtermpower]"
if(debug)
world << "Status: [main_status] - Excess: [excess] - Last Equip: [lastused_equip] - Last Light: [lastused_light]"
if(cell && !shorted)
@@ -1318,4 +1320,4 @@ obj/machinery/power/apc/proc/autoset(var/val, var/on)
else
return 0
#undef APC_UPDATE_ICON_COOLDOWN
#undef APC_UPDATE_ICON_COOLDOWN
+2
View File
@@ -602,9 +602,11 @@
#define LIGHTING_POWER_FACTOR 20 //20W per unit luminosity
/*
/obj/machinery/light/process()//TODO: remove/add this from machines to save on processing as needed ~Carn PRIORITY
if(on)
use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT)
*/
// called when area power state changes
/obj/machinery/light/power_change()
+6 -2
View File
@@ -54,13 +54,17 @@
// increment the power usage stats for an area
/obj/machinery/proc/use_power(var/amount, var/chan = -1) // defaults to power_channel
var/area/A = get_area(src) // make sure it's in an area
/obj/machinery/proc/use_power(var/amount, var/chan = -1, var/autocalled = 0) // defaults to power_channel
var/area/A = src.loc.loc // make sure it's in an area
if(!A || !isarea(A) || !A.master)
return
if(chan == -1)
chan = power_channel
A.master.use_power(amount, chan)
if(!autocalled)
if(A.master.debug)
world << "Yeah we're setting this to 2 source: [src] / [src.type]"
A.master.powerupdate = 2 // Decremented by 2 each GC tick, since it's not auto power change we're going to update power twice.
/obj/machinery/proc/power_change() // called whenever the power settings of the containing area change
// by default, check equipment channel & set flag