Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::InvokableSystemManager Class Reference

A SystemManager where stages and events can be invoked. More...

#include <invokableSystemManager.h>

Inheritance diagram for Saga::InvokableSystemManager:
Collaboration diagram for Saga::InvokableSystemManager:

Public Member Functions

void runStageStartup (std::shared_ptr< GameWorld > gameWorld)
 Invoke the startup stage. This calls all systems attached in the Awake and Start stages.
 
void runStageUpdate (std::shared_ptr< GameWorld > gameWorld, float deltaTime, float time)
 Invoke the update stage. This calls any PreUpdate, Update, and LateUpdate systems in that order.
 
void runStageFixedUpdate (std::shared_ptr< GameWorld > gameWorld, float deltaTime, float time)
 Invoke the fixed update stage. This calls any FixUpdate, and LateFixedUpdate systems in that order.
 
void runStageDraw (std::shared_ptr< GameWorld > gameWorld)
 Invoke the Draw stage.
 
void runStageCleanup (std::shared_ptr< GameWorld > gameWorld)
 Invoke the Cleanup stage.
 
template<typename Event , typename ... DataType>
void broadcastEvent (Event event, std::shared_ptr< GameWorld > gameWorld, DataType... args)
 Broadcast an event. Only systems registered that are not tied to a specific entity will receive this broadcast.
 
template<typename Event , typename ... DataType>
void deliverEvent (Event event, Entity entity, std::shared_ptr< GameWorld > gameWorld, DataType... args)
 Deliver an event to an entity. Any system attached to that entity with this event will receive this delivery.
 
void keyEvent (std::shared_ptr< GameWorld > gameWorld, int key, int action)
 Broadcast a key event.
 
void mousePosEvent (std::shared_ptr< GameWorld > gameWorld, double xpos, double ypos)
 Broadcast a mouse position event.
 
void mouseButtonEvent (std::shared_ptr< GameWorld > gameWorld, int button, int action)
 Broadcast a mouse button event.
 
void scrollEvent (std::shared_ptr< GameWorld > gameWorld, double distance)
 Broadcast a scroll event.
 
void windowResizeEvent (std::shared_ptr< GameWorld > gameWorld, int width, int height)
 Broadcast a window resize event.
 
- Public Member Functions inherited from Saga::SystemManager
 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.
 

Additional Inherited Members

- Public Types inherited from Saga::SystemManager
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...
 
- Protected Types inherited from Saga::SystemManager
enum class  OtherInput { MOUSE_POS , SCROLL , WINDOW_RESIZE }
 Types of input events, with button events excluded. More...
 
- Static Protected Member Functions inherited from Saga::SystemManager
static auto id_value () -> uint64_t &
 
- Protected Attributes inherited from Saga::SystemManager
EventMap stagedSystemsMap
 Map between Stage and Systems.
 
std::unordered_map< int, EventMapeventSystemsMap
 Maps entity to an EventMap that maps Event to System.
 
EventMap keyboardInputMap
 
EventMap mouseInputMap
 
EventMap otherInputMap
 

Detailed Description

A SystemManager where stages and events can be invoked.

Member Function Documentation

◆ broadcastEvent()

template<typename Event , typename ... DataType>
void Saga::InvokableSystemManager::broadcastEvent ( Event  event,
std::shared_ptr< GameWorld gameWorld,
DataType...  args 
)
inline

Broadcast an event. Only systems registered that are not tied to a specific entity will receive this broadcast.

Template Parameters
Eventanything castable to an int.
DataTypethe type of arguments that the Systems listening to this event will receive.
Parameters
event
gameWorld
argsarguments to be passed to the systems.

◆ deliverEvent()

template<typename Event , typename ... DataType>
void Saga::InvokableSystemManager::deliverEvent ( Event  event,
Entity  entity,
std::shared_ptr< GameWorld gameWorld,
DataType...  args 
)
inline

Deliver an event to an entity. Any system attached to that entity with this event will receive this delivery.

Template Parameters
Eventanything castable to an int.
DataTypethe type of arguments that the systems listening to this event will receive.
Parameters
event
entitythe entity to deliver the event to.
gameWorld
argsarguments to be passed to the systems attached to this event.

◆ keyEvent()

void Saga::InvokableSystemManager::keyEvent ( std::shared_ptr< GameWorld gameWorld,
int  key,
int  action 
)

Broadcast a key event.

Parameters
gameWorld
keya GLFW key.
actiona GLFW action, like GLFW_PRESSED or GLFW_RELEASE.
Here is the call graph for this function:

◆ mouseButtonEvent()

void Saga::InvokableSystemManager::mouseButtonEvent ( std::shared_ptr< GameWorld gameWorld,
int  button,
int  action 
)

Broadcast a mouse button event.

Parameters
gameWorld
keya GLFW key.
actiona GLFW action, like GLFW_PRESSED or GLFW_RELEASE.
Here is the call graph for this function:

◆ mousePosEvent()

void Saga::InvokableSystemManager::mousePosEvent ( std::shared_ptr< GameWorld gameWorld,
double  xpos,
double  ypos 
)

Broadcast a mouse position event.

Parameters
gameWorld
xposthe x position of the mouse in screen space.
yposthe y position of the mouse in screen space.
Here is the call graph for this function:

◆ runStageCleanup()

void Saga::InvokableSystemManager::runStageCleanup ( std::shared_ptr< GameWorld gameWorld)

Invoke the Cleanup stage.

Parameters
gameWorld
Here is the call graph for this function:

◆ runStageDraw()

void Saga::InvokableSystemManager::runStageDraw ( std::shared_ptr< GameWorld gameWorld)

Invoke the Draw stage.

Parameters
gameWorld
Here is the call graph for this function:

◆ runStageFixedUpdate()

void Saga::InvokableSystemManager::runStageFixedUpdate ( std::shared_ptr< GameWorld gameWorld,
float  deltaTime,
float  time 
)

Invoke the fixed update stage. This calls any FixUpdate, and LateFixedUpdate systems in that order.

Parameters
gameWorld
deltaTimethe time since the last fixed update.
timetotal time ellapsed since the start of the program.
Here is the call graph for this function:

◆ runStageStartup()

void Saga::InvokableSystemManager::runStageStartup ( std::shared_ptr< GameWorld gameWorld)

Invoke the startup stage. This calls all systems attached in the Awake and Start stages.

Parameters
gameWorld
Here is the call graph for this function:

◆ runStageUpdate()

void Saga::InvokableSystemManager::runStageUpdate ( std::shared_ptr< GameWorld gameWorld,
float  deltaTime,
float  time 
)

Invoke the update stage. This calls any PreUpdate, Update, and LateUpdate systems in that order.

Parameters
gameWorld
deltaTimethe time since the last update.
timetotal time ellapsed since the start of the program.
Here is the call graph for this function:

◆ scrollEvent()

void Saga::InvokableSystemManager::scrollEvent ( std::shared_ptr< GameWorld gameWorld,
double  distance 
)

Broadcast a scroll event.

Parameters
gameWorld
distanceamount of pixels scrolled.
Here is the call graph for this function:

◆ windowResizeEvent()

void Saga::InvokableSystemManager::windowResizeEvent ( std::shared_ptr< GameWorld gameWorld,
int  width,
int  height 
)

Broadcast a window resize event.

Parameters
gameWorld
widththe width in pixels of the new window.
heightthe height in pixels of the new window.
Here is the call graph for this function:

The documentation for this class was generated from the following files: