feat: Add shovel asset and inventory helper (#15)
This commit is contained in:
BIN
assets/shovel.aseprite
Normal file
BIN
assets/shovel.aseprite
Normal file
Binary file not shown.
@@ -80,8 +80,8 @@ impl ItemType {
|
|||||||
aseprite: asset_server.load("berry.aseprite"),
|
aseprite: asset_server.load("berry.aseprite"),
|
||||||
},
|
},
|
||||||
ItemType::Shovel => AseSlice {
|
ItemType::Shovel => AseSlice {
|
||||||
name: "Berry".into(),
|
name: "Shovel".into(),
|
||||||
aseprite: asset_server.load("berry.aseprite"),
|
aseprite: asset_server.load("shovel.aseprite"),
|
||||||
},
|
},
|
||||||
ItemType::BerrySeed { name } => {
|
ItemType::BerrySeed { name } => {
|
||||||
let seed_config = game_config.berry_seeds.iter().find(|s| s.name == *name);
|
let seed_config = game_config.berry_seeds.iter().find(|s| s.name == *name);
|
||||||
@@ -114,12 +114,14 @@ pub struct Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Inventory {
|
impl Inventory {
|
||||||
pub fn has_item(&self, items_query: Query<&ItemStack>) -> bool {
|
pub fn has_item_type(&self, items_query: &Query<&ItemStack>, item_type: ItemType) -> bool {
|
||||||
self.items
|
self.items.iter().any(|&entity| {
|
||||||
.iter()
|
if let Ok(stack) = items_query.get(entity) {
|
||||||
.map(|entity| items_query.get(*entity).ok())
|
stack.item_type == item_type
|
||||||
.find(|option| option.is_some())
|
} else {
|
||||||
.is_some()
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_item_stack(
|
pub fn update_item_stack(
|
||||||
|
|||||||
Reference in New Issue
Block a user