summaryrefslogtreecommitdiff
path: root/server/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/data')
-rw-r--r--server/src/data/index.rs25
-rw-r--r--server/src/data/mod.rs1
2 files changed, 26 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);
+ }
+ _ => (),
+ }
+ }
+ }
+}
diff --git a/server/src/data/mod.rs b/server/src/data/mod.rs
index 12d4f23e..246f695e 100644
--- a/server/src/data/mod.rs
+++ b/server/src/data/mod.rs
@@ -17,6 +17,7 @@
*/
pub mod demands;
+pub mod index;
use crate::entity::{construct_entity, Entities, EntityDecl};
use anyhow::{anyhow, bail, Result};