mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
Converts AI controller processing subsystems to use currentrun (#94905)
## About The Pull Request this makes it so `SSai_controllers` and its subtypes use a `currentrun` loop, instead of directly looping thru `GLOB.ai_controllers_by_status[planning_status]` ## Why It's Good For The Game most other processing subsystems do this, why shouldn't we? it should ensure all ai controllers get to process, even if the server's under load. ## Changelog no player-facing changes, prolly
This commit is contained in:
@@ -8,6 +8,7 @@ SUBSYSTEM_DEF(ai_controllers)
|
||||
)
|
||||
wait = 0.5 SECONDS //Plan every half second if required, not great not terrible.
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
var/list/currentrun = list()
|
||||
///type of status we are interested in running
|
||||
var/planning_status = AI_STATUS_ON
|
||||
/// The average tick cost of all active AI, calculated on fire.
|
||||
@@ -26,9 +27,16 @@ SUBSYSTEM_DEF(ai_controllers)
|
||||
|
||||
/datum/controller/subsystem/ai_controllers/fire(resumed)
|
||||
if(!resumed)
|
||||
var/list/planning_list = GLOB.ai_controllers_by_status[planning_status]
|
||||
currentrun = planning_list.Copy()
|
||||
summing_cost = 0
|
||||
|
||||
//cache for sanic speed (lists are references anyways)
|
||||
var/list/current_run = src.currentrun
|
||||
var/timer = TICK_USAGE_REAL
|
||||
for(var/datum/ai_controller/ai_controller as anything in GLOB.ai_controllers_by_status[planning_status])
|
||||
while(length(current_run))
|
||||
var/datum/ai_controller/ai_controller = current_run[length(current_run)]
|
||||
current_run.len--
|
||||
if(!ai_controller.able_to_plan)
|
||||
continue
|
||||
ai_controller.SelectBehaviors(wait * 0.1)
|
||||
|
||||
Reference in New Issue
Block a user