Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
engine.h
Go to the documentation of this file.
1 #ifndef ENGINE_H
2 #define ENGINE_H
3 
4 #define GLFW_INCLUDE_GLCOREARB
5 
6 #include <memory>
7 #include "component_manager.h"
8 #include "utility/fps_counter.h"
9 #include "input/input_system.h"
14 #include "utility/config_manager.h"
15 #include "game/scene.h"
16 #include "utility/debug_parser.h"
17 #include "graphics/ui/text_area.h"
19 //#include "sound/sound_system.h"
20 
21 //= SCRIPTABLE
22 
26 class Engine : public std::enable_shared_from_this<Engine> {
27  private:
28  std::shared_ptr<ComponentManager> component_manager;
29  std::shared_ptr<Utility::FPSCounter> fps_counter;
30  std::shared_ptr<Input::InputSystem> input_system;
31  std::shared_ptr<Graphics::UI::FontGenerator> font_generator;
32  std::shared_ptr<Graphics::GraphicsSystem> graphics_system;
33  std::shared_ptr<Graphics::ShaderManager> shader_manager;
34  std::shared_ptr<Graphics::TextureManager> texture_manager;
35  std::shared_ptr<Utility::ConfigManager> config_manager;
36  std::shared_ptr<Script::ScriptingSystem> scripting_system;
37  //std::shared_ptr<Sound::SoundSystem> sound_system;
38 
39  //Bool represents if the scene is active;
40  std::map<std::shared_ptr<Game::Scene>, bool> scenes;
41 
42  float viewport_tile_width;
43  float viewport_tile_height;
44 
45  bool time_to_exit;
46  std::shared_ptr<Graphics::Camera> camera_component;
47 
48  void loadScriptingSystemSave();
49 
50  public:
51  Engine() = delete;
55  Engine(const std::string& config_path);
56 
60  virtual ~Engine() = default;
61 
62  //= BEGIN SCRIPTABLE
63 
69  void addScene(std::shared_ptr<Game::Scene> scene) noexcept;
77  std::shared_ptr<Game::Scene> findSceneByName(const std::string& name) noexcept;
78 
84  std::map<std::shared_ptr<Game::Scene>, bool> getScenes() const noexcept;
85 
91  void activateScene(const std::string& name);
97  void deactivateScene(const std::string& name);
103  std::vector<std::string> getSceneNames() const noexcept;
109  std::vector<std::string> getActiveSceneNames() const noexcept;
110 
114  void timeToExit() noexcept;
115  //= END SCRIPTABLE
116 
120  void setup();
124  void mainLoop();
128  void cleanUp();
129 
130 };
131 
132 #endif
void deactivateScene(const std::string &name)
Deactivates a scene by name.
Definition: engine.cpp:74
std::vector< std::string > getSceneNames() const noexcept
Gets the scene names.
Definition: engine.cpp:83
void cleanUp()
Cleans up before exiting.
Definition: engine.cpp:172
void activateScene(const std::string &name)
Activates a scene by name.
Definition: engine.cpp:62
void addScene(std::shared_ptr< Game::Scene > scene) noexcept
Adds a scene to the engine.
Definition: engine.cpp:30
Engine()=delete
void mainLoop()
Triggers the main loop for the engine.
Definition: engine.cpp:152
std::vector< std::string > getActiveSceneNames() const noexcept
Gets the active scene names.
Definition: engine.cpp:92
virtual ~Engine()=default
Engine destructor.
void timeToExit() noexcept
This is to signal the engine that it is time to shut down.
Definition: engine.cpp:26
std::shared_ptr< Game::Scene > findSceneByName(const std::string &name) noexcept
Finds a scene by name.
Definition: engine.cpp:34
void setup()
Sets up the engine.
Definition: engine.cpp:107
std::map< std::shared_ptr< Game::Scene >, bool > getScenes() const noexcept
Gets the scenes.
Definition: engine.cpp:57
Class for engine.
Definition: engine.h:26