Working event system!

This commit is contained in:
2014-04-28 09:28:18 +02:00
parent 22138a36aa
commit 5870a4d7bf
6 changed files with 150 additions and 45 deletions
+28
View File
@@ -1,8 +1,36 @@
#include "PrecompiledHeader.h"
#include "Engine.h"
#include "EventBroker.h"
struct TestEvent : Event
{
std::string Hello;
};
bool OnTestEvent(const TestEvent &event)
{
std::cout << "TestEvent.Hello = " << event.Hello << std::endl;
return true;
}
int main(int argc, char* argv[])
{
EventBroker broker;
TestEvent e;
e.Hello = "Hello world";
{
EventRelay<TestEvent> testRelay = &OnTestEvent;
broker.Subscribe(testRelay);
broker.Publish<TestEvent>(e);
}
broker.Publish<TestEvent>(e);
return 0;
Engine engine(argc, argv);
while (engine.Running())
engine.Tick();