refactor: Refactor interaction option logic

This commit is contained in:
demenik
2025-12-02 16:22:12 +01:00
parent c60b2ce2b3
commit 76a0c4340c

View File

@@ -32,31 +32,29 @@ impl InteractionAction {
) -> Vec<InteractionAction> { ) -> Vec<InteractionAction> {
let mut options: Vec<InteractionAction> = vec![]; let mut options: Vec<InteractionAction> = vec![];
for &entity in &inventory.items {
let Ok(stack) = item_query.get(entity) else {
continue;
};
if stack.amount <= 0 {
continue;
}
match tile_state {
TileState::Empty => match &stack.item_type {
ItemType::BerrySeed { .. } => {
options.push(InteractionAction::Plant(stack.item_type.clone()));
}
_ => (),
},
_ => (),
}
}
match tile_state { match tile_state {
TileState::Occupied { watered, .. } => { TileState::Occupied { watered, .. } => {
if !*watered { if !*watered {
options.push(InteractionAction::Water); options.push(InteractionAction::Water);
} }
} }
TileState::Empty => {
for &entity in &inventory.items {
let Ok(stack) = item_query.get(entity) else {
continue;
};
if stack.amount <= 0 {
continue;
}
match &stack.item_type {
ItemType::BerrySeed { .. } => {
options.push(InteractionAction::Plant(stack.item_type.clone()));
}
_ => (),
}
}
}
_ => (), _ => (),
} }