//remove the collider from the bounding box dict
 public static void removeCollider(Entity___Component.cCollider c)
 {
     man.boundingBoxes[c.key].Remove(c);
     if (man.boundingBoxes[c.key].Count <= 0)
     {
         man.boundingBoxes.Remove(c.key);
     }
 }
        //add the collider to the list in the dict
        public static void addCollider(Entity___Component.cCollider c)
        {
            //generate the key
            Point key = getKey(c.rect);

            //if there is already a list for that key just put the collider in that list ~~
            if (man.boundingBoxes.ContainsKey(key))
            {
                man.boundingBoxes[key].Add(c);
            }
            else
            {
                //~~ otherwise add a new list to that key and add the collider
                man.boundingBoxes.Add(key, new List <Entity___Component.cCollider>());
                man.boundingBoxes[key].Add(c);
            }
            //set the colliders key to the generated key
            c.key = key;
        }
        public static Point WillItCollide(Entity___Component.cCollider c, int xMove, int yMove)
        {
            //assign the movement to a point to use to return
            Point p = new Point(xMove, yMove);

            //Create two rects that corrispond to the rect if this move is allowed for each axis
            Rectangle futureRectX = new Rectangle(c.rect.X + xMove, c.rect.Y, c.rect.Width, c.rect.Height);
            Rectangle futureRectY = new Rectangle(c.rect.X, c.rect.Y + yMove, c.rect.Width, c.rect.Height);

            //check if each of those rects will collide
            bool collideX = man.CheckFutureCollision(futureRectX, c);
            bool collideY = man.CheckFutureCollision(futureRectY, c);

            //if the rect that corrisponds to the xmove collides set the xmove to 0
            if (collideX)
            {
                if (xMove < 0)
                {
                    p.X = 1;
                }
                else
                {
                    p.X = -1;
                }
            }

            //do the same for the y move
            if (collideY)
            {
                if (yMove < 0)
                {
                    p.Y = 1;
                }
                else
                {
                    p.Y = -1;
                }
            }

            //return the adjusted movement
            return(p);
        }
        //this checks if a rect will cause a collision and returns true if it does
        public Boolean CheckFutureCollision(Rectangle rect, Entity___Component.cCollider c)
        {
            //get the boundingBoxes Key from the rect
            Point cKey = getKey(rect);

            //if the rect is outside the world immediately return true
            if (c.rRef.tag != "Player" && CheckForLeaveWorld(rect))
            {
                return(true);
            }

            //for all of the surrounding bounding boxes check if any of the objects will collide
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    //this generates the key for the surrounding bounding boxes
                    Point key = new Point(cKey.X + i, cKey.Y + j);

                    //this checks if the corrisponding bounding box has any objects in it
                    if (boundingBoxes.ContainsKey(key))
                    {
                        List <Entity___Component.cCollider> box = boundingBoxes[key];
                        //for every object in the bounding box --
                        for (int k = 0; k < box.Count; k++)
                        {
                            //-- check if the bounding box collides and is not the object calling this function return true
                            if (box[k].collides(rect, c) && c != box[k])
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            //if all else fails return false
            return(false);
        }
        public List <Entity___Component.cCollider> CheckCollision(Entity___Component.cCollider c, int buffer)
        {
            //create a list to hold all of the objects that might be colliding
            List <Entity___Component.cCollider> temp = new List <Entity___Component.cCollider>();

            //get the key for the collidable that is being checked
            Point     cKey = getKey(c.rect);
            Rectangle rect = new Rectangle(c.rect.X - buffer, c.rect.Y - buffer, c.rect.Width + (buffer * 2), c.rect.Height + (buffer * 2));

            //for all of the surrounding bounding boxes --
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    //-- generate the key for that bounding box --
                    Point key = new Point(cKey.X + i, cKey.Y + j);

                    //-- if the key has any objects in it --
                    if (boundingBoxes.ContainsKey(key))
                    {
                        //-- for all of said objects ~~
                        List <Entity___Component.cCollider> box = boundingBoxes[key];
                        for (int k = 0; k < box.Count; k++)
                        {
                            //~~ if the object collides with the calling object and it is not the calling object ~~
                            if (box[k].collides(rect, c) && c != box[k])
                            {
                                //~~ add that object to the list to return
                                temp.Add(box[k]);
                            }
                        }
                    }
                }
            }

            //return all the objects that are colliding
            return(temp);
        }
 //remove and replace the collider to change which bounding box it is in
 public static void moveCollider(Entity___Component.cCollider c)
 {
     removeCollider(c);
     addCollider(c);
 }