Example #1
0
        /// <summary>
        /// Registers a steering component.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        public void RegisterSteeringBehavior(ISteeringBehaviour behavior)
        {
            int count = _steeringComponents.Count;

            for (int i = 0; i < count; i++)
            {
                var c = _steeringComponents[i];
                if (c.priority == behavior.priority)
                {
                    var grp = c as SteeringGroup;
                    if (grp == null)
                    {
                        grp = new SteeringGroup(c.priority);
                        _steeringComponents[i] = grp;
                        grp.Add(c);
                    }

                    grp.Add(behavior);
                    return;
                }
            }

            _steeringComponents.Add(behavior);
            _steeringComponents.Sort((a, b) => b.priority.CompareTo(a.priority));
        }
        /// <summary>
        /// Registers a steering component.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        public void RegisterSteeringBehavior(ISteeringBehaviour behavior)
        {
            int count = _steeringComponents.Count;
            for (int i = 0; i < count; i++)
            {
                var c = _steeringComponents[i];
                if (c.priority == behavior.priority)
                {
                    var grp = c as SteeringGroup;
                    if (grp == null)
                    {
                        grp = new SteeringGroup(c.priority);
                        _steeringComponents[i] = grp;
                        grp.Add(c);
                    }

                    grp.Add(behavior);
                    return;
                }
            }

            _steeringComponents.Add(behavior);
            _steeringComponents.Sort((a, b) => b.priority.CompareTo(a.priority));
        }