public void Accept(IQuadTreeVisitor aVisitor) { aVisitor.Visit(this); if (this.subTrees != null) { foreach (IQuadTree subTree in this.subTrees) { subTree.Accept(aVisitor); } } }
public bool Insert(IPoint <IUserObject> aPoint, IQuadTreeVisitor aVisitor) { if (!aPoint.GetUserObject().GetShape().IntersectsWithRectangle(this.boundary)) { return(false); } aVisitor.Visit(this); if (aPoint.GetUserObject().GetHealth() < 1) { return(false); } if (null == this.points) { this.points = new List <IPoint <IUserObject> > (this.capacity); } if (this.points.Count < this.capacity && null == subTrees) { this.points.Add(aPoint); return(true); } if (null == this.subTrees) { this.subdivide(); } foreach (IQuadTree subTree in this.subTrees) { if (subTree.Insert(aPoint, aVisitor)) { return(true); } } return(false); }