| 1234567891011121314151617181920212223242526272829303132 |
- #include "ai_executor.h"
- #include "systems/ai_system/ai_behavior.h"
- #include "systems/ai_system/ai_behavior_registry.h"
- #include "systems/ai_system/ai_types.h"
- #include <vector>
- namespace Game::Systems::AI {
- void AIExecutor::run(const AISnapshot &snapshot, AIContext &context,
- float delta_time, AIBehaviorRegistry ®istry,
- std::vector<AICommand> &outCommands) {
- bool exclusive_behavior_executed = false;
- registry.forEach([&](AIBehavior &behavior) {
- if (exclusive_behavior_executed && !behavior.canRunConcurrently()) {
- return;
- }
- bool const should_exec = behavior.should_execute(snapshot, context);
- if (should_exec) {
- behavior.execute(snapshot, context, delta_time, outCommands);
- if (!behavior.canRunConcurrently()) {
- exclusive_behavior_executed = true;
- }
- }
- });
- }
- } // namespace Game::Systems::AI
|