Saga
Saga Game Engine
|
Manages Systems in the ECS model. Allows for System to be added, but not invoked. More...
#include <systemManager.h>
Public Types | |
enum class | Stage { Awake , Start , PreUpdate , Update , LateUpdate , FixedUpdate , LateFixedUpdate , Draw , Cleanup } |
Stages in the Saga engine where systems can be set to run in. Awake is a stage that happens at the very start of an entity. Start happens on the firsts frame. Every frame thereafter, PreUpdate, Update, and LateUpdate is called. FixedUpdate is called on every physics frame, and so is LateFixedUpdate. The Draw stage happens at the end of every frame, where we have to render the output to the screen. More... | |
enum | Id : uint64_t |
Used for id of Systems. More... | |
Public Member Functions | |
SystemManager () | |
virtual | ~SystemManager () |
template<typename ... DataType> | |
EventMap::Id | addStagedSystem (std::shared_ptr< System< DataType... > > system, Stage stage=Stage::Update) |
Add a staged System to the list of systems. | |
void | removeStagedSystem (EventMap::Id id, Stage stage=Stage::Update) |
Remove a staged System. | |
template<typename Event , typename ... DataType> | |
EventMap::Id | addEventSystem (Event event, std::shared_ptr< System< DataType... > > system) |
Add an event System. Event systems are Systems triggerable by events broadcasted by the program, and not neccessarily the stages in normal execution. These Systems only respond to when events are being broadcasted. | |
template<typename Event > | |
void | removeEventSystem (Event event, EventMap::Id id) |
Remove the System from being called when an event is broadcasted. | |
template<typename Event , typename ... DataType> | |
EventMap::Id | addEventSystem (Event event, Saga::Entity entity, std::shared_ptr< System< Saga::Entity, DataType... > > system) |
Add an event System specific to an entity. This event System will be triggered when that event is delivered to the entity. | |
template<typename Event > | |
void | removeEventSystem (Event event, Saga::Entity entity, EventMap::Id id) |
Remove the System from being called when an event is delivered. | |
EventMap::Id | addKeyboardEventSystem (int key, System< int > system) |
Add a System to respond to a keyboard input. | |
void | removeKeyboardEventSystem (int key, EventMap::Id id) |
Remove a keyboard System. | |
EventMap::Id | addMouseEventSystem (int key, System< int > system) |
Add a System to respond to a mouse button inputs. | |
void | removeMouseEventSystem (int key, EventMap::Id id) |
Remove a System from responding to mouse button inputs. | |
EventMap::Id | addMousePosSystem (System< double, double > system) |
Add a System to receive mouse position. | |
void | removeMousePosSystem (EventMap::Id id) |
EventMap::Id | addScrollSystem (System< double > system) |
Add a System to receive scroll input. | |
void | removeScrollSystem (EventMap::Id id) |
EventMap::Id | addWindowResizeSystem (System< int, int > system) |
Add a System to receive when the window resize. | |
void | removeWindowResizeSystem (EventMap::Id id) |
Remove a resize System. | |
Protected Types | |
enum class | OtherInput { MOUSE_POS , SCROLL , WINDOW_RESIZE } |
Types of input events, with button events excluded. More... | |
Static Protected Member Functions | |
static auto | id_value () -> uint64_t & |
Protected Attributes | |
EventMap | stagedSystemsMap |
Map between Stage and Systems. | |
std::unordered_map< int, EventMap > | eventSystemsMap |
Maps entity to an EventMap that maps Event to System. | |
EventMap | keyboardInputMap |
EventMap | mouseInputMap |
EventMap | otherInputMap |
Manages Systems in the ECS model. Allows for System to be added, but not invoked.
enum Saga::SystemManager::Id : uint64_t |
Used for id of Systems.
|
strongprotected |
|
strong |
Stages in the Saga engine where systems can be set to run in. Awake is a stage that happens at the very start of an entity. Start happens on the firsts frame. Every frame thereafter, PreUpdate, Update, and LateUpdate is called. FixedUpdate is called on every physics frame, and so is LateFixedUpdate. The Draw stage happens at the end of every frame, where we have to render the output to the screen.
Enumerator | |
---|---|
Awake | |
Start | |
PreUpdate | |
Update | |
LateUpdate | |
FixedUpdate | |
LateFixedUpdate | |
Draw | |
Cleanup |
Saga::SystemManager::SystemManager | ( | ) |
|
virtual |
EventMap::Id Saga::SystemManager::addEventSystem | ( | Event | event, |
Saga::Entity | entity, | ||
std::shared_ptr< System< Saga::Entity, DataType... > > | system | ||
) |
Add an event System specific to an entity. This event System will be triggered when that event is delivered to the entity.
Event | can be anything castable to an integer. |
DataType | the data type the System accepts as argument. |
event | |
entity | |
system |
EventMap::Id Saga::SystemManager::addEventSystem | ( | Event | event, |
std::shared_ptr< System< DataType... > > | system | ||
) |
Add an event System. Event systems are Systems triggerable by events broadcasted by the program, and not neccessarily the stages in normal execution. These Systems only respond to when events are being broadcasted.
Event | could be anything castable to an integer. |
DataType | the data types that the Systems that receive these events accept. |
event | the event. |
system | the System to add. |
EventMap::Id Saga::SystemManager::addKeyboardEventSystem | ( | int | key, |
System< int > | system | ||
) |
Add a System to respond to a keyboard input.
key | key as an GLFW enum. |
system | System to receive the key input. |
EventMap::Id Saga::SystemManager::addMouseEventSystem | ( | int | key, |
System< int > | system | ||
) |
Add a System to respond to a mouse button inputs.
key | key as an GLFW enum. |
system |
EventMap::Id Saga::SystemManager::addMousePosSystem | ( | System< double, double > | system | ) |
Add a System to receive mouse position.
system | must accept <double, double> as the position of the mouse in screen space. |
EventMap::Id Saga::SystemManager::addScrollSystem | ( | System< double > | system | ) |
Add a System to receive scroll input.
system | must accept <double> as the amount of pixels scrolled. |
EventMap::Id Saga::SystemManager::addStagedSystem | ( | std::shared_ptr< System< DataType... > > | system, |
Stage | stage = Stage::Update |
||
) |
Add a staged System to the list of systems.
DataType | the data types that the System accepts. |
system | |
stage | which stage is the System attached to. When this stage is invoked, all systems attached to the stage is invoked. |
EventMap::Id Saga::SystemManager::addWindowResizeSystem | ( | System< int, int > | system | ) |
Add a System to receive when the window resize.
system | must accept <int,int> as the dimensions of the window after resized. |
|
inlinestaticprotected |
void Saga::SystemManager::removeEventSystem | ( | Event | event, |
EventMap::Id | id | ||
) |
Remove the System from being called when an event is broadcasted.
Event | can be anything castable to an integer. |
event | the event. |
id | the id of the System to be removed. |
void Saga::SystemManager::removeEventSystem | ( | Event | event, |
Saga::Entity | entity, | ||
EventMap::Id | id | ||
) |
Remove the System from being called when an event is delivered.
Event | can be anything castable to an int. |
event | |
entity | |
id |
void Saga::SystemManager::removeKeyboardEventSystem | ( | int | key, |
EventMap::Id | id | ||
) |
Remove a keyboard System.
key | |
id |
void Saga::SystemManager::removeMouseEventSystem | ( | int | key, |
EventMap::Id | id | ||
) |
Remove a System from responding to mouse button inputs.
key | key as an GLFW enum. |
id |
void Saga::SystemManager::removeMousePosSystem | ( | EventMap::Id | id | ) |
void Saga::SystemManager::removeScrollSystem | ( | EventMap::Id | id | ) |
void Saga::SystemManager::removeStagedSystem | ( | EventMap::Id | id, |
Stage | stage = Stage::Update |
||
) |
Remove a staged System.
id | the id of the system to be removed. |
stage | the stageSof the System. |
void Saga::SystemManager::removeWindowResizeSystem | ( | EventMap::Id | id | ) |
Remove a resize System.
id |
|
protected |
Maps entity to an EventMap that maps Event to System.
|
protected |
|
protected |
|
protected |