diff options
Diffstat (limited to 'server/data/src/lib.rs')
-rw-r--r-- | server/data/src/lib.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/server/data/src/lib.rs b/server/data/src/lib.rs index 822d6997..fa078643 100644 --- a/server/data/src/lib.rs +++ b/server/data/src/lib.rs @@ -31,7 +31,7 @@ use hurrycurry_protocol::{ }; use serde::{Deserialize, Serialize}; use std::{ - collections::{BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, BTreeSet, HashMap, HashSet}, sync::RwLock, time::Duration, }; @@ -52,14 +52,16 @@ pub enum RecipeDeclAction { #[rustfmt::skip] #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RecipeDecl { - #[serde(default)] tile: Option<String>, + tile: Option<String>, #[serde(default)] inputs: Vec<String>, #[serde(default)] outputs: Vec<String>, #[serde(default)] action: RecipeDeclAction, #[serde(default)] warn: bool, - #[serde(default)] revert_duration: Option<f32>, - #[serde(default)] duration: Option<f32>, - #[serde(default)] points: Option<i64>, + revert_duration: Option<f32>, + duration: Option<f32>, + points: Option<i64>, + group: Option<String>, + #[serde(default)] group_hidden: bool, } #[rustfmt::skip] @@ -114,7 +116,8 @@ pub struct Serverdata { pub default_timer: Option<Duration>, pub book: Book, pub flags: ServerdataFlags, - pub entity_decls: Vec<EntityDecl> + pub entity_decls: Vec<EntityDecl>, + pub recipe_groups: BTreeMap<String, BTreeSet<ItemIndex>>, } #[rustfmt::skip] @@ -133,6 +136,7 @@ fn build_data( let mut recipes = Vec::new(); let mut entities = Vec::new(); let mut raw_demands = Vec::new(); + let mut recipe_groups = BTreeMap::<String, BTreeSet<ItemIndex>>::new(); for mut r in recipes_in { #[cfg(feature = "fast_recipes")] @@ -149,6 +153,11 @@ fn build_data( let mut inputs = r.inputs.into_iter().map(|i| reg.register_item(i)); let mut outputs = r.outputs.into_iter().map(|o| reg.register_item(o)); let tile = r.tile.map(|t| reg.register_tile(t)); + if let Some(g) = r.group { + if !r.group_hidden { + recipe_groups.entry(g).or_default().extend(inputs.clone()); + } + } match r.action { RecipeDeclAction::Never => {} RecipeDeclAction::Passive => recipes.push(Recipe::Passive { @@ -327,6 +336,7 @@ fn build_data( book: Book::default(), score_baseline: map_in.score_baseline, entity_decls: entities, + recipe_groups, }, )) } |