void IntEventSubscriber::Notify(const EventPublisher& event) { if (event.Is(Event<std::uint32_t>::TypeIdClass())) { Event<std::uint32_t>* intEvent = event.As<Event<std::uint32_t>>(); mNumber = intEvent->Message(); } }
void AsyncFooSubscriber::Notify(const EventPublisher& publisher) { assert(publisher.Is(Event<Foo>::TypeIdClass())); const Foo& foo = publisher.As<Event<Foo>>()->Message(); data = foo.GetData(); wasNotified = true; Foo anotherFoo(100); std::shared_ptr<EventPublisher> anotherEvent = std::make_shared<Event<Foo>>(anotherFoo); mEventQueuePtr->Enqueue(anotherEvent, *mGameTimePtr); }
void AttributedFooEventSubscriber::Notify(const EventPublisher& publisher) { if (publisher.Is(Event<AttributedFoo>::TypeIdClass())) { Event<AttributedFoo>* aFooEvent = publisher.As<Event<AttributedFoo>>(); const AttributedFoo& aFoo = aFooEvent->Message(); health = aFoo["Health"].Get<int>(); money = aFoo["Money"].Get<float>(); identity = aFoo["Name"].Get<std::string>(); position = aFoo["Position"].Get<glm::vec4>(); currentFieldGrid = aFoo["CurrentFieldGrid"].Get<glm::mat4>(); } }