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"),
|
||||
},
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user