onComponentTypeCheck method

  1. @override
bool onComponentTypeCheck(
  1. PositionComponent other
)
override

Works only for the QuadTree collision detection. If you need to prevent collision of items of different types - reimplement onComponentTypeCheck. The result of calculation is cached so you should not check any dynamical parameters here, the function intended to be used as pure type checker. Call super.onComponentTypeCheck to get the parent's result of the type check if needed. In other causes this call is redundant in game code.

Implementation

@override
bool onComponentTypeCheck(PositionComponent other) {
  final myParent = parent;
  final otherParent = other.parent;
  if (myParent is CollisionCallbacks && otherParent is PositionComponent) {
    return myParent.onComponentTypeCheck(otherParent);
  }

  return true;
}