mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-30 23:48:28 +01:00
wire up ai idling to spatial grid (#30711)
* wire up ai idling to spatial grid * lint * Apply suggestions from code review Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: warriorstar-orion <orion@snowfrost.garden> * stupid loadbearing src * some spatial grid cleanup * make sure to remove controllers in the GLOB * immediately set targets and state for hiveloord brood * properly fail behaviors when movement targets are lost * Apply suggestions from code review Comment formatting Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/ai/ai_controller.dm Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/ai/ai_controller.dm Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> * Apply suggestions from code review Comment formatting Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/ai/ai_controller.dm Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> --------- Signed-off-by: warriorstar-orion <orion@snowfrost.garden> Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> Co-authored-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>
This commit is contained in:
co-authored by
DGamerL
PollardTheDragon
Burzah
parent
9e87289bd8
commit
be48d7598f
@@ -0,0 +1,34 @@
|
||||
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 = "AI Unplanned Controllers"
|
||||
flags = SS_POST_FIRE_TIMING|SS_BACKGROUND
|
||||
priority = FIRE_PRIORITY_UNPLANNED_NPC
|
||||
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
|
||||
|
||||
/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)
|
||||
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
|
||||
Reference in New Issue
Block a user