/
githubmirror
/
vgstation13
Обзор
Документация
Войти
/
githubmirror
/
vgstation13
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
Bleeding-Edge
code/controllers/subsystem/power.dm
102 строки
3 KB
boy2mantwicethefam
Stations with no living players will no longer lose power + maxed SMES at 5 players and less (#38354)
11 сен 2025, 17:43
Не верифицирован
11 сен 2025, 17:43
e33e92c
Код
Авторство
О чём код?
var/datum/subsystem/power/SSpower var/list/power_machines = list() var/list/datum/powernet/powernets = list() //Holds all powernet datums in use or pooled var/list/cable_list = list() //Index for all cables, so that powernets don't have to look through the entire world all the time /datum/subsystem/power name = "Power" init_order = SS_INIT_POWER display_order = SS_DISPLAY_POWER priority = SS_PRIORITY_POWER wait = 2 SECONDS var/list/currentrun_cables var/list/currentrun_powerents var/list/currentrun_power_machines var/no_pop_mode // Will make powernets provide power when there's no players online. /datum/subsystem/power/New() NEW_SS_GLOBAL(SSpower) /datum/subsystem/power/stat_entry() ..("C:[cable_list.len]|PN:[powernets.len]|PM:[power_machines.len]") /datum/subsystem/power/Initialize(timeofday) makepowernets() ..() /datum/subsystem/power/fire(resumed = FALSE) if (!resumed) currentrun_cables = global.cable_list.Copy() currentrun_powerents = global.powernets.Copy() currentrun_power_machines = global.power_machines.Copy() // First we reset the powernets. // This is done first because we want the power machinery to have acted last on the powernet between intervals. while (currentrun_cables.len) var/obj/structure/cable/PC = currentrun_cables[currentrun_cables] currentrun_cables.len-- if (!PC || PC.gcDestroyed) continue // Does a powernet need rebuild? Lets do it! if (PC.build_status && PC.rebuild_from() && MC_TICK_CHECK) return if(istype(ticker.mode, /datum/gamemode/dynamic)) var/datum/gamemode/dynamic/D = ticker.mode if(!D.living_players.len) no_pop_mode = TRUE else no_pop_mode = FALSE while (currentrun_powerents.len) var/datum/powernet/powerNetwork = currentrun_powerents[currentrun_powerents.len] currentrun_powerents.len-- if (!powerNetwork || powerNetwork.gcDestroyed) continue powerNetwork.no_pop_mode = no_pop_mode powerNetwork.reset() if (MC_TICK_CHECK) return // Next we let the power machines operate, this way until the next tick it will be as if they have all done their work. while (currentrun_power_machines.len) var/datum/X = currentrun_power_machines[currentrun_power_machines.len] currentrun_power_machines.len-- if (!X || X.gcDestroyed) continue if (istype(X, /obj/machinery)) var/obj/machinery/M = X if (M.timestopped) continue M.check_rebuild() //Checks to make sure the powernet doesn't need to be rebuilt, rebuilds it if it does if (M.process() == PROCESS_KILL) M.inMachineList = FALSE power_machines.Remove(M) continue if (M.use_power) M.auto_use_power() else if (istype(X, /datum/power_connection)) var/datum/power_connection/C = X C.check_rebuild() //Checks to make sure the powernet doesn't need to be rebuilt, rebuilds it if it does if (C.process() == PROCESS_KILL) C.inMachineList = FALSE power_machines.Remove(C) continue if (MC_TICK_CHECK) return