mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-29 03:21:42 +00:00
Ports SSmobs from Virgo
- Ports SSmobs from Virgo - Has some debugging code, that was added a long time ago
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
/datum/controller/process/mob
|
||||
var/tmp/datum/updateQueue/updateQueueInstance
|
||||
|
||||
/datum/controller/process/mob/setup()
|
||||
name = "mob"
|
||||
schedule_interval = 20 // every 2 seconds
|
||||
start_delay = 16
|
||||
|
||||
/datum/controller/process/mob/started()
|
||||
..()
|
||||
if(!mob_list)
|
||||
mob_list = list()
|
||||
|
||||
/datum/controller/process/mob/doWork()
|
||||
for(last_object in mob_list)
|
||||
var/mob/M = last_object
|
||||
if(M && !QDELETED(M))
|
||||
try
|
||||
M.Life()
|
||||
catch(var/exception/e)
|
||||
catchException(e, M)
|
||||
SCHECK
|
||||
else
|
||||
catchBadType(M)
|
||||
mob_list -= M
|
||||
|
||||
/datum/controller/process/mob/statProcess()
|
||||
..()
|
||||
stat(null, "[mob_list.len] mobs")
|
||||
55
code/controllers/subsystems/mobs.dm
Normal file
55
code/controllers/subsystems/mobs.dm
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Mobs Subsystem - Process mob.Life()
|
||||
//
|
||||
|
||||
SUBSYSTEM_DEF(mobs)
|
||||
name = "Mobs"
|
||||
priority = 100
|
||||
wait = 2 SECONDS
|
||||
flags = SS_KEEP_TIMING|SS_NO_INIT
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
|
||||
var/list/currentrun = list()
|
||||
var/log_extensively = FALSE
|
||||
var/list/timelog = list()
|
||||
var/list/busy_z_levels = list()
|
||||
var/slept_mobs = 0
|
||||
|
||||
/datum/controller/subsystem/mobs/stat_entry()
|
||||
..("P: [global.mob_list.len] | S: [slept_mobs]")
|
||||
|
||||
/datum/controller/subsystem/mobs/fire(resumed = 0)
|
||||
var/list/busy_z_levels = src.busy_z_levels
|
||||
|
||||
if (!resumed)
|
||||
slept_mobs = 0
|
||||
src.currentrun = mob_list.Copy()
|
||||
busy_z_levels.Cut()
|
||||
for(var/played_mob in player_list)
|
||||
if(!played_mob || isobserver(played_mob))
|
||||
continue
|
||||
var/mob/pm = played_mob
|
||||
busy_z_levels |= pm.z
|
||||
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/currentrun = src.currentrun
|
||||
var/times_fired = src.times_fired
|
||||
while(currentrun.len)
|
||||
var/mob/M = currentrun[currentrun.len]
|
||||
currentrun.len--
|
||||
|
||||
if(QDELETED(M))
|
||||
mob_list -= M
|
||||
else
|
||||
// Right now mob.Life() is unstable enough I think we need to use a try catch.
|
||||
// Obviously we should try and get rid of this for performance reasons when we can.
|
||||
try
|
||||
if(M.low_priority && !(M.z in busy_z_levels))
|
||||
slept_mobs++
|
||||
continue
|
||||
M.Life(times_fired)
|
||||
catch(var/exception/e)
|
||||
log_runtime(e, M, "Caught by [name] subsystem")
|
||||
|
||||
if (MC_TICK_CHECK)
|
||||
return
|
||||
Reference in New Issue
Block a user