The abstract class for all Steering Behaviors
Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Remove the provided Steering Behavior instance
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Remove(SteeringBehavior steeringBehavior)
 {
     _steeringBehaviors.Remove(steeringBehavior);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Add a new Steering Behavior
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Add(SteeringBehavior steeringBehavior)
 {
     Add(steeringBehavior, true);
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Remove the provided Steering Behavior instance
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Remove(SteeringBehavior steeringBehavior)
 {
     _steeringBehaviors.Remove(steeringBehavior);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Add a new Steering Behavior
 /// </summary>
 /// <param name="steeringBehavior"></param>
 public void Add(SteeringBehavior steeringBehavior)
 {
     Add(steeringBehavior, true);
 }
Ejemplo n.º 9
0
 /// <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));
 }
Ejemplo n.º 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));
 }