From 48c24ec8b011d081550dc78329cbe61de67b30e9 Mon Sep 17 00:00:00 2001 From: troido Date: Sun, 5 Apr 2020 20:04:33 +0200 Subject: items are now mostly replaced by itemids, with a mapping to the item in the encyclopedia --- src/components/inventory.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/components/inventory.rs') 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, pub capacity: usize } impl Component for Inventory { @@ -19,9 +27,9 @@ impl Inventory { fn equipped(&self) -> Vec { 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!"); -- cgit