diff options
author | metamuffin <metamuffin@disroot.org> | 2025-10-07 00:13:56 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-10-07 00:14:00 +0200 |
commit | f6458b62e733de11e3665c83bcde4fd4051d7842 (patch) | |
tree | 540942eeee8381d289022668d8cf81f6a73f75a5 /server/data/src/lib.rs | |
parent | dfa1adc6f7e2d57c1897223d1620f28140b518e8 (diff) | |
download | hurrycurry-f6458b62e733de11e3665c83bcde4fd4051d7842.tar hurrycurry-f6458b62e733de11e3665c83bcde4fd4051d7842.tar.bz2 hurrycurry-f6458b62e733de11e3665c83bcde4fd4051d7842.tar.zst |
Book pages from recipe groups
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, }, )) } |