diff options
author | metamuffin <metamuffin@disroot.org> | 2024-08-15 20:26:15 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-08-15 20:26:15 +0200 |
commit | a868f49b41c30daca83de86f982ffed431d3e891 (patch) | |
tree | 8d3c0f1242874517404e232ecb7a91fd2195e3a6 /server/bot/src/algos/customer.rs | |
parent | 6323dbc7ce50a73875c4b473da5776b7cbf41cde (diff) | |
download | hurrycurry-a868f49b41c30daca83de86f982ffed431d3e891.tar hurrycurry-a868f49b41c30daca83de86f982ffed431d3e891.tar.bz2 hurrycurry-a868f49b41c30daca83de86f982ffed431d3e891.tar.zst |
customers leave if they get stuck walking
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() } } |