summaryrefslogtreecommitdiff
path: root/server/src/interaction.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/interaction.rs')
-rw-r--r--server/src/interaction.rs51
1 files changed, 29 insertions, 22 deletions
diff --git a/server/src/interaction.rs b/server/src/interaction.rs
index a8f80bd8..0721fa81 100644
--- a/server/src/interaction.rs
+++ b/server/src/interaction.rs
@@ -20,6 +20,8 @@ use hurrycurry_protocol::{Gamedata, ItemLocation, PacketC, PlayerID, Recipe, Sco
use log::info;
use std::collections::VecDeque;
+use crate::data::index::GamedataIndex;
+
pub fn interact(
data: &Gamedata,
edge: bool,
@@ -206,9 +208,11 @@ pub enum TickEffect {
ClearProgress,
Produce,
}
+
pub fn tick_slot(
dt: f32,
data: &Gamedata,
+ data_index: &GamedataIndex,
tile: Option<TileIndex>,
slot: &mut Option<Item>,
slot_loc: ItemLocation,
@@ -272,28 +276,31 @@ pub fn tick_slot(
return;
}
} else {
- for (ri, recipe) in data.recipes() {
- if recipe.supports_tile(tile) {
- if let Recipe::Passive {
- input, warn, speed, ..
- } = recipe
- {
- if *input == item.kind {
- item.active = Some(Involvement {
- player: None,
- recipe: ri,
- position: 0.,
- warn: *warn,
- speed: *speed,
- });
- packet_out.push_back(PacketC::SetProgress {
- player: None,
- position: 0.,
- speed: *speed,
- warn: *warn,
- item: slot_loc,
- });
- return;
+ if let Some(recipes) = data_index.recipe_passive_by_input.get(&item.kind) {
+ for &ri in recipes {
+ let recipe = data.recipe(ri);
+ if recipe.supports_tile(tile) {
+ if let Recipe::Passive {
+ input, warn, speed, ..
+ } = recipe
+ {
+ if *input == item.kind {
+ item.active = Some(Involvement {
+ player: None,
+ recipe: ri,
+ position: 0.,
+ warn: *warn,
+ speed: *speed,
+ });
+ packet_out.push_back(PacketC::SetProgress {
+ player: None,
+ position: 0.,
+ speed: *speed,
+ warn: *warn,
+ item: slot_loc,
+ });
+ return;
+ }
}
}
}