Main agent loop processing
| 345 | |
| 346 | // Main agent loop processing |
| 347 | void agent_loop(ReducerContext& ctx, GameEnemyAiAgentState& agent, |
| 348 | const GameTargetableState& agent_targetable, |
| 349 | const std::vector<GameTargetableState>& surrounding_agents, |
| 350 | uint64_t current_time_ms) { |
| 351 | uint64_t entity_id = agent.entity_id; |
| 352 | |
| 353 | auto coordinates_opt = ctx.db[game_mobile_entity_state_entity_id].find(entity_id); |
| 354 | if (!coordinates_opt) { |
| 355 | LOG_PANIC("GameMobileEntityState Entity ID not found"); |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | auto agent_entity_opt = ctx.db[game_enemy_state_entity_id].find(entity_id); |
| 360 | if (!agent_entity_opt) { |
| 361 | LOG_PANIC("GameEnemyState Entity ID not found"); |
| 362 | return; |
| 363 | } |
| 364 | const auto& agent_entity = *agent_entity_opt; |
| 365 | |
| 366 | auto agent_herd_opt = ctx.db[game_herd_cache_id].find(agent_entity.herd_id); |
| 367 | if (!agent_herd_opt) { |
| 368 | LOG_PANIC("GameHerdCache Entity ID not found"); |
| 369 | return; |
| 370 | } |
| 371 | const auto& agent_herd = *agent_herd_opt; |
| 372 | |
| 373 | SmallHexTile agent_herd_coordinates = agent_herd.location; |
| 374 | |
| 375 | move_agent(ctx, agent, agent_herd_coordinates, current_time_ms); |
| 376 | } |
| 377 | |
| 378 | // Main game loop for enemy AI processing |
| 379 | SPACETIMEDB_REDUCER(game_loop_enemy_ia, ReducerContext& ctx, uint64_t players) { |
no test coverage detected
searching dependent graphs…