diff options
| author | troido <troido@protonmail.com> | 2020-04-05 20:04:33 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-05 20:04:33 +0200 |
| commit | 48c24ec8b011d081550dc78329cbe61de67b30e9 (patch) | |
| tree | d2d700897dc5ba3d0f52e8a1cd57c0f4880272fd /src/components/inventory.rs | |
| parent | 84c70cee089b72720a85d285ee0437b65be298b9 (diff) | |
items are now mostly replaced by itemids, with a mapping to the item in the encyclopedia
Diffstat (limited to 'src/components/inventory.rs')
| -rw-r--r-- | src/components/inventory.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/components/inventory.rs b/src/components/inventory.rs index 81064d8..c3282e9 100644 --- a/src/components/inventory.rs +++ b/src/components/inventory.rs @@ -1,14 +1,22 @@ use std::collections::HashMap; use specs::{Component, FlaggedStorage, HashMapStorage}; -use super::{ +use crate::{ + ItemId, item::{Item, ItemAction}, - equipment::{Stat, Equippable}, + components::equipment::{Stat, Equippable}, }; +#[derive(Debug, Clone)] +pub struct InventoryEntry { + pub itemid: ItemId, + pub item: Item, + pub is_equipped: bool +} + #[derive(Debug, Clone, Default)] pub struct Inventory { - pub items: Vec<(Item, bool)>, + pub items: Vec<InventoryEntry>, pub capacity: usize } impl Component for Inventory { @@ -19,9 +27,9 @@ impl Inventory { fn equipped(&self) -> Vec<Equippable> { let mut equippables = Vec::new(); - for (item, is_equipped) in self.items.iter() { - if *is_equipped { - if let ItemAction::Equip(equippable) = &item.action { + for entry in self.items.iter() { + if entry.is_equipped { + if let ItemAction::Equip(equippable) = &entry.item.action { equippables.push(equippable.clone()); } else { panic!("unequippable item equipped!"); |
