/// <summary>
 /// Subscribes a IBattleArtificialIntelligence member on one of the designated lists
 /// to be processed.
 /// </summary>
 /// <param name="e"></param>
 public static void Subscribe(IBattleArtificialIntelligence e)
 {
     //If the object is subscribed cancel
     if (e.BattleState.IsSubscribed == true) return;
     int index = FindBestThreadStateToSubscribe();
     Subscribe(e, index);
 }
 /// <summary>
 /// Unsubscribes a IBattleArtificialIntelligence member on one of the designated lists
 /// to be processed.
 /// </summary>
 /// <param name="e"></param>
 public static void Unsubscribe(IBattleArtificialIntelligence e)
 {
     //If the object is not subscribed cancel
     if (e.BattleState.IsSubscribed == false) return;
     int index = e.BattleState.ThreadIndex;
     Unsubscribe(e, index);
 }
Example #3
0
 /// <summary>
 /// Removes the requested
 /// IBattleArtificialIntelligence
 /// </summary>
 /// <param name="e"></param>
 public void Remove(IBattleArtificialIntelligence e)
 {
     lock (e)
     {
         this.processinglist.Remove(e);
     }
 }
Example #4
0
 /// <summary>
 /// Adds the requested IBattleArtificialIntelligence.
 /// </summary>
 /// <param name="e"></param>
 public void Add(IBattleArtificialIntelligence e)
 {
     lock (e)
     {
         this.processinglist.Add(e);
     }
 }
Example #5
0
            /// <summary>
            /// Processes all list members
            /// </summary>
            private void Process()
            {
                while (!Environment.HasShutdownStarted)
                {
                    try
                    {
                        //Process all mobs
                        for (int i = 0; i < this.processinglist.Count; i++)
                        {
                            try
                            {
                                IBattleArtificialIntelligence ai = this.processinglist[i];
                                ai.Process();
                            }
                            catch (ThreadAbortException ex)
                            {
                                throw ex;
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        }

                        //Sleep one sec
                        Thread.Sleep(1);
                    }
                    catch (ThreadAbortException)
                    {
                        break;
                    }
                }
            }
Example #6
0
 private static void Subscribe(IBattleArtificialIntelligence e, int index)
 {
     if (index < ThreadStateList.Count)
     {
         ThreadState current = ThreadStateList[index];
         current.Add(e);
         e.BattleState.Subscribe(index);
     }
 }
Example #7
0
 private static void Unsubscribe(IBattleArtificialIntelligence e, int index)
 {
     if (index < ThreadStateList.Count)
     {
         //Actual ubsubscribement
         ThreadState current = ThreadStateList[index];
         current.Remove(e);
         e.BattleState.Unsubscribe(index);
     }
 }
Example #8
0
        /// <summary>
        /// Unsubscribes a IBattleArtificialIntelligence member on one of the designated lists
        /// to be processed.
        /// </summary>
        /// <param name="e"></param>
        public static void Unsubscribe(IBattleArtificialIntelligence e)
        {
            //If the object is not subscribed cancel
            if (e.BattleState.IsSubscribed == false)
            {
                return;
            }
            int index = e.BattleState.ThreadIndex;

            Unsubscribe(e, index);
        }
Example #9
0
        /// <summary>
        /// Subscribes a IBattleArtificialIntelligence member on one of the designated lists
        /// to be processed.
        /// </summary>
        /// <param name="e"></param>
        public static void Subscribe(IBattleArtificialIntelligence e)
        {
            //If the object is subscribed cancel
            if (e.BattleState.IsSubscribed == true)
            {
                return;
            }
            int index = FindBestThreadStateToSubscribe();

            Subscribe(e, index);
        }
 /// <summary>
 /// Removes the requested
 /// IBattleArtificialIntelligence
 /// </summary>
 /// <param name="e"></param>
 public void Remove(IBattleArtificialIntelligence e)
 {
     lock (e)
     {
         this.processinglist.Remove(e);
     }
 }
 /// <summary>
 /// Checks if a threadstate contains the requested
 /// IBattleArtificialIntelligence
 /// </summary>
 /// <param name="e"></param>
 public void Contains(IBattleArtificialIntelligence e)
 {
     this.processinglist.Contains(e);
 }
 /// <summary>
 /// Adds the requested IBattleArtificialIntelligence.
 /// </summary>
 /// <param name="e"></param>
 public void Add(IBattleArtificialIntelligence e)
 {
     lock (e)
     {
         this.processinglist.Add(e);
     }
 }
 private static void Unsubscribe(IBattleArtificialIntelligence e, int index)
 {
     if (index < ThreadStateList.Count)
     {
         //Actual ubsubscribement
         ThreadState current = ThreadStateList[index];
         current.Remove(e);
         e.BattleState.Unsubscribe(index);
     }
 }
 private static void Subscribe(IBattleArtificialIntelligence e, int index)
 {
     if (index < ThreadStateList.Count)
     {
         ThreadState current = ThreadStateList[index];
         current.Add(e);
         e.BattleState.Subscribe(index);
     }
 }
Example #15
0
 /// <summary>
 /// Checks if a threadstate contains the requested
 /// IBattleArtificialIntelligence
 /// </summary>
 /// <param name="e"></param>
 public void Contains(IBattleArtificialIntelligence e)
 {
     this.processinglist.Contains(e);
 }