queryEachPairsSelf method

void queryEachPairsSelf(
  1. QueryParams params,
  2. void fn(
    1. QueryRowView a,
    2. QueryRowView b
    )
)

Implementation

void queryEachPairsSelf(
  QueryParams params,
  void Function(QueryRowView a, QueryRowView b) fn,
) {
  if (!params.activate(this)) return;

  final columns = List<int>.filled(params.componentIDs.length, 0);
  final rowA = QueryRowView();
  final rowB = QueryRowView();

  final archetypes = _archetypeIndex.values.toList(growable: false);

  for (final arch in archetypes) {
    if (arch.isEmpty || !arch.setHash.contains(params.hash)) continue;

    for (int c = 0; c < params.componentIDs.length; c++) {
      columns[c] = _componentIndex[params.componentIDs[c]]![arch.setHash]!;
    }

    final count = arch.entityCount;

    for (int i = 0; i < count; i++) {
      rowA.bind(arch, columns, i, params.typeIndices);

      for (int j = i + 1; j < count; j++) {
        rowB.bind(arch, columns, j, params.typeIndices);
        fn(rowA, rowB);
      }
    }
  }
}