Пример #1
0
        /// <summary>
        /// help method to sort units in the right subtree based on thier position in the quad
        /// </summary>
        void AddObjectToSubTrees(Agent agent)
        {
            var pos = agent.position.ToWorld();

            if (pos.X < Quad.Center.X)
            {
                if (pos.Y < Quad.Center.Y)
                {
                    BottomLeft.AddObject(agent);
                }
                else
                {
                    TopLeft.AddObject(agent);
                }
            }
            else
            {
                if (pos.Y < Quad.Center.Y)
                {
                    BottomRight.AddObject(agent);
                }
                else
                {
                    TopRight.AddObject(agent);
                }
            }
        }