public static void SetCollisionNotification(Box sender, SpatialGrid spatialGrid)
        {
            Box copy = new Box(sender);

            copy.Inflate(1, 1);
            foreach (Box aabb in spatialGrid.GetProbableCollisions(sender))
            {
                if (aabb.Intersects(copy))
                {
                    sender.CollisionNotification(aabb);
                }
            }
            copy.Inflate(-1, -1);
        }
 public static void ExpulseCollision(Box sender, SpatialGrid spatialGrid)
 {
     if (sender.Solid)
     {
         foreach (Box aabb in spatialGrid.GetProbableCollisions(sender))
         {
             if (aabb is KineticBox)
             {
                 KineticBox box = aabb as KineticBox;
                 if ((box.InteractWithSolid) && (box.Intersects(sender)))
                 {
                     ClassicCollision(box, spatialGrid);
                 }
             }
         }
     }
 }
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = Game.Services.GetService <SpriteBatch>();

            foreach (Box aabb in SpatialGrid.GetProbableCollisions(new Box(null, 0, 0, Width, Height)))
            {
                if (aabb.CollisionSide.HasFlag(Box.CollisionDirection.Inside))
                {
                    DrawHelper.DrawRectangle(spriteBatch, aabb.Rectangle, new Color(Color.Green, 0.1f));
                }
                DrawHelper.DrawOutline(spriteBatch, aabb.Rectangle, Color.Black);
                if (aabb.CollisionSide.HasFlag(Box.CollisionDirection.Top))
                {
                    DrawHelper.DrawRectangle(spriteBatch, new Rectangle(aabb.Rectangle.Left, aabb.Rectangle.Top, aabb.Rectangle.Width, 1), Color.Green);
                }
                if (aabb.CollisionSide.HasFlag(Box.CollisionDirection.Left))
                {
                    DrawHelper.DrawRectangle(spriteBatch, new Rectangle(aabb.Rectangle.Left, aabb.Rectangle.Top, 1, aabb.Rectangle.Height), Color.Green);
                }
                if (aabb.CollisionSide.HasFlag(Box.CollisionDirection.Right))
                {
                    DrawHelper.DrawRectangle(spriteBatch, new Rectangle(aabb.Rectangle.Right - 1, aabb.Rectangle.Top, 1, aabb.Rectangle.Height), Color.Green);
                }
                if (aabb.CollisionSide.HasFlag(Box.CollisionDirection.Bottom))
                {
                    DrawHelper.DrawRectangle(spriteBatch, new Rectangle(aabb.Rectangle.Left, aabb.Rectangle.Bottom - 1, aabb.Rectangle.Width, 1), Color.Green);
                }

                if (aabb is KineticBox)
                {
                    KineticBox box = aabb as KineticBox;

                    Vector2 end = box.Acceleration;
                    end *= (float)gameTime.ElapsedGameTime.TotalSeconds;
                    DrawHelper.DrawLine(spriteBatch, box.Rectangle.Center, box.Rectangle.Center + end.ToPoint(), Color.Red);

                    end  = box.Speed;
                    end *= (float)gameTime.ElapsedGameTime.TotalSeconds;
                    DrawHelper.DrawLine(spriteBatch, box.Rectangle.Center, box.Rectangle.Center + end.ToPoint(), Color.Blue);
                }
            }
            SpatialGrid.Draw(gameTime);
        }