SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
Scene.h
1#ifndef Scene_H
2#define Scene_H
3
4#include "AzulCore.h"
5#include "../GameObject/Alarmable/AlarmableManager.h"
6#include "../GameObject/Collidable/CollisionManager.h"
8
9class CommandBase;
10class Alarmable;
11class Collidable;
12class Drawable;
13class DrawableManager;
14class Inputable;
16class Updatable;
18class CameraManager;
20class Terrain;
21class TerrainManager;
22
31class Scene
32{
33public:
34 Scene();
35 Scene(const Scene&) = delete;
36 Scene& operator=(const Scene&) = delete;
37 virtual ~Scene();
38
43 void SetCurrentCamera(Camera* cam);
44
49 Camera* GetCurrentCamera() const;
50
55 void SetCurrentCamera2D(Camera* cam);
56
61 Camera* GetCurrentCamera2D() const;
62
67 void SetTerrain(const std::string& key);
68
73 Terrain* GetTerrain() const;
74
75private:
76 friend class SceneAttorney;
77
82
87
92
97
102
107
112
117
121 virtual void Initialize() = 0;
122
126 void Update();
127
131 void Draw();
132
136 virtual void SceneEnd() = 0;
137
142 void Register(Updatable* up);
143
148 void Deregister(Updatable* up);
149
154 void Register(Drawable* dr);
155
160 void Deregister(Drawable* dr);
161
168 void Register(Alarmable* al, AlarmableManager::ALARM_ID id, float t);
169
176
183 void Register(Inputable* in, AZUL_KEY k, EventType e);
184
191 void Deregister(Inputable* in, AZUL_KEY k, EventType e);
192
199 void Register(Inputable* in, AZUL_MOUSE m, EventType e);
200
207 void Deregister(Inputable* in, AZUL_MOUSE m, EventType e);
208
213 void SubmitCommand(CommandBase* cmd);
214
220
221protected:
226 template <typename C>
228 {
229 collisionManager->SetCollisionSelf<C>();
230 }
231
237 template <typename C1, typename C2>
239 {
240 collisionManager->SetCollisionPair<C1, C2>();
241 }
242
247 template <typename Type>
249 {
250 if (GetTerrain() != nullptr)
251 {
252 collisionManager->SetCollisionTerrain<Type>();
253 }
254 else
255 {
256 DebugMsg::out("Error: No terrain set for the scene. Call SetTerrain() before setting collision.\n");
257 assert(false);
258 }
259 }
260};
261
262#endif
Defines the event types for input handling.
EventType
Enum class representing the types of input events.
Definition EventType.h:19
Base class for objects that can have alarms triggered in the game loop.
Definition Alarmable.h:19
Manages the registration and processing of alarms for GameObjects.
Definition AlarmableManager.h:16
ALARM_ID
Enum class representing the alarm IDs.
Definition AlarmableManager.h:22
Manages the current and default cameras for both 3D and 2D views.
Definition CameraManager.h:14
Base class for objects that can participate in collision detection.
Definition Collidable.h:26
Manages the registration and processing of collisions for GameObjects.
Definition CollisionManager.h:24
Base class for all command objects.
Definition CommandBase.h:19
Base class for objects that can be drawn in the game loop.
Definition Drawable.h:19
Manages the registration and processing of drawable GameObjects.
Definition DrawableManager.h:16
Base class for objects that can handle keyboard input events.
Definition Inputable.h:23
Manages the registration and processing of keyboard events for GameObjects.
Definition KeyboardEventManager.h:19
virtual void SceneEnd()=0
Ends the scene. Defined by the user.
CollisionManager * GetCollisionManager()
Gets the collision manager for the scene.
Definition Scene.cpp:133
void SubmitCommand(CommandBase *cmd)
Submits a command to the scene.
Definition Scene.cpp:128
Camera * GetCurrentCamera() const
Gets the current camera for the scene.
Definition Scene.cpp:42
UpdatableManager * updatableManager
Pointer to the updatable manager.
Definition Scene.h:91
void Register(Updatable *up)
Registers an updatable GameObject.
Definition Scene.cpp:78
DrawableManager * drawableManager
Pointer to the drawable manager.
Definition Scene.h:106
void Draw()
Draws the scene.
Definition Scene.cpp:148
Terrain * GetTerrain() const
Sets the terrain for the scene using a pointer to a Terrain object.
Definition Scene.cpp:73
void Update()
Updates the scene. Specifically, the broker and managers other than draw.
Definition Scene.cpp:138
void SetCollisionPair()
Sets the collision pair test for the specified collidable types.
Definition Scene.h:238
AlarmableManager * alarmableManager
Pointer to the alarmable manager.
Definition Scene.h:96
void SetTerrain(const std::string &key)
Sets the terrain for the scene using a key.
Definition Scene.cpp:57
void SetCollisionTerrain()
Sets up collision detection between the specified type and the current terrain.
Definition Scene.h:248
Camera * GetCurrentCamera2D() const
Gets the current 2D camera for the scene.
Definition Scene.cpp:52
KeyboardEventManager * keyboardEventManager
Pointer to the keyboard event manager.
Definition Scene.h:101
void SetCurrentCamera(Camera *cam)
Sets the current 3D camera for the scene.
Definition Scene.cpp:37
TerrainManager * terrainManager
Pointer to the current terrain.
Definition Scene.h:116
CollisionManager * collisionManager
Pointer to the collision manager.
Definition Scene.h:111
virtual void Initialize()=0
Initializes the scene. Defined by the user.
SceneRegistrationBroker * registrationBroker
Pointer to the scene registration broker.
Definition Scene.h:86
void Deregister(Updatable *up)
Deregisters an updatable GameObject.
Definition Scene.cpp:83
CameraManager * cameraManager
Pointer to the camera manager.
Definition Scene.h:81
void SetCollisionSelf()
Sets the collision self test for the specified collidable type.
Definition Scene.h:227
void SetCurrentCamera2D(Camera *cam)
Sets the current 2D camera for the scene.
Definition Scene.cpp:47
Manages the registration and execution of commands for scene registration.
Definition SceneRegistrationBroker.h:15
Represents a 3D terrain generated from a heightmap.
Definition Terrain.h:18
Manages the active Terrain instance in the scene.
Definition TerrainManager.h:16
Base class for objects that can be updated in the game loop.
Definition Updatable.h:19
Manages the registration and processing of updatable GameObjects.
Definition UpdatableManager.h:18