Пример #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;
            }
        }