mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
51 lines
1.3 KiB
Plaintext
51 lines
1.3 KiB
Plaintext
var/global/list/power_machinery_profiling = list()
|
|
var/global/list/power_machines = list()
|
|
|
|
/datum/controller/process/power_machinery
|
|
var/tmp/datum/updateQueue/updateQueueInstance
|
|
schedule_interval = 20 // every 2 seconds
|
|
|
|
/datum/controller/process/power_machinery/setup()
|
|
name = "pow_machine"
|
|
|
|
|
|
/datum/controller/process/power_machinery/doWork()
|
|
for(var/i = 1 to power_machines.len)
|
|
if(i > power_machines.len)
|
|
break
|
|
var/obj/machinery/M = power_machines[i]
|
|
if(istype(M) && !M.gcDestroyed)
|
|
#ifdef PROFILE_MACHINES
|
|
var/time_start = world.timeofday
|
|
#endif
|
|
|
|
if(M.check_rebuild()) //Checks to make sure the powernet doesn't need to be rebuilt, rebuilds it if it does
|
|
scheck()
|
|
|
|
if(M.process() == PROCESS_KILL)
|
|
M.inMachineList = 0
|
|
power_machines.Remove(M)
|
|
continue
|
|
|
|
if(M && M.use_power)
|
|
M.auto_use_power()
|
|
if(istype(M))
|
|
#ifdef PROFILE_MACHINES
|
|
var/time_end = world.timeofday
|
|
|
|
if(!(M.type in power_machinery_profiling))
|
|
power_machinery_profiling[M.type] = 0
|
|
|
|
power_machinery_profiling[M.type] += (time_end - time_start)
|
|
#endif
|
|
else
|
|
if(!power_machines.Remove(M))
|
|
power_machines.Cut(i,i+1)
|
|
else
|
|
if(M)
|
|
M.inMachineList = 0
|
|
if(!power_machines.Remove(M))
|
|
power_machines.Cut(i,i+1)
|
|
|
|
scheck()
|