ScrollingShooter.GameObjectManager.RemoveGameObject C# (CSharp) Method

RemoveGameObject() private method

Removes a Game object from the axis
private RemoveGameObject ( ScrollingShooter.GameObject gameObject ) : void
gameObject ScrollingShooter.GameObject The game object to remove
return void
        private void RemoveGameObject(GameObject gameObject)
        {
            uint id = gameObject.ID;

            // Remove the game object from our list of all game objects
            gameObjects.Remove(id);

            // Remove the game object from our collection of collisions
            CollisionPair[] pairs = collisions.ToArray();
            foreach (CollisionPair pair in pairs)
            {
                if (pair.A == id || pair.B == id)
                {
                    collisions.Remove(pair);
                }
            }

            // Remove the game object from our collection of overlaps
            CollisionPair[] pairs2 = verticalOverlaps.ToArray();
            foreach (CollisionPair pair in pairs2)
            {
                if (pair.A == id || pair.B == id)
                {
                    verticalOverlaps.Remove(pair);
                }
            }

            // Grab the game object's bounding box
            BoundingBox box;
            try
            {
                box = boundingBoxes[id];
            }
            catch (KeyNotFoundException ke)
            {
                return;
            }

            // Remove the game objects' bounds from our vertical axis lists
            verticalAxis.Remove(box.Top);
            verticalAxis.Remove(box.Bottom);

            // Remove the game object's bounding box
            boundingBoxes.Remove(id);
        }