r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
Engine.hpp
Go to the documentation of this file.
1///
2/// @file Engine.hpp
3/// @brief This file contains the Engine class declaration
4/// @namespace eng
5///
6
7#pragma once
8
9#include <functional>
10#include <memory>
11
13#include "ECS/Registry.hpp"
15#include "Interfaces/IAudio.hpp"
18#include "Utils/Clock.hpp"
19
20namespace eng
21{
22
23 enum State : unsigned char
24 {
25 STOP = 0,
26 RUN = 1,
28 };
29
30 ///
31 /// @class Engine
32 /// @brief Class for the game engine
33 /// @namespace eng
34 ///
35 class Engine
36 {
37
38 public:
39 Engine(const std::function<std::shared_ptr<IAudio>()> &audioFactory,
40 const std::function<std::shared_ptr<INetworkClient>()> &networkFactory,
41 const std::function<std::shared_ptr<IRenderer>()> &rendererFactory);
42 ~Engine() = default;
43
44 Engine(const Engine &) = delete;
45 Engine &operator=(const Engine &) = delete;
46 Engine(Engine &&) = delete;
47 Engine &operator=(Engine &&) = delete;
48
49 std::shared_ptr<IAudio> &getAudio() { return m_audio; }
50 std::shared_ptr<INetworkClient> &getNetwork() { return m_network; }
51 std::shared_ptr<IRenderer> &getRenderer() { return m_renderer; }
52 std::unique_ptr<utl::Clock> &getClock() { return m_clock; }
53 std::unique_ptr<SceneManager> &getSceneManager() { return m_sceneManager; }
54 State getState() const { return m_state; }
55
56 void addSystem(std::unique_ptr<ISystem> system) { m_systems.emplace_back(std::move(system)); }
57 void setState(const State newState) { m_state = newState; }
58
59 void render(ecs::Registry &registry, Color clearColor, float dt) const;
60 void stop() const { m_renderer->closeWindow(); }
61
62 private:
63 void updateSystems(ecs::Registry &registry, float dt) const;
64
66 std::unique_ptr<utl::Clock> m_clock;
67 std::unique_ptr<SceneManager> m_sceneManager;
68 std::vector<std::unique_ptr<ISystem>> m_systems;
69 std::shared_ptr<IAudio> m_audio;
70 std::shared_ptr<INetworkClient> m_network;
71 std::shared_ptr<IRenderer> m_renderer;
72 }; // class Engine
73
74} // namespace eng
This file contains the Clock class.
This file contains the Audio interface.
This file contains the client network interface.
This file contains the IRenderer class declaration.
This file contains the Registry class declaration.
Class for managing entities and their components.
Definition Registry.hpp:25
Class for the game engine.
Definition Engine.hpp:36
std::shared_ptr< IAudio > & getAudio()
Definition Engine.hpp:49
std::unique_ptr< utl::Clock > & getClock()
Definition Engine.hpp:52
Engine(const std::function< std::shared_ptr< IAudio >()> &audioFactory, const std::function< std::shared_ptr< INetworkClient >()> &networkFactory, const std::function< std::shared_ptr< IRenderer >()> &rendererFactory)
Definition engine.cpp:3
std::shared_ptr< IRenderer > & getRenderer()
Definition Engine.hpp:51
std::unique_ptr< utl::Clock > m_clock
Definition Engine.hpp:66
std::shared_ptr< INetworkClient > m_network
Definition Engine.hpp:70
std::shared_ptr< IRenderer > m_renderer
Definition Engine.hpp:71
void setState(const State newState)
Definition Engine.hpp:57
State m_state
Definition Engine.hpp:65
~Engine()=default
void stop() const
Definition Engine.hpp:60
State getState() const
Definition Engine.hpp:54
Engine(Engine &&)=delete
Engine(const Engine &)=delete
std::unique_ptr< SceneManager > & getSceneManager()
Definition Engine.hpp:53
void addSystem(std::unique_ptr< ISystem > system)
Definition Engine.hpp:56
void updateSystems(ecs::Registry &registry, float dt) const
Definition engine.cpp:11
std::unique_ptr< SceneManager > m_sceneManager
Definition Engine.hpp:67
std::vector< std::unique_ptr< ISystem > > m_systems
Definition Engine.hpp:68
Engine & operator=(const Engine &)=delete
Engine & operator=(Engine &&)=delete
void render(ecs::Registry &registry, Color clearColor, float dt) const
Definition engine.cpp:19
std::shared_ptr< IAudio > m_audio
Definition Engine.hpp:69
std::shared_ptr< INetworkClient > & getNetwork()
Definition Engine.hpp:50
This file contains the SceneManager class declaration.
State
Definition Engine.hpp:24
@ STOP
Definition Engine.hpp:25
@ RUN
Definition Engine.hpp:26
@ DEFAULT
Definition Engine.hpp:27