Example #1
0
 /* This method calls the suppress method on all behaviours which isn't going to be executed.
  * This can be used to stop existing coroutines
  */
 public void SuppressBehaviours()
 {
     foreach (var behaviour in strategyToUse.GetBehaviours())
     {
         if (!toExecute.Contains(behaviour))
         {
             behaviour.Suppress();
         }
     }
 }
Example #2
0
 /* This method will be called before Update, FixedUpdate and LateUpdate
  * This makes sure that the first method which gets called each frame (which can vary)
  * forces the controlcenter to calculate which behaviour(s) to execute exactly one time
  * each frame
  */
 public void PreExecuteCalculations()
 {
     if (lastArbitratedFrame != Time.frameCount)
     {
         strategyToUse = StrategyManager.GetStrategy();                               // Get the strategy to use
         toExecute     = ArbitrationManager.Arbitrate(strategyToUse.GetBehaviours()); // Get the behaviour(s) to execute
         if (CommunicationManager.EnableBroadcasting)
         {
             AgentBehaviour broadcastedBehaviourToDo = CommunicationManager.GetBehaviourToDo(toExecute);
             if (broadcastedBehaviourToDo != null)
             {
                 toExecute.Clear();
                 toExecute.Add(broadcastedBehaviourToDo);
             }
         }
         SuppressBehaviours();
         lastArbitratedFrame = Time.frameCount;
     }
 }