aboutsummaryrefslogtreecommitdiffstats
path: root/include/inventory.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/inventory.hpp')
-rw-r--r--include/inventory.hpp44
1 files changed, 36 insertions, 8 deletions
diff --git a/include/inventory.hpp b/include/inventory.hpp
index fa24de4..44ed148 100644
--- a/include/inventory.hpp
+++ b/include/inventory.hpp
@@ -7,29 +7,57 @@
#include <events.hpp>
struct Item {
- GLuint icon;
+ std::string name;
+ std::string type;
+ int value;
+ int stackSize;
+ Texture sprite;
+
+ Item(void)
+ : value(0), stackSize(1) {}
+
+ Item(XMLElement *e) {
+ name = e->StrAttribute("name");
+ type = e->StrAttribute("type");
+
+ value = 0;
+ e->QueryIntAttribute("value", &value);
+ stackSize = 1;
+ e->QueryIntAttribute("maxStackSize", &stackSize);
+
+ sprite = Texture(e->StrAttribute("sprite"));
+ }
};
-using InventoryEntry = std::pair<Item, unsigned int>;
+struct InventoryEntry {
+ Item* item;
+ int count;
+ vec2 loc;
+
+ InventoryEntry(void)
+ : item(nullptr), count(0) {}
+};
class InventorySystem : public entityx::System<InventorySystem>, public entityx::Receiver<InventorySystem> {
private:
- entityx::Entity currentItemEntity;
-
std::vector<InventoryEntry> items;
- unsigned int maxItemCount;
public:
- InventorySystem(unsigned int mic = 1)
- : maxItemCount(mic) {}
+ InventorySystem(int size = 4) {
+ items.resize(size);
+ loadItems();
+ }
void configure(entityx::EventManager &ev);
- void loadIcons(void);
+ void loadItems(void);
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
void receive(const KeyDownEvent &kde);
+ void render(void);
+
+ void add(const std::string& name, int count);
};
#endif // INVENTORY_HPP_