/// <summary> /// Broadcasts the given GDEvent to all currently registered receivers /// </summary> /// <param name="gameEvent">The event to broadcast</param> public void BroadcastEvent(GDEvent gameEvent) { string eventType = gameEvent.EventType; if (!HasReceiversForEvent(eventType)) { return; } // Flag used to signal whether to clear the list of event receivers after the event is broadcasted bool cleanAfter = false; for (int i = 0; i < eventTypes[eventType].Count; i++) { if (eventTypes[eventType][i].IsAlive) { IEventReceiver receiver = eventTypes[eventType][i].Target as IEventReceiver; if (receiver != null) { receiver.ReceiveEvent(gameEvent); } } else { cleanAfter = true; } } if (cleanAfter) { ClearEmptyEventTypes(eventType); } }
public void SendEvent(object parameter) { if (Receiver != null) { Receiver.ReceiveEvent(EventName, parameter); } }
public void Update(UpdateInfo info) { while (m_Events.Count > 0 && m_Events.Peek().Tick <= info.Time) { Event evt = m_Events.Dequeue(); IEventReceiver evtRec = m_Receivers.Values.FirstOrDefault(receiver => receiver.ID == evt.ReceiverID); evtRec.ReceiveEvent(evt); } }
/// <inheritdoc/> public Task ReceiveEvent(JToken eventAsJson, CancellationToken token = default) { return(_logic.ReceiveEvent(eventAsJson, token)); }