feat: Add shovel asset and inventory helper (#15)

This commit is contained in:
demenik
2025-12-09 17:21:54 +01:00
parent 51f1f54b7d
commit a96ad857a6
2 changed files with 10 additions and 8 deletions

BIN
assets/shovel.aseprite Normal file

Binary file not shown.

View File

@@ -80,8 +80,8 @@ impl ItemType {
aseprite: asset_server.load("berry.aseprite"),
},
ItemType::Shovel => AseSlice {
name: "Berry".into(),
aseprite: asset_server.load("berry.aseprite"),
name: "Shovel".into(),
aseprite: asset_server.load("shovel.aseprite"),
},
ItemType::BerrySeed { name } => {
let seed_config = game_config.berry_seeds.iter().find(|s| s.name == *name);
@@ -114,12 +114,14 @@ pub struct Inventory {
}
impl Inventory {
pub fn has_item(&self, items_query: Query<&ItemStack>) -> bool {
self.items
.iter()
.map(|entity| items_query.get(*entity).ok())
.find(|option| option.is_some())
.is_some()
pub fn has_item_type(&self, items_query: &Query<&ItemStack>, item_type: ItemType) -> bool {
self.items.iter().any(|&entity| {
if let Ok(stack) = items_query.get(entity) {
stack.item_type == item_type
} else {
false
}
})
}
pub fn update_item_stack(