diff options
author | metamuffin <metamuffin@disroot.org> | 2024-10-01 17:52:41 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-10-01 17:58:24 +0200 |
commit | c0b7131a5db1d6965b25a9b689ccf0d1a2f70f53 (patch) | |
tree | 2d037a8de86084b171e0598874b8f3eb54c8ea6c /server/src | |
parent | 99857c6f73c2dfcbc8f84ccfafa2481d2f006d3e (diff) | |
download | hurrycurry-c0b7131a5db1d6965b25a9b689ccf0d1a2f70f53.tar hurrycurry-c0b7131a5db1d6965b25a9b689ccf0d1a2f70f53.tar.bz2 hurrycurry-c0b7131a5db1d6965b25a9b689ccf0d1a2f70f53.tar.zst |
customer scaling factor
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/entity/customers.rs | 6 | ||||
-rw-r--r-- | server/src/entity/mod.rs | 8 | ||||
-rw-r--r-- | server/src/server.rs | 5 |
3 files changed, 11 insertions, 8 deletions
diff --git a/server/src/entity/customers.rs b/server/src/entity/customers.rs index a9ddb6f1..1e8b6b13 100644 --- a/server/src/entity/customers.rs +++ b/server/src/entity/customers.rs @@ -25,14 +25,16 @@ pub struct Customers { customers: Vec<BotDriver<Customer>>, spawn_cooldown: f32, chair_count: Option<usize>, + scaling_factor: f32, } impl Customers { - pub fn new() -> Result<Self> { + pub fn new(scaling_factor: f32) -> Result<Self> { Ok(Self { customers: Default::default(), spawn_cooldown: 0., chair_count: None, + scaling_factor, }) } } @@ -46,7 +48,7 @@ impl Entity for Customers { .filter(|t| c.game.data.tile_name(t.kind) == "chair") .count() }); - let max_count = 5.min(chairs); + let max_count = (self.scaling_factor * chairs as f32).max(1.) as usize; self.spawn_cooldown -= c.dt; self.spawn_cooldown = self.spawn_cooldown.max(0.); diff --git a/server/src/entity/mod.rs b/server/src/entity/mod.rs index 15e9b0d8..87656f0d 100644 --- a/server/src/entity/mod.rs +++ b/server/src/entity/mod.rs @@ -115,7 +115,9 @@ pub enum EntityDecl { from: Option<Vec2>, to: Vec2, }, - Customers {}, + Customers { + scaling_factor: Option<f32>, + }, Map { name: String, location: Option<Vec2>, @@ -185,9 +187,9 @@ pub fn construct_entity( blocker_tile: reg.register_tile("fence".to_string()), active: true, }), - EntityDecl::Customers {} => { + EntityDecl::Customers { scaling_factor } => { reg.register_item("unknown-order".to_owned()); - Box::new(Customers::new()?) + Box::new(Customers::new(scaling_factor.unwrap_or(0.5))?) } EntityDecl::EnvironmentEffect(config) => Box::new(EnvironmentEffectController::new(config)), EntityDecl::Environment(names) => Box::new(EnvironmentController(names)), diff --git a/server/src/server.rs b/server/src/server.rs index 1d57a200..d8470fb8 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -413,7 +413,7 @@ impl Server { PacketS::Movement { pos, boost, - dir: direction, + dir, player, } => { let pd = self @@ -422,7 +422,7 @@ impl Server { .get_mut(&player) .ok_or(tre!("s.error.no_player"))?; - pd.movement.input(direction, boost); + pd.movement.input(dir, boost); if let Some(pos) = pos { let last_position_update = self @@ -433,7 +433,6 @@ impl Server { *last_position_update += dt; let diff = pos - pd.movement.position; pd.movement.position += diff.clamp_length_max(dt.as_secs_f32()); - if diff.length() > 1. { replies.push(PacketC::MovementSync { player }); } |