AStarCollisionMap.Collision.CollisionMap.UpdateCollisionMap C# (CSharp) Метод

UpdateCollisionMap() публичный Метод

Updates the collisionmap, without updating or adding pathfinding points. DO NOT USE THIS METHOD IN-GAME, ONLY IN THE EDITOR.
public UpdateCollisionMap ( Rectangle rect, System.Boolean add ) : void
rect Microsoft.Xna.Framework.Rectangle The rectangle
add System.Boolean Whether to add or to remove the rect.
Результат void
        public void UpdateCollisionMap(Rectangle rect, Boolean add)
        {
            CollisionChangedEvent e = new CollisionChangedEvent();
            e.collisionMap = this;
            e.changedRect = rect;
            e.collisionAdded = add;

            CustomArrayList<Quad> quadList = new CustomArrayList<Quad>();
            double checkInterval = 3.0;

            quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Left, rect.Top)));
            // top line
            for (int i = 0; i < checkInterval; i++)
                quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Left + (i * (int)(rect.Width / checkInterval)), rect.Top)));

            quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Right, rect.Top)));

            // right line
            for (int i = 0; i < checkInterval; i++)
                quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Right, rect.Top + (int)(i * (rect.Height / checkInterval)))));

            quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Left, rect.Bottom)));

            // bottom line
            for (int i = 0; i < checkInterval; i++)
                quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Left + (int)(i * (rect.Width / checkInterval)), rect.Bottom)));

            quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Right, rect.Bottom)));

            // left line
            for (int i = 0; i < checkInterval; i++)
                quadList.AddLast(this.tree.GetQuadByPoint(new Point(rect.Left, rect.Top + (int)(i * (rect.Height / checkInterval)))));

            CustomArrayList<Quad> affectedQuads = new CustomArrayList<Quad>();

            for (int i = 0; i < quadList.Count(); i++)
            {
                Quad quad = quadList.ElementAt(i);
                if (quad != null && !affectedQuads.Contains(quad)) affectedQuads.AddLast(quad);
            }

            // Update each of the quads.
            for( int i = 0; i < affectedQuads.Count(); i++ ){
                Quad q = affectedQuads.ElementAt(i);

                Rectangle updatedRect = Rectangle.Intersect(q.rectangle, rect);
                updatedRect.X = updatedRect.X - q.rectangle.X;
                updatedRect.Y = updatedRect.Y - q.rectangle.Y;
                q.collisionTexture.UpdateCollision(updatedRect, add);
                e.changedQuads.AddLast(new CollisionChangedEvent.QuadPart(q, updatedRect));
            }

            FireCollisionChangedEvent(e);
        }