aboutsummaryrefslogtreecommitdiff
path: root/server/src/entity/pedestrians.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/entity/pedestrians.rs')
-rw-r--r--server/src/entity/pedestrians.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/server/src/entity/pedestrians.rs b/server/src/entity/pedestrians.rs
index fa3276d2..cc5d6d90 100644
--- a/server/src/entity/pedestrians.rs
+++ b/server/src/entity/pedestrians.rs
@@ -1,3 +1,5 @@
+use crate::random_gauss;
+
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
@@ -17,15 +19,14 @@
*/
use super::{Entity, EntityContext};
use anyhow::Result;
-use hurrycurry_protocol::{glam::Vec2, Character, PacketS, PlayerClass, PlayerID};
-use rand::{random, rng};
-use rand_distr::Distribution;
-use std::collections::HashMap;
+use hurrycurry_protocol::{Character, PacketS, PlayerClass, PlayerID, glam::Vec2};
+use std::{collections::HashMap, random::random};
pub struct Pedestrians {
pub players: HashMap<PlayerID, usize>,
pub points: Vec<Vec2>,
- pub spawn_delay_distr: rand_distr::Normal<f32>,
+ pub spawn_delay: f32,
+ pub spawn_delay_stdev: f32,
pub cooldown: f32,
pub speed: f32,
}
@@ -37,12 +38,12 @@ impl Entity for Pedestrians {
fn tick(&mut self, c: EntityContext<'_>) -> Result<()> {
self.cooldown -= c.dt;
if self.cooldown <= 0. && self.players.len() < 32 {
- let id = PlayerID(random());
+ let id = PlayerID(random(..));
c.packet_in.push_back(PacketS::Join {
name: "Pedestrian".to_string(),
character: Character {
- color: random(),
- hairstyle: random(),
+ color: random(..),
+ hairstyle: random(..),
headwear: 0,
},
class: PlayerClass::Customer,
@@ -50,7 +51,7 @@ impl Entity for Pedestrians {
position: self.points.first().copied(),
});
self.players.insert(id, 0);
- self.cooldown += self.spawn_delay_distr.sample(&mut rng()).max(0.1);
+ self.cooldown += (self.spawn_delay + self.spawn_delay_stdev * random_gauss()).max(0.1);
}
let mut remove = Vec::new();