diff options
Diffstat (limited to 'server/bot/src/algos/customer.rs')
-rw-r--r-- | server/bot/src/algos/customer.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 556f5ce5..9c0ce210 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -58,7 +58,6 @@ impl Default for Customer { impl BotAlgo for Customer { fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput { - let _ = (me, game, dt); let Some(playerdata) = game.players.get(&me) else { return BotInput::default(); }; @@ -106,9 +105,14 @@ impl BotAlgo for Customer { }], ..Default::default() } + } else if path.is_stuck() { + if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), *origin) { + *self = Customer::Exiting { path }; + } + BotInput::default() } else { BotInput { - direction: path.next_direction(pos) * 0.5, + direction: path.next_direction(pos, dt) * 0.5, ..Default::default() } } @@ -252,7 +256,7 @@ impl BotAlgo for Customer { } } Customer::Exiting { path } => { - if path.is_done() { + if path.is_done() || path.is_stuck() { info!("{me:?} -> leave"); BotInput { leave: true, @@ -260,7 +264,7 @@ impl BotAlgo for Customer { } } else { BotInput { - direction: path.next_direction(pos) * 0.5, + direction: path.next_direction(pos, dt) * 0.5, ..Default::default() } } |