using System.Collections.Generic; using UnityEngine; namespace AwesomeTechnologies.Utility.Quadtree { public class QuadTree where T : IHasRect { /// /// The root QuadTreeNode /// readonly QuadTreeNode _root; /// /// The bounds of this QuadTree /// private Rect _rect; /// /// Create the quadtree /// /// public QuadTree(Rect rect) { _rect = rect; _root = new QuadTreeNode(_rect); } /// /// Get the count of items in the QuadTree /// public int Count => _root.Count; /// /// Insert the feature into the QuadTree /// /// public void Insert(T item) { _root.Insert(item); } public void Move(Vector2 offset) { _rect = new Rect(_rect.xMin + offset.x, _rect.yMin + offset.y, _rect.width, _rect.height); _root.Move(offset); } public void Query(Rect area, List results) { _root.Query(area,results); } } }