remove method

  1. @override
void remove(
  1. ShapeHitbox item
)
override

Removes an item from the broadphase. Should be called in a CollisionDetection class while removing a hitbox from its collision detection system.

Implementation

@override
void remove(ShapeHitbox item) {
  tree.remove(item);
  _cachedCenters.remove(item);
  if (item.collisionType == CollisionType.active) {
    activeHitboxes.remove(item);
  }

  final checkCache = _broadphaseCheckCache[item];
  if (checkCache != null) {
    for (final entry in checkCache.entries) {
      _broadphaseCheckCache[entry.key]?.remove(item);
    }
    _broadphaseCheckCache.remove(item);
  }
}