aboutsummaryrefslogtreecommitdiff
path: root/server/src/customer
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/customer')
-rw-r--r--server/src/customer/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/server/src/customer/mod.rs b/server/src/customer/mod.rs
index f90b2eb2..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((
@@ -145,7 +150,7 @@ impl DemandState {
));
p.state = CustomerState::Waiting {
chair: *chair,
- timeout: 60.,
+ timeout: 60. + random::<f32>() * 30.,
demand,
};
}