summaryrefslogtreecommitdiff
path: root/server/src/data/index.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/data/index.rs')
-rw-r--r--server/src/data/index.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/server/src/data/index.rs b/server/src/data/index.rs
new file mode 100644
index 00000000..1c206d83
--- /dev/null
+++ b/server/src/data/index.rs
@@ -0,0 +1,25 @@
+use hurrycurry_protocol::{Gamedata, ItemIndex, Recipe, RecipeIndex};
+use std::collections::HashMap;
+
+#[derive(Debug, Default)]
+pub struct GamedataIndex {
+ pub recipe_passive_by_input: HashMap<ItemIndex, Vec<RecipeIndex>>,
+}
+
+impl GamedataIndex {
+ pub fn update(&mut self, data: &Gamedata) {
+ self.recipe_passive_by_input.clear();
+
+ for (ri, r) in data.recipes() {
+ match r {
+ Recipe::Passive { input, .. } => {
+ self.recipe_passive_by_input
+ .entry(*input)
+ .or_default()
+ .push(ri);
+ }
+ _ => (),
+ }
+ }
+ }
+}