feat: Add has_item helper to Inventory
This commit is contained in:
@@ -114,6 +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 update_item_stack(
|
||||
&mut self,
|
||||
commands: &mut Commands,
|
||||
|
||||
Reference in New Issue
Block a user