public void Raise(XmasEvent evt) { ICollection<Trigger> trigered = triggers.Get(evt.GetType()); foreach (Trigger t in trigered) { if (t.CheckCondition(evt)) t.Execute(evt); } var buffer = EventRaised; if(buffer != null) buffer(this, new UnaryValueEvent<XmasEvent>(evt)); }
public void Raise(XmasEvent evt) { ICollection<Trigger> trigered = triggers.Get(evt.GetType()); foreach (Trigger t in trigered) { try { if (t.CheckCondition(evt)) t.Execute(evt); } catch (Exception e) { if (!(evt is TriggerFailedEvent)) this.Raise(new TriggerFailedEvent(t, e)); } } var buffer = EventRaised; if(buffer != null) buffer(this, new UnaryValueEvent<XmasEvent>(evt)); }
private void entity_TriggerRaised(object sender, XmasEvent e) { Raise(e); }
/// <summary> /// Raises an event, this triggers all triggers with the same event /// </summary> /// <param name="evt">The event raised</param> public void Raise(XmasEvent evt) { triggerManager.Raise(evt); }
/// <summary> /// Executes the action of the trigger /// </summary> /// <param name="evt">The event that triggered the trigger</param> protected internal abstract void Execute(XmasEvent evt);
/// <summary> /// Checks the condition on the trigger /// </summary> /// <param name="evt">The event that triggered the trigger</param> /// <returns>Whether or not the condition is satisfied</returns> protected internal abstract bool CheckCondition(XmasEvent evt);
private void raiseEventForAction(XmasAction act, XmasEvent evt) { var envact = act as EnvironmentAction; var entact = act as EntityXmasAction; if (entact != null) { entact.Source.Raise(evt); } else { evtman.Raise(evt); if (envact != null) { foreach (var xuni in envact.RaiseActionEvtOn) { xuni.RaiseNonRecursive(evt); } } } }