Files
Yogstation/code/controllers/subsystem/mobs.dm
alexkar598 0ff2f1b025 SSMetrics (#19719)
* SSMetrics

* We were a bit too silly

* Forgot to commit this

* Logs CPU

* Removes global data from all ss

* And puts it on the metrics ss

* Update metrics.dm

* Logs profiler data

* Adds profile configs

* Update code/controllers/subsystem/metrics.dm

Co-authored-by: adamsong <adamsong@users.noreply.github.com>

* Log request errors

* Final fixes

* Rebuilds for 1.2.0-yogs1

* Apparnetly you can't split macro calls on multiple lines

* Org is called yogstation13 not yogstation

---------

Co-authored-by: alexkar598 <>
Co-authored-by: adamsong <adamsong@users.noreply.github.com>
2023-07-28 00:16:53 -05:00

50 lines
1.7 KiB
Plaintext

SUBSYSTEM_DEF(mobs)
name = "Mobs"
priority = FIRE_PRIORITY_MOBS
flags = SS_KEEP_TIMING | SS_NO_INIT
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
wait = 2 SECONDS
var/list/currentrun = list()
var/static/list/clients_by_zlevel[][]
var/static/list/dead_players_by_zlevel[][] = list(list()) // Needs to support zlevel 1 here, MaxZChanged only happens when z2 is created and new_players can login before that.
var/static/list/cubemonkeys = list()
var/static/list/slimes = list()
var/static/list/cheeserats = list()
/datum/controller/subsystem/mobs/stat_entry(msg)
msg = "P:[length(GLOB.mob_living_list)]"
return ..()
/datum/controller/subsystem/mobs/get_metrics()
. = ..()
.["mobs"] = length(GLOB.mob_living_list)
/datum/controller/subsystem/mobs/proc/MaxZChanged()
if (!islist(clients_by_zlevel))
clients_by_zlevel = new /list(world.maxz,0)
dead_players_by_zlevel = new /list(world.maxz,0)
while (clients_by_zlevel.len < world.maxz)
clients_by_zlevel.len++
clients_by_zlevel[clients_by_zlevel.len] = list()
dead_players_by_zlevel.len++
dead_players_by_zlevel[dead_players_by_zlevel.len] = list()
/datum/controller/subsystem/mobs/fire(resumed = FALSE)
if (!resumed)
src.currentrun = GLOB.mob_living_list.Copy()
//cache for sanic speed (lists are references anyways)
var/list/currentrun = src.currentrun
var/times_fired = src.times_fired
var/seconds_per_tick = wait / (1 SECONDS) // TODO: Make this actually responsive to stuff like pausing and resuming
while(currentrun.len)
var/mob/living/L = currentrun[currentrun.len]
currentrun.len--
if(L)
L.Life(seconds_per_tick, times_fired)
else
GLOB.mob_living_list.Remove(L)
if (MC_TICK_CHECK)
return