-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeModifier.h
43 lines (33 loc) · 981 Bytes
/
TimeModifier.h
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
#ifndef _TIME_MODIFIER_
#define _TIME_MODIFIER_
#include <Core/Event.h>
#include <Core/EngineEvents.h>
#include <Core/IListener.h>
#include <Core/IEvent.h>
using OpenEngine::Core::IListener;
using OpenEngine::Core::ProcessEventArg;
using OpenEngine::Core::IEvent;
using OpenEngine::Core::Event;
class TimeModifier : public IListener<ProcessEventArg> {
private:
IEvent<ProcessEventArg>& originalEvents;
Event<ProcessEventArg> newEvents;
float factor;
public:
TimeModifier(IEvent<ProcessEventArg>& originalEvents, float factor)
: originalEvents(originalEvents), factor(factor) {
originalEvents.Attach(*this);
}
virtual ~TimeModifier() {}
void Handle(ProcessEventArg arg) {
ProcessEventArg event(arg.start, arg.approx*factor);
newEvents.Notify(event);
}
void SetFactor(float factor) {
this->factor = factor;
}
virtual IEvent<ProcessEventArg>& ProcessEvent() {
return newEvents;
}
};
#endif // _TIME_MODIFIER_