aboutsummaryrefslogtreecommitdiff
path: root/server/src/data.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/data.rs')
-rw-r--r--server/src/data.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/server/src/data.rs b/server/src/data.rs
index fd268cb5..9c200e5b 100644
--- a/server/src/data.rs
+++ b/server/src/data.rs
@@ -31,7 +31,10 @@ pub struct RecipeDecl {
#[derive(Debug, Clone, Deserialize)]
pub struct InitialMap {
map: Vec<String>,
- tiles: HashMap<String, String>,
+ tiles: HashMap<char, String>,
+ items: HashMap<char, String>,
+ chef_spawn: char,
+ customer_spawn: char,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -55,7 +58,7 @@ pub struct Gamedata {
pub item_names: Vec<String>,
pub tile_names: Vec<String>,
#[serde(skip)]
- pub initial_map: HashMap<IVec2, TileIndex>,
+ pub initial_map: HashMap<IVec2, (TileIndex, Option<ItemIndex>)>,
pub chef_spawn: Vec2,
pub customer_spawn: Vec2,
}
@@ -121,17 +124,17 @@ pub fn build_gamedata(
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 == "chef-spawn" {
+ if tile == map_in.chef_spawn {
chef_spawn = pos.as_vec2();
- tilename = "floor".to_owned();
}
- if tilename == "customer-spawn" {
+ if tile == map_in.customer_spawn {
customer_spawn = pos.as_vec2();
- tilename = "floor".to_owned();
}
+ let tilename = map_in.tiles[&tile].clone();
+ let itemname = map_in.items.get(&tile).cloned();
let tile = TileIndex(register(&tile_names, tilename));
- initial_map.insert(pos, tile);
+ let item = itemname.map(|i| ItemIndex(register(&item_names, i)));
+ initial_map.insert(pos, (tile, item));
}
}