mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-12 02:32:10 +00:00
* Revives PR #58579; Sligh refactor to AI datums that allows for basic support of subtrees (#60249) Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> Co-authored-by: coiax <yellowbounder@ gmail.com> Co-authored-by: Watermelon914 <37270891+Watermelon914@ users.noreply.github.com> Co-authored-by: Rohesie <rohesie@ gmail.com> Co-authored-by: Matthew J. <12817816+ZephyrTFA@ users.noreply.github.com> Co-authored-by: AnturK <AnturK@ users.noreply.github.com> Co-authored-by: Jonathan Rubenstein <jrubcop@ gmail.com> Co-authored-by: Kylerace <kylerlumpkin1@ gmail.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> Co-authored-by: tralezab <40974010+tralezab@ users.noreply.github.com> Co-authored-by: Jordan Brown <Cyberboss@ users.noreply.github.com> Co-authored-by: Fikou <piotrbryla@ onet.pl> Co-authored-by: Emmanuel S. <emmanuelssr@ gmail.com> * Revives PR #58579; Sligh refactor to AI datums that allows for basic support of subtrees Co-authored-by: ma44 <guyonleagueoflegends@gmail.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> Co-authored-by: coiax <yellowbounder@ gmail.com> Co-authored-by: Watermelon914 <37270891+Watermelon914@ users.noreply.github.com> Co-authored-by: Rohesie <rohesie@ gmail.com> Co-authored-by: Matthew J. <12817816+ZephyrTFA@ users.noreply.github.com> Co-authored-by: AnturK <AnturK@ users.noreply.github.com> Co-authored-by: Jonathan Rubenstein <jrubcop@ gmail.com> Co-authored-by: Kylerace <kylerlumpkin1@ gmail.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> Co-authored-by: tralezab <40974010+tralezab@ users.noreply.github.com> Co-authored-by: Jordan Brown <Cyberboss@ users.noreply.github.com> Co-authored-by: Fikou <piotrbryla@ onet.pl> Co-authored-by: Emmanuel S. <emmanuelssr@ gmail.com>
34 lines
1.4 KiB
Plaintext
34 lines
1.4 KiB
Plaintext
/// The subsystem used to tick [/datum/ai_controllers] instances. Handling the re-checking of plans.
|
|
SUBSYSTEM_DEF(ai_controllers)
|
|
name = "AI Controller Ticker"
|
|
flags = SS_POST_FIRE_TIMING|SS_BACKGROUND
|
|
priority = FIRE_PRIORITY_NPC
|
|
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
|
init_order = INIT_ORDER_AI_CONTROLLERS
|
|
wait = 0.5 SECONDS //Plan every half second if required, not great not terrible.
|
|
|
|
///List of all ai_subtree singletons, key is the typepath while assigned value is a newly created instance of the typepath. See setup_subtrees()
|
|
var/list/ai_subtrees = list()
|
|
///List of all ai controllers currently running
|
|
var/list/active_ai_controllers = list()
|
|
|
|
/datum/controller/subsystem/ai_controllers/Initialize(timeofday)
|
|
setup_subtrees()
|
|
return ..()
|
|
|
|
/datum/controller/subsystem/ai_controllers/proc/setup_subtrees()
|
|
ai_subtrees = list()
|
|
for(var/subtree_type in subtypesof(/datum/ai_planning_subtree))
|
|
var/datum/ai_planning_subtree/subtree = new subtree_type
|
|
ai_subtrees[subtree_type] = subtree
|
|
|
|
/datum/controller/subsystem/ai_controllers/fire(resumed)
|
|
for(var/datum/ai_controller/ai_controller as anything in active_ai_controllers)
|
|
if(!COOLDOWN_FINISHED(ai_controller, failed_planning_cooldown))
|
|
continue
|
|
|
|
if(!LAZYLEN(ai_controller.current_behaviors))
|
|
ai_controller.SelectBehaviors(wait * 0.1)
|
|
if(!LAZYLEN(ai_controller.current_behaviors)) //Still no plan
|
|
COOLDOWN_START(ai_controller, failed_planning_cooldown, AI_FAILED_PLANNING_COOLDOWN)
|