mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 00:29:02 +01:00
[MIRROR] Emitters and Shieldgens work roundstart, APCs charge evenly (#28897)
* Emitters and Shieldgens work roundstart, APCs charge evenly * modular --------- Co-authored-by: Andrew <mt.forspam@gmail.com> Co-authored-by: SpaceLoveSs13 <68121607+SpaceLoveSs13@users.noreply.github.com>
This commit is contained in:
co-authored by
Andrew
SpaceLoveSs13
parent
5ce53057ed
commit
0a84ecdee5
@@ -11,10 +11,17 @@ SUBSYSTEM_DEF(machines)
|
||||
VAR_PRIVATE/list/all_machines = list()
|
||||
|
||||
var/list/processing = list()
|
||||
var/list/processing_apcs = list()
|
||||
|
||||
var/list/currentrun = list()
|
||||
var/list/apc_early_processing = list()
|
||||
var/list/apc_late_processing = list()
|
||||
var/current_part = SSMACHINES_APCS_EARLY
|
||||
var/current_part = SSMACHINES_MACHINES
|
||||
var/list/apc_steps = list(
|
||||
SSMACHINES_APCS_ENVIRONMENT,
|
||||
SSMACHINES_APCS_LIGHTS,
|
||||
SSMACHINES_APCS_EQUIPMENT,
|
||||
SSMACHINES_APCS_EARLY,
|
||||
SSMACHINES_APCS_LATE
|
||||
)
|
||||
///List of all powernets on the server.
|
||||
var/list/datum/powernet/powernets = list()
|
||||
|
||||
@@ -82,25 +89,10 @@ SUBSYSTEM_DEF(machines)
|
||||
if (!resumed)
|
||||
for(var/datum/powernet/powernet as anything in powernets)
|
||||
powernet.reset() //reset the power state.
|
||||
current_part = SSMACHINES_APCS_EARLY
|
||||
src.currentrun = apc_early_processing.Copy()
|
||||
|
||||
//APC early processing. Draws static power usages from their grids.
|
||||
if(current_part == SSMACHINES_APCS_EARLY)
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/obj/machinery/power/apc/apc = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(QDELETED(apc) || apc.early_process(wait * 0.1) == PROCESS_KILL)
|
||||
apc_early_processing -= apc
|
||||
apc.datum_flags &= ~DF_ISPROCESSING
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
current_part = SSMACHINES_MACHINES
|
||||
src.currentrun = processing.Copy()
|
||||
|
||||
//General machine processing. Their power usage can be dynamic and based on surplus power, so they come after static power usage have been applied.
|
||||
//Processing all machines
|
||||
if(current_part == SSMACHINES_MACHINES)
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
@@ -112,22 +104,34 @@ SUBSYSTEM_DEF(machines)
|
||||
thing.datum_flags &= ~DF_ISPROCESSING
|
||||
if (MC_TICK_CHECK)
|
||||
return
|
||||
current_part = SSMACHINES_APCS_LATE
|
||||
src.currentrun = apc_late_processing.Copy()
|
||||
current_part = apc_steps[1]
|
||||
src.currentrun = processing_apcs.Copy()
|
||||
|
||||
//APC late processing. APCs will use the remaining power on the grid to charge their cells if needed.
|
||||
//This is applied at the end so charging APCs don't cause others to discharge by taking all the power from the grid before machines use power.
|
||||
if(current_part == SSMACHINES_APCS_LATE)
|
||||
//Processing APCs
|
||||
while(current_part in apc_steps)
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
while(currentrun.len)
|
||||
var/obj/machinery/power/apc/apc = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
if(QDELETED(apc) || apc.late_process(wait * 0.1) == PROCESS_KILL)
|
||||
apc_late_processing -= apc
|
||||
if(QDELETED(apc))
|
||||
processing_apcs -= apc
|
||||
apc.datum_flags &= ~DF_ISPROCESSING
|
||||
switch(current_part)
|
||||
if(SSMACHINES_APCS_EARLY)
|
||||
apc.early_process(wait * 0.1)
|
||||
if(SSMACHINES_APCS_LATE)
|
||||
apc.charge_channel(null, wait * 0.1)
|
||||
apc.late_process(wait * 0.1)
|
||||
else
|
||||
apc.charge_channel(current_part, wait * 0.1)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
var/next_index = apc_steps.Find(current_part) + 1
|
||||
if (next_index > apc_steps.len)
|
||||
return
|
||||
current_part = apc_steps[next_index]
|
||||
src.currentrun = processing_apcs.Copy()
|
||||
|
||||
/datum/controller/subsystem/machines/proc/setup_template_powernets(list/cables)
|
||||
var/obj/structure/cable/PC
|
||||
|
||||
Reference in New Issue
Block a user