Example #1
0
        /// <summary>
        /// Takes cover based on the given search only if it was already adjacent to the previously held cover.
        /// </summary>
        /// <param name="search">Cover search.</param>
        /// <param name="observer">Position of the character.</param>
        public void Maintain(CoverSearch search, Vector3 observer)
        {
            Observer = observer;

            var closest      = search.FindClosest();
            var previousMain = Main;

            if (Main != null && Main != closest)
            {
                if (closest == null || (!Main.IsLeftAdjacent(closest, observer) && !Main.IsRightAdjacent(closest, observer)))
                {
                    Main = null;
                }
            }

            if (Main != null)
            {
                LeftAdjacent  = Main.LeftAdjacent;
                RightAdjacent = Main.RightAdjacent;
            }
            else
            {
                LeftAdjacent  = null;
                RightAdjacent = null;
            }
        }
Example #2
0
        /// <summary>
        /// Takes cover based on the given search.
        /// </summary>
        /// <param name="search">Cover search.</param>
        /// <param name="observer">Position of the character.</param>
        /// <returns>Was the cover taken.</returns>
        public bool Take(CoverSearch search, Vector3 observer)
        {
            Observer = observer;

            var wasIn        = In;
            var closest      = search.FindClosest();
            var previousMain = Main;

            if (Main == null && closest != null)
            {
                Main          = closest;
                LeftAdjacent  = Main.LeftAdjacent;
                RightAdjacent = Main.RightAdjacent;
            }
            else
            {
                Clear();
            }

            if (In && !wasIn)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// Takes cover based on the given search.
        /// </summary>
        /// <param name="search">Cover search.</param>
        /// <param name="observer">Position of the character.</param>
        /// <returns>Was the cover taken.</returns>
        public bool Take(CoverSearch search, Vector3 observer, float tallThreshold)
        {
            Observer = observer;
            ObserverTallThreshold = tallThreshold;

            var wasIn        = In;
            var closest      = search.FindClosest();
            var previousMain = Main;

            if (Main == null && closest != null)
            {
                Main          = closest;
                LeftAdjacent  = Main.LeftAdjacent;
                RightAdjacent = Main.RightAdjacent;
            }
            else
            {
                Clear();
            }

            if (Main != previousMain)
            {
                MainChangeAge = 0;
            }

            if (In && !wasIn)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// Takes cover based on the given search only if it was already adjacent to the previously held cover.
        /// </summary>
        /// <param name="search">Cover search.</param>
        /// <param name="observer">Position of the character.</param>
        public void Maintain(CoverSearch search, Vector3 observer, float tallThreshold)
        {
            Observer = observer;
            ObserverTallThreshold = tallThreshold;

            var closest      = search.FindClosest();
            var previousMain = Main;

            if (Main != null && Main != closest)
            {
                if (closest != null)
                {
                    if (closest == LeftAdjacent)
                    {
                        StandLeft();
                        Main = closest;
                    }
                    else if (closest == RightAdjacent)
                    {
                        StandRight();
                        Main = closest;
                    }
                    else
                    {
                        Main = null;
                    }
                }
                else
                {
                    Main = null;
                }
            }

            if (Main != null)
            {
                LeftAdjacent  = Main.LeftAdjacent;
                RightAdjacent = Main.RightAdjacent;
            }
            else
            {
                LeftAdjacent  = null;
                RightAdjacent = null;
            }

            if (Main != previousMain)
            {
                MainChangeAge = 0;
            }
        }