summaryrefslogtreecommitdiff
path: root/engine-ocean/Game/Systems/Inventory/inventorysystem.h
blob: 4305f68b2b99059c7c799d7287728f2e286aab0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef INVENTORYSYSTEM_H
#define INVENTORYSYSTEM_H


#include "Game/GameWorld.h"
#include <map>
#include "inventoryitem.h"

//struct InventoryItem{
//    TextureData lootLabelUI;
//    TextureData lootInventoryUI;
//    int inventoryCount = 0;

//    InventoryItem(TextureData label, TextureData inventory):
//        lootLabelUI(label),
//        lootInventoryUI(inventory)
//    {}
//};

class InventorySystem : public System
{
public:
    InventorySystem(std::map<std::string, std::shared_ptr<GameObject>>& gameobjects,
                    std::map<std::string, std::shared_ptr<GameObject>>& all_gameobjects,
                    std::map<std::string, std::vector<std::shared_ptr<GameObject>>>& lootables,
                                     std::map<int, Input>& input_map,
                                        std::shared_ptr<Camera>& camera,
                    std::set<std::string>& m_shownScreens);
    ~InventorySystem();
    void draw() override;
    void update(double deltaTime) override;
    void scrollEvent(double distance) override;
    void mousePosEvent(double xpos, double ypos) override;
    void drawUIText();
    void onWindowResize(int width, int height);



private:
    void addToInventory(std::shared_ptr<GameObject> &go);
    bool withinPlayerReach(const std::shared_ptr<GameObject> &go);
    void initializeInventory(std::string itemName, const char* label_filename, const char* inventory_filename);





    int m_bamboo_count = 0;
    std::map<std::string, std::shared_ptr<GameObject>>& m_dynamic_gameobjects;

    // maps loot id to game objects/associated textures
    std::map<std::string, std::vector<std::shared_ptr<GameObject>>>& m_lootables; // holds position
    std::map<std::string, std::shared_ptr<InventoryItem>> m_inventoryItems;

    std::map<int, Input>& m_input_map;
     std::shared_ptr<Camera>& m_camera;

     //std::set<std::string> m_inventoryScreens; // stores ids of all scenes in which inventory is rendered
     std::set<std::string>& m_shownScreens;

     std::vector<float> m_quadPos = {
         -1.0f, 1.0f,
         -1.0f, -1.0f,
         1.0f, 1.0f,
         1.0f, -1.0f
     };

     GLuint m_screenVAO;
     GLuint m_texID;

     glm::vec2 m_offset = glm::vec2(.2f);

     std::shared_ptr<UIDisplay> m_sparkle;

     std::map<std::string, std::shared_ptr<GameObject>>& m_all_gameobjects;
};

#endif // INVENTORYSYSTEM_H