(ctx: &ReducerContext, players: u64)
| 391 | // We check only for a single pass in the game loop. |
| 392 | #[spacetimedb::reducer] |
| 393 | pub fn game_loop_enemy_ia(ctx: &ReducerContext, players: u64) { |
| 394 | let mut count = 0; |
| 395 | let current_time_ms = moment_milliseconds(); |
| 396 | |
| 397 | for mut agent in ctx.db.game_enemy_ai_agent_state().iter() { |
| 398 | let agent_targetable = ctx |
| 399 | .db |
| 400 | .game_targetable_state() |
| 401 | .entity_id() |
| 402 | .find(agent.entity_id) |
| 403 | .expect("No TargetableState for AgentState entity"); |
| 404 | |
| 405 | let surrounding_agents = get_targetables_near_quad(ctx, agent_targetable.entity_id, players); |
| 406 | |
| 407 | agent.action = AgentAction::Fighting; |
| 408 | |
| 409 | agent_loop(ctx, agent, agent_targetable, &surrounding_agents, current_time_ms); |
| 410 | |
| 411 | count += 1; |
| 412 | } |
| 413 | |
| 414 | log::info!("ENEMY IA LOOP PLAYERS: {players}, processed: {count}"); |
| 415 | } |
| 416 | |
| 417 | #[spacetimedb::reducer] |
| 418 | pub fn init_game_ia_loop(ctx: &ReducerContext, initial_load: u32) { |
no test coverage detected
searching dependent graphs…