summaryrefslogtreecommitdiff
path: root/server/src/entity
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/entity')
-rw-r--r--server/src/entity/bot.rs8
-rw-r--r--server/src/entity/customers.rs8
-rw-r--r--server/src/entity/mod.rs12
-rw-r--r--server/src/entity/pedestrians.rs11
-rw-r--r--server/src/entity/tram.rs4
5 files changed, 27 insertions, 16 deletions
diff --git a/server/src/entity/bot.rs b/server/src/entity/bot.rs
index 922cc55e..8d3994cb 100644
--- a/server/src/entity/bot.rs
+++ b/server/src/entity/bot.rs
@@ -18,7 +18,7 @@
use super::{Entity, EntityContext};
use anyhow::Result;
use hurrycurry_bot::{BotAlgo, DynBotAlgo};
-use hurrycurry_protocol::{Hand, PacketS, PlayerClass, PlayerID};
+use hurrycurry_protocol::{Character, Hand, PacketS, PlayerClass, PlayerID};
use log::info;
use rand::random;
use std::any::Any;
@@ -27,14 +27,14 @@ pub type DynBotDriver = BotDriver<DynBotAlgo>;
pub struct BotDriver<T> {
algo: T,
- join_data: Option<(String, i32, PlayerClass)>,
+ join_data: Option<(String, Character, PlayerClass)>,
id: PlayerID,
interacting: bool,
left: bool,
}
impl<T: BotAlgo> BotDriver<T> {
- pub fn new(name: String, character: i32, class: PlayerClass, algo: T) -> Self {
+ pub fn new(name: String, character: Character, class: PlayerClass, algo: T) -> Self {
Self {
algo,
id: PlayerID(0),
@@ -51,7 +51,7 @@ impl<T: BotAlgo + Any> Entity for BotDriver<T> {
fn tick(&mut self, c: EntityContext<'_>) -> Result<()> {
if let Some((name, character, class)) = self.join_data.take() {
self.id = PlayerID(random()); // TODO bad code, can collide
- info!("spawn {:?} ({name:?}, {character})", self.id);
+ info!("spawn {:?} ({name:?})", self.id);
c.packet_in.push_back(PacketS::Join {
name,
character,
diff --git a/server/src/entity/customers.rs b/server/src/entity/customers.rs
index 02051901..05246a54 100644
--- a/server/src/entity/customers.rs
+++ b/server/src/entity/customers.rs
@@ -18,7 +18,7 @@
use super::{bot::BotDriver, Entity, EntityContext};
use anyhow::Result;
use hurrycurry_bot::algos::{Customer, CustomerConfig};
-use hurrycurry_protocol::PlayerClass;
+use hurrycurry_protocol::{Character, PlayerClass};
use rand::random;
pub struct Customers {
@@ -56,7 +56,11 @@ impl Entity for Customers {
self.spawn_cooldown = 10. + random::<f32>() * 10.;
let bot = BotDriver::new(
"".to_string(),
- -1 - random::<u16>() as i32,
+ Character {
+ color: random(),
+ hairstyle: random(),
+ headwear: 0,
+ },
PlayerClass::Customer,
Customer::new(CustomerConfig {
unknown_order: !c.serverdata.flags.disable_unknown_orders,
diff --git a/server/src/entity/mod.rs b/server/src/entity/mod.rs
index 75ea0e9b..2eadc0ff 100644
--- a/server/src/entity/mod.rs
+++ b/server/src/entity/mod.rs
@@ -42,7 +42,7 @@ use environment_effect::{EnvironmentController, EnvironmentEffect, EnvironmentEf
use hurrycurry_client_lib::Game;
use hurrycurry_protocol::{
glam::{IVec2, Vec2},
- PacketC, PacketS, PlayerID,
+ Character, PacketC, PacketS, PlayerID,
};
use item_portal::ItemPortal;
use player_portal::PlayerPortal;
@@ -142,7 +142,7 @@ pub enum EntityDecl {
},
Tram {
length: usize,
- character: Option<i32>,
+ color: Option<i32>,
points: Vec<Vec2>,
spacing: f32,
smoothing: f32,
@@ -219,13 +219,17 @@ pub fn construct_entity(
EntityDecl::Environment(names) => Box::new(EnvironmentController(names)),
EntityDecl::Tram {
length,
- character,
+ color,
points,
smoothing,
spacing,
} => Box::new(Tram {
length,
- character: character.unwrap_or(51),
+ character: Character {
+ color: color.unwrap_or_default(),
+ hairstyle: 0,
+ headwear: 0,
+ },
ids: Vec::new(),
points,
progress: 0.,
diff --git a/server/src/entity/pedestrians.rs b/server/src/entity/pedestrians.rs
index 9b433ded..64adf57b 100644
--- a/server/src/entity/pedestrians.rs
+++ b/server/src/entity/pedestrians.rs
@@ -1,5 +1,3 @@
-use std::collections::HashMap;
-
/*
Hurry Curry! - a game about cooking
Copyright 2025 metamuffin
@@ -19,9 +17,10 @@ use std::collections::HashMap;
*/
use super::{Entity, EntityContext};
use anyhow::Result;
-use hurrycurry_protocol::{glam::Vec2, PacketS, PlayerClass, PlayerID};
+use hurrycurry_protocol::{glam::Vec2, Character, PacketS, PlayerClass, PlayerID};
use rand::{random, rng};
use rand_distr::Distribution;
+use std::collections::HashMap;
pub struct Pedestrians {
pub players: HashMap<PlayerID, usize>,
@@ -40,7 +39,11 @@ impl Entity for Pedestrians {
let id = PlayerID(random());
c.packet_in.push_back(PacketS::Join {
name: "Pedestrian".to_string(),
- character: 0,
+ character: Character {
+ color: random(),
+ hairstyle: random(),
+ headwear: 0,
+ },
class: PlayerClass::Customer,
id: Some(id),
position: self.points.get(0).copied(),
diff --git a/server/src/entity/tram.rs b/server/src/entity/tram.rs
index 26a191aa..76ce6dbd 100644
--- a/server/src/entity/tram.rs
+++ b/server/src/entity/tram.rs
@@ -17,12 +17,12 @@
*/
use super::{Entity, EntityContext};
use anyhow::Result;
-use hurrycurry_protocol::{glam::Vec2, PacketS, PlayerClass, PlayerID};
+use hurrycurry_protocol::{glam::Vec2, Character, PacketS, PlayerClass, PlayerID};
use rand::random;
pub struct Tram {
pub length: usize,
- pub character: i32,
+ pub character: Character,
pub ids: Vec<PlayerID>,
pub points: Vec<Vec2>,
pub progress: f32,