diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-01-10 17:16:03 +0100 |
|---|---|---|
| committer | tpart <tpart120@proton.me> | 2026-02-26 20:48:35 +0100 |
| commit | b634bad931f530ee0a207e1461ffc5e52ebb83e3 (patch) | |
| tree | 90a45e8c67e6a7c66e49c7409f0c37881eade96e /server/game-core/src/interaction.rs | |
| parent | 0ed9e8387a66b3af78412feea62fdc8b9804f793 (diff) | |
| download | hurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar hurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar.bz2 hurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar.zst | |
compiles with tile stacks
Diffstat (limited to 'server/game-core/src/interaction.rs')
| -rw-r--r-- | server/game-core/src/interaction.rs | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/server/game-core/src/interaction.rs b/server/game-core/src/interaction.rs index 275e87d1..28efc43e 100644 --- a/server/game-core/src/interaction.rs +++ b/server/game-core/src/interaction.rs @@ -33,9 +33,13 @@ impl Game { ItemLocation::Player(pid, _) => Some(pid), _ => None, }; - let this_tile_kind = match this_loc { - ItemLocation::Tile(t) => self.tiles.get(&t).map(|t| t.kind), - _ => None, + let this_tile_parts = match this_loc { + ItemLocation::Tile(t) => self + .tiles + .get(&t) + .map(|t| t.parts.clone()) + .unwrap_or_default(), + _ => Vec::new(), }; let (this_slot, other_slot) = match (this_loc, other_loc) { @@ -94,7 +98,7 @@ impl Game { && let Some(inv) = &mut item.active { let recipe = &self.data.recipe(inv.recipe); - if recipe.supports_tile(this_tile_kind) + if this_tile_parts.iter().any(|p| recipe.supports_tile(*p)) && let Recipe::Active { outputs, speed, .. } = recipe { if edge { @@ -142,7 +146,7 @@ impl Game { return Ok(()); } for (ri, recipe) in self.data.recipes() { - if !recipe.supports_tile(this_tile_kind) { + if !this_tile_parts.iter().any(|p| recipe.supports_tile(*p)) { continue; } match recipe { @@ -238,7 +242,7 @@ impl Game { } let can_place = automated - || this_tile_kind.is_none_or(|tile| { + || this_tile_parts.iter().any(|tile| { other_slot.as_ref().is_some_and(|other| { self.data .tile_placeable_items @@ -276,9 +280,13 @@ impl Game { } pub fn tick_slot(&mut self, loc: ItemLocation, dt: f32) -> Result<(), TrError> { - let tile = match loc { - ItemLocation::Tile(t) => self.tiles.get(&t).map(|t| t.kind), - _ => None, + let parts = match loc { + ItemLocation::Tile(t) => self + .tiles + .get(&t) + .map(|t| t.parts.clone()) + .unwrap_or_default(), + _ => Vec::new(), }; let slot = match loc { ItemLocation::Tile(p) => { @@ -303,7 +311,7 @@ impl Game { let r = &self.data.recipe(a.recipe); let prev_speed = a.speed; - if r.supports_tile(tile) { + if parts.iter().any(|p| r.supports_tile(*p)) { if a.speed <= 0. && let Recipe::Passive { speed, .. } = &self.data.recipe(a.recipe) { @@ -355,7 +363,7 @@ impl Game { } else if let Some(recipes) = self.data_index.recipe_passive_by_input.get(&item.kind) { for &ri in recipes { let recipe = self.data.recipe(ri); - if recipe.supports_tile(tile) + if parts.iter().any(|p| recipe.supports_tile(*p)) && let Recipe::Passive { input, warn, speed, .. } = recipe |