diff options
Diffstat (limited to 'server/bot/src/algos')
| -rw-r--r-- | server/bot/src/algos/customer.rs | 31 | 
1 files changed, 20 insertions, 11 deletions
| diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index c1a13d31..a147db05 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -30,17 +30,20 @@ pub enum Customer {      Entering {          path: Path,          chair: IVec2, +        origin: IVec2,      },      Waiting {          demand: DemandIndex,          chair: IVec2,          timeout: f32, +        origin: IVec2,      },      Eating {          demand: DemandIndex,          target: IVec2,          progress: f32,          chair: IVec2, +        origin: IVec2,      },      Exiting {          path: Path, @@ -72,12 +75,20 @@ impl BotAlgo for Customer {                  {                      if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), chair) {                          info!("{me:?} -> entering"); -                        *self = Customer::Entering { path, chair }; +                        *self = Customer::Entering { +                            path, +                            chair, +                            origin: pos.as_ivec2(), +                        };                      }                  }                  BotInput::default()              } -            Customer::Entering { path, chair } => { +            Customer::Entering { +                path, +                chair, +                origin, +            } => {                  if path.is_done() {                      let demand = DemandIndex(random::<u32>() as usize % game.data.demands.len());                      info!("{me:?} -> waiting"); @@ -85,6 +96,7 @@ impl BotAlgo for Customer {                          chair: *chair,                          timeout: 90. + random::<f32>() * 60.,                          demand, +                        origin: *origin,                      };                      BotInput {                          extra: vec![PacketS::Communicate { @@ -105,16 +117,12 @@ impl BotAlgo for Customer {                  chair,                  demand,                  timeout, +                origin,              } => {                  *timeout -= dt;                  if *timeout <= 0. { -                    let path = find_path( -                        &game.walkable, -                        pos.as_ivec2(), -                        pos.as_ivec2(), -                        // game.data.customer_spawn.as_ivec2(), -                    ) -                    .expect("no path to exit"); +                    let path = find_path(&game.walkable, pos.as_ivec2(), *origin) +                        .expect("no path to exit");                      // *self.chairs.get_mut(chair).unwrap() = true;                      // game.score.demands_failed += 1;                      // game.score.points -= 1; @@ -165,6 +173,7 @@ impl BotAlgo for Customer {                              target: pos,                              progress: 0.,                              chair: *chair, +                            origin: *origin,                          };                          BotInput {                              extra: vec![ @@ -202,6 +211,7 @@ impl BotAlgo for Customer {                  target,                  progress,                  chair, +                origin,              } => {                  let demand = &game.data.demands[demand.0];                  *progress += dt / demand.duration; @@ -209,8 +219,7 @@ impl BotAlgo for Customer {                      if let Some(path) = find_path(                          &game.walkable,                          pos.as_ivec2(), -                        pos.as_ivec2(), -                        // game.data.customer_spawn.as_ivec2(), +                        *origin,                      ) {                          let mut packets = Vec::new();                          packets.push(PacketS::ReplaceHand { | 
