#ifndef GameWorld_H #define GameWorld_H #include "Game/Environment/environmentsystem.h" #include "Game/Systems/CollisionSystems/environmentcollisiondetectionsystem.h" #include "Game/Systems/aisystem.h" #include "Game/Systems/system.h" #include "Graphics/global.h" #include "Graphics/camera.h" #include #include "screen.h" #include struct Input { // key presses int inputVal = 0; // mouse clicks int xpos; int ypos; // mouse scrolls double distance; glm::vec3 translationDir = glm::vec3(0.f); bool isActive = false; bool isHeld = false; bool isClicked = false; int checkClickTime = 0; }; class GameWorld { public: GameWorld(std::map& input_map); void update(double deltaTime); void draw(); void keyEvent(int key, int action); void mousePosEvent(double xpos, double ypos); void mouseButtonEvent(int button, int action); void scrollEvent(double distance); void windowResizeEvent(int width, int height); void framebufferResizeEvent(int width, int height); template void addSystem(std::shared_ptr &&component){ m_systems.put(std::forward>(component)); } template T* getSystem(){ auto comp = m_systems.find(); assert(comp != m_systems.end()); return static_cast(comp->second.get()); } template void removeSystem(){ m_external_systems.remove(); } template void addExternalSystem(std::shared_ptr &&component){ m_external_systems.put(std::forward>(component)); } template T* getExternalSystem(){ auto comp = m_external_systems.find(); assert(comp != m_external_systems.end()); return static_cast(comp->second.get()); } template void removeExternalSystem(){ m_external_systems.remove(); } private: // GLuint VAO, VBO; // GLuint grass_tex, wind_tex; // std::vector positions; std::map m_input_map; void createKeyInput(int inputVal); void initializeInputMap(); void reset(); void initializeGrassVBO(); TypeMap> m_systems; TypeMap> m_external_systems; std::shared_ptr camera; std::map> m_gameobjects; std::vector m_game_object_names; std::map> m_dynamic_gameobjects; std::vector m_dynamic_game_object_names; std::map> m_rigid_gameobjects; std::vector m_rigid_game_object_names; std::shared_ptr collisionSystem; std::shared_ptr environmentSystem; // map that contains submaps of each data type std::map m_global_blackboard; bool m_checkingMouseClick = false; int m_mouseIsHeldTime = 0; glm::vec2 m_mousePos; std::map>> m_lootables; std::set m_shownScreens; }; #endif // GameWorld_H