Ejemplo n.º 1
0
        /// <summary>Checks if an action with the same link is already on the Action List.</summary>
        private static bool CheckAction(SimulationRule rule, Action action, List <ActItem> actionList)
        {
            for (int i = 0; i < actionList.Count; i++)
            {
                if (actionList[i].action._link != action._link)
                {
                    continue;
                }

                // Action with same link
                if (rule._priority > actionList[i].rule._priority)
                {
                    // Replace Actitem action with higher priority rule
                    actionList[i] = new ActItem(rule, action);
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
 /// <summary>Adds rule's actions to action list.</summary>
 private static void UpdateActionList(SimulationRule rule, List <ActItem> actionList, bool branch)
 {
     if (branch)
     {
         // go through the true action branch
         foreach (Action a  in  rule._tchain)
         {
             if (!CheckAction(rule, a, actionList)) // add a new action from the "true" chain
             {
                 actionList.Add(new ActItem(rule, a));
             }
         }
     }
     else
     {
         foreach (Action a  in  rule._fchain)
         {
             if (!CheckAction(rule, a, actionList)) // add a new action from the "false" chain
             {
                 actionList.Add(new ActItem(rule, a));
             }
         }
     }
 }
Ejemplo n.º 3
0
 public ActItem(SimulationRule rule, Action action)
 {
     this.rule   = rule;
     this.action = action;
 }