| 12345678910111213141516171819202122232425262728293031323334353637 |
- #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> &out_commands) {
- bool exclusive_behavior_executed = false;
- registry.for_each([&](AIBehavior &behavior) {
- if (exclusive_behavior_executed && !behavior.can_run_concurrently()) {
- return;
- }
- bool const should_exec = behavior.should_execute(snapshot, context);
- if (should_exec) {
- size_t commands_before = out_commands.size();
- behavior.execute(snapshot, context, delta_time, out_commands);
- size_t commands_after = out_commands.size();
- context.debug_info.total_commands_issued +=
- static_cast<int>(commands_after - commands_before);
- if (!behavior.can_run_concurrently()) {
- exclusive_behavior_executed = true;
- }
- }
- });
- }
- } // namespace Game::Systems::AI
|