Saga
Saga Game Engine
Loading...
Searching...
No Matches
invokableSystemManager.h
Go to the documentation of this file.
1#pragma once
2#include "systemManager.h"
3#include "../Entity/entity.h"
4
5namespace Saga {
6
7class GameWorld;
8
13public:
18 void runStageStartup(std::shared_ptr<GameWorld> gameWorld);
19
27 void runStageUpdate(std::shared_ptr<GameWorld> gameWorld, float deltaTime, float time);
28
36 void runStageFixedUpdate(std::shared_ptr<GameWorld> gameWorld, float deltaTime, float time);
37
43 void runStageDraw(std::shared_ptr<GameWorld> gameWorld);
44
50 void runStageCleanup(std::shared_ptr<GameWorld> gameWorld);
51
61 template <typename Event, typename ...DataType>
62 void broadcastEvent(Event event, std::shared_ptr<GameWorld> gameWorld, DataType... args) {
63 if (eventSystemsMap.count((int) event))
64 eventSystemsMap[(int) event].invoke(-1, gameWorld, args...);
65 }
66
77 template <typename Event, typename ...DataType>
78 void deliverEvent(Event event, Entity entity, std::shared_ptr<GameWorld> gameWorld, DataType... args) {
79 if (eventSystemsMap.count((int) event))
80 eventSystemsMap[(int) event].invoke(entity, gameWorld, entity, args...);
81 }
82
90 void keyEvent(std::shared_ptr<GameWorld> gameWorld, int key, int action);
91
99 void mousePosEvent(std::shared_ptr<GameWorld> gameWorld, double xpos, double ypos);
100
108 void mouseButtonEvent(std::shared_ptr<GameWorld> gameWorld, int button, int action);
109
116 void scrollEvent(std::shared_ptr<GameWorld> gameWorld, double distance);
117
125 void windowResizeEvent(std::shared_ptr<GameWorld> gameWorld, int width, int height);
126};
127}
A SystemManager where stages and events can be invoked.
Definition: invokableSystemManager.h:12
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 ...
Definition: invokableSystemManager.h:62
void runStageCleanup(std::shared_ptr< GameWorld > gameWorld)
Invoke the Cleanup stage.
Definition: invokableSystemManager.cpp:23
void mouseButtonEvent(std::shared_ptr< GameWorld > gameWorld, int button, int action)
Broadcast a mouse button event.
Definition: invokableSystemManager.cpp:32
void runStageDraw(std::shared_ptr< GameWorld > gameWorld)
Invoke the Draw stage.
Definition: invokableSystemManager.cpp:20
void windowResizeEvent(std::shared_ptr< GameWorld > gameWorld, int width, int height)
Broadcast a window resize event.
Definition: invokableSystemManager.cpp:38
void scrollEvent(std::shared_ptr< GameWorld > gameWorld, double distance)
Broadcast a scroll event.
Definition: invokableSystemManager.cpp:35
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.
Definition: invokableSystemManager.cpp:16
void mousePosEvent(std::shared_ptr< GameWorld > gameWorld, double xpos, double ypos)
Broadcast a mouse position event.
Definition: invokableSystemManager.cpp:29
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 d...
Definition: invokableSystemManager.h:78
void runStageStartup(std::shared_ptr< GameWorld > gameWorld)
Invoke the startup stage. This calls all systems attached in the Awake and Start stages.
Definition: invokableSystemManager.cpp:6
void keyEvent(std::shared_ptr< GameWorld > gameWorld, int key, int action)
Broadcast a key event.
Definition: invokableSystemManager.cpp:26
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.
Definition: invokableSystemManager.cpp:11
Manages Systems in the ECS model. Allows for System to be added, but not invoked.
Definition: systemManager.h:17
std::unordered_map< int, EventMap > eventSystemsMap
Maps entity to an EventMap that maps Event to System.
Definition: systemManager.h:207
Definition: app.cpp:8