From bcbc56d161ac78a48dcca88e5671d333614d7425 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 19 Jun 2024 12:49:24 +0200 Subject: customers part 1 --- server/src/data.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'server/src/data.rs') diff --git a/server/src/data.rs b/server/src/data.rs index 6affccb5..9f03b1ea 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -31,14 +31,15 @@ pub struct InitialMap { tiles: HashMap, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct Gamedata { pub recipes: Vec, pub item_names: Vec, pub tile_names: Vec, #[serde(skip)] pub initial_map: HashMap, - pub spawn: Vec2, + pub chef_spawn: Vec2, + pub customer_spawn: Vec2, } pub fn build_gamedata(recipes_in: Vec, map_in: InitialMap) -> Gamedata { @@ -77,14 +78,19 @@ pub fn build_gamedata(recipes_in: Vec, map_in: InitialMap) -> Gameda assert_eq!(outputs.next(), None, "{r2:?}"); } - let mut spawn = Vec2::new(0., 0.); + let mut chef_spawn = Vec2::new(0., 0.); + let mut customer_spawn = Vec2::new(0., 0.); let mut initial_map = HashMap::new(); for (y, line) in map_in.map.iter().enumerate() { for (x, tile) in line.trim().char_indices() { let pos = IVec2::new(x as i32, y as i32); let mut tilename = map_in.tiles[&tile.to_string()].clone(); - if tilename == "spawn" { - spawn = pos.as_vec2(); + if tilename == "chef-spawn" { + chef_spawn = pos.as_vec2(); + tilename = "floor".to_owned(); + } + if tilename == "customer-spawn" { + customer_spawn = pos.as_vec2(); tilename = "floor".to_owned(); } let tile = register(&tile_names, tilename); @@ -97,7 +103,8 @@ pub fn build_gamedata(recipes_in: Vec, map_in: InitialMap) -> Gameda initial_map, item_names: item_names.into_inner().unwrap(), tile_names: tile_names.into_inner().unwrap(), - spawn, + chef_spawn, + customer_spawn, } } -- cgit v1.2.3-70-g09d2