diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-01 17:56:49 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-01 17:56:49 +0200 |
commit | 9b9468029a42d17226a551d7d31572e40699fbc5 (patch) | |
tree | 72e8e52c247aeae693796fb849f6a0ddce766252 /server/src | |
parent | 287adfc6f8f1b548aacb005b5f4ccf18caef40ed (diff) | |
download | hurrycurry-9b9468029a42d17226a551d7d31572e40699fbc5.tar hurrycurry-9b9468029a42d17226a551d7d31572e40699fbc5.tar.bz2 hurrycurry-9b9468029a42d17226a551d7d31572e40699fbc5.tar.zst |
cutomer spawn cooldown
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/customer/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/server/src/customer/mod.rs b/server/src/customer/mod.rs index c9b45160..8e6f1db6 100644 --- a/server/src/customer/mod.rs +++ b/server/src/customer/mod.rs @@ -41,6 +41,7 @@ pub struct DemandState { chairs: HashMap<IVec2, bool>, customer_id_counter: PlayerID, customers: HashMap<PlayerID, Customer>, + spawn_cooldown: f32, pub completed: usize, pub failed: usize, @@ -93,6 +94,7 @@ impl DemandState { customer_id_counter: PlayerID(0), customers: Default::default(), data, + spawn_cooldown: 0., } } } @@ -106,7 +108,10 @@ impl DemandState { dt: f32, points: &mut i64, ) -> Result<()> { - if self.customers.len() < 5 { + self.spawn_cooldown -= dt; + self.spawn_cooldown = self.spawn_cooldown.max(0.); + if self.customers.len() < 5 && self.spawn_cooldown <= 0. { + self.spawn_cooldown = 5. + random::<f32>() * 10.; self.customer_id_counter.0 -= 1; let id = self.customer_id_counter; packets_out.push(( |