forked from DopplerShift13/DopplerShift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tick checks unplanned controllers (tgstation#87506)
Shakes fist at random overtime
- Loading branch information
1 parent
d9c3997
commit 7f5d9d7
Showing
3 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
GLOBAL_LIST_EMPTY(unplanned_controller_subsystems) | ||
/// Handles making mobs perform lightweight "idle" behaviors such as wandering around when they have nothing planned | ||
SUBSYSTEM_DEF(unplanned_controllers) | ||
name = "Unplanned AI Controllers" | ||
flags = SS_POST_FIRE_TIMING|SS_BACKGROUND|SS_NO_INIT | ||
flags = SS_POST_FIRE_TIMING|SS_BACKGROUND | ||
priority = FIRE_PRIORITY_UNPLANNED_NPC | ||
init_order = INIT_ORDER_AI_CONTROLLERS | ||
wait = 0.25 SECONDS | ||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME | ||
///what ai status are we interested in | ||
var/target_status = AI_STATUS_ON | ||
var/list/current_run = list() | ||
|
||
/datum/controller/subsystem/unplanned_controllers/Initialize() | ||
..() | ||
GLOB.unplanned_controller_subsystems += src | ||
return SS_INIT_SUCCESS | ||
|
||
/datum/controller/subsystem/unplanned_controllers/Destroy() | ||
GLOB.unplanned_controller_subsystems -= src | ||
return ..() | ||
|
||
/datum/controller/subsystem/unplanned_controllers/stat_entry(msg) | ||
msg = "Planning AIs:[length(GLOB.unplanned_controllers[target_status])]" | ||
return ..() | ||
|
||
/datum/controller/subsystem/unplanned_controllers/fire(resumed) | ||
for(var/datum/ai_controller/ai_controller as anything in GLOB.unplanned_controllers[target_status]) | ||
ai_controller.idle_behavior.perform_idle_behavior(wait * 0.1, ai_controller) | ||
if(!resumed) | ||
src.current_run = GLOB.unplanned_controllers[target_status].Copy() | ||
var/list/current_run = src.current_run // cache for sonic speed | ||
while(length(current_run)) | ||
var/datum/ai_controller/unplanned = current_run[current_run.len] | ||
current_run.len-- | ||
if(!QDELETED(unplanned)) | ||
unplanned.idle_behavior.perform_idle_behavior(wait * 0.1, unplanned) | ||
if (MC_TICK_CHECK) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters