diff options
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(( |