The abstract class for all Steering Behaviors
        /// <summary>
        /// Add a new Steering Behavior
        /// </summary>
        /// <param name="steeringBehavior"></param>
        /// <param name="unicity">Set to true if we want to have one steering behavior type only</param>
        public void Add(SteeringBehavior steeringBehavior, bool unicity)
        {
            if(unicity && Contains(steeringBehavior.GetType()))
                throw new CoreException(steeringBehavior.GetType().Name + " steering behavior type is already present");

            steeringBehavior.Priority = _steeringBehaviors.Count;
            steeringBehavior.AutonomousAgent = Agent as AutonomousAgent;

            _steeringBehaviors.Add(steeringBehavior);

            _steeringBehaviors.Sort(SortBySteeringBehaviorPriority);
        }
        /// <summary>
        /// Add a new Steering Behavior
        /// </summary>
        /// <param name="steeringBehavior"></param>
        /// <param name="unicity">Set to true if we want to have one steering behavior type only</param>
        public void Add(SteeringBehavior steeringBehavior, bool unicity)
        {
            if (unicity && Contains(steeringBehavior.GetType()))
            {
                throw new CoreException(steeringBehavior.GetType().Name + " steering behavior type is already present");
            }

            steeringBehavior.Priority        = _steeringBehaviors.Count;
            steeringBehavior.AutonomousAgent = Agent as AutonomousAgent;

            _steeringBehaviors.Add(steeringBehavior);

            _steeringBehaviors.Sort(SortBySteeringBehaviorPriority);
        }
 /// <summary>
 /// Remove the provided Steering Behavior instance
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Remove(SteeringBehavior steeringBehavior)
 {
     _steeringBehaviors.Remove(steeringBehavior);
 }
 /// <summary>
 /// Add a new Steering Behavior
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Add(SteeringBehavior steeringBehavior)
 {
     Add(steeringBehavior, true);
 }
 /// <summary>
 /// Returns if a given Steering Behavior instance is present
 /// </summary>
 /// <param name="steeringBehavior"></param>
 /// <returns></returns>
 public bool Contains(SteeringBehavior steeringBehavior)
 {
     return _steeringBehaviors.Contains(steeringBehavior);
 }
 /// <summary>
 /// Sort all Steering Behaviors by their Priority property
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static int SortBySteeringBehaviorPriority(SteeringBehavior a, SteeringBehavior b)
 {
     return Comparer<float>.Default.Compare(a.Priority, b.Priority);
 }
 /// <summary>
 /// Remove the provided Steering Behavior instance
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Remove(SteeringBehavior steeringBehavior)
 {
     _steeringBehaviors.Remove(steeringBehavior);
 }
 /// <summary>
 /// Add a new Steering Behavior
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Add(SteeringBehavior steeringBehavior)
 {
     Add(steeringBehavior, true);
 }
 /// <summary>
 /// Returns if a given Steering Behavior instance is present
 /// </summary>
 /// <param name="steeringBehavior"></param>
 /// <returns></returns>
 public bool Contains(SteeringBehavior steeringBehavior)
 {
     return(_steeringBehaviors.Contains(steeringBehavior));
 }
示例#10
0
 /// <summary>
 /// Sort all Steering Behaviors by their Priority property
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static int SortBySteeringBehaviorPriority(SteeringBehavior a, SteeringBehavior b)
 {
     return(Comparer <float> .Default.Compare(a.Priority, b.Priority));
 }