예제 #1
0
        /// <summary>
        /// A group used to manage a list of objects inherited from GenBasic.
        /// </summary>
        public GenGroup()
        {
            Members = new List<GenBasic>();
            _activeMembers = new List<GenBasic>();
            _updateMembers = false;

            Quadtree = null;
            _clear = false;
        }
예제 #2
0
        /// <summary>
        /// Creates a quadtree for the group based on the current world bounds, and inserts the group's current members.
        /// </summary>
        public void MakeQuadtree()
        {
            Quadtree = new GenQuadtree(GenG.WorldBounds.X, GenG.WorldBounds.Y, GenG.WorldBounds.Width, GenG.WorldBounds.Height);

            // Add each current member of this group to the quadtree by adding the group itself.
            Quadtree.Add(this);
        }
예제 #3
0
 /// <summary>
 /// A single node within a quadtree data structure.
 /// Used as a container for objects or other nodes.
 /// </summary>
 /// <param name="x">The x position of the top-left corner of the node bounding box.</param>
 /// <param name="y">The y position of the top-left corner of the node bounding box.</param>
 /// <param name="width">The width of the node bounding box.</param>
 /// <param name="height">The height of the node bounding box.</param>
 /// <param name="quadtree">A reference to the quadtree manager of this node.</param>
 /// <param name="parentNode">The quadtree node that this node is a leaf of. Use null if this is a root node.</param>
 /// <param name="level">The split level of the node.</param>
 public GenQuadtreeNode(float x, float y, float width, float height, GenQuadtree quadtree, GenQuadtreeNode parentNode, int level)
     : base(x, y, width, height)
 {
     _quadtree = quadtree;
     _parentNode = parentNode;
     _level = level;
     _objects = new List<GenObject>();
     _objectCount = 0;
     _nodes = new GenQuadtreeNode[4];
 }