has<A extends Comp<T>, B extends Comp<T>> method

(E, E)? has<A extends Comp<T>, B extends Comp<T>>()

Returns the pair ordered so that the first element carries component A and the second carries component B, or null if the collision doesn't involve both component types.

Unlike as, this matches on component presence rather than entity type.

final hasVelocityHealth = collision.has<CVelocity, CHealth>();
if (hasVelocityHealth) {
  final (hasVelocity, hasHealth) = hasVelocityHealth;
}

Implementation

(E, E)? has<A extends Comp<T>, B extends Comp<T>>() {
  if (a.has<A>() && b.has<B>()) return (a, b);
  if (a.has<B>() && b.has<A>()) return (b, a);
  return null;
}