aboutsummaryrefslogtreecommitdiff
path: root/server/game-core/src/interaction.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/game-core/src/interaction.rs')
-rw-r--r--server/game-core/src/interaction.rs30
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