예제 #1
0
 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));
 }
예제 #2
0
        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));
        }
예제 #3
0
 private void entity_TriggerRaised(object sender, XmasEvent e)
 {
     Raise(e);
 }
예제 #4
0
 /// <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);
 }
예제 #5
0
 /// <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);
예제 #6
0
 /// <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);
예제 #7
0
 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);
             }
         }
     }
 }