forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventSystem.hpp
More file actions
81 lines (70 loc) · 1.98 KB
/
Copy pathEventSystem.hpp
File metadata and controls
81 lines (70 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include <Ogre.h>
#include <cstdlib>
#include "System.hpp"
#include "EntitySystem.hpp"
#include "Helpers.hpp"
#include "lppscript/LppScript.hpp"
class EventSystem : public System
{
public:
/**
* Constructor.
* Param: Entity system that has entities this system will manage.
*/
EventSystem(EntitySystem&);
/**
* Destructor.
*/
~EventSystem() {}
/**
* Brief: Checks for handlers of all active events and if needed, handles
* them.
* Param: Time since last frame.
*/
void update(Ogre::Real) override;
/**
* Brief: Sets the time it takes before an update is performed
* (in seconds).
* Param: The new update time period.
*/
void set_update_period(Ogre::Real);
/**
* Brief: Returns the time it takes before an update is performed
* (in seconds).
*/
Ogre::Real get_update_period() const;
/**
* Brief: Sets the value by which the frame time is multiplied before
* it's added to the update timer.
* Param: The new multiplier value.
*/
void set_update_time_multiplier(Ogre::Real);
/**
* Brief: Returns the value by which the frame time is multiplied before
* it's added to the update timer.
*/
Ogre::Real get_update_time_multiplier() const;
private:
/**
* Brief: Handles a given event by a given entity that can handle it, returns
* true if the event will be destroyed after this call (single handler event),
* false if the event persist (multi handler event).
* Param: ID of the handler.
* Param: ID of the event.
*/
bool handle_event_(std::size_t, std::size_t);
/**
* Entity system that has entities this system will manage.
*/
EntitySystem& entities_;
/**
* Allow for less frequent updates, since per frame updates are quite
* unnecessary and resource wasting.
*/
Ogre::Real update_period_, curr_update_time_;
/**
* Allows to speed up/slow down the update timer.
*/
Ogre::Real update_time_multiplier_;
};