describeEntity method

EntityDetailSnapshot describeEntity(
  1. int index,
  2. int generation
)

Collects details for one entity.

Implementation

EntityDetailSnapshot describeEntity(int index, int generation) {
  final entity = Entity(index, generation);
  if (!world.isAlive(entity)) {
    return EntityDetailSnapshot(
      index: index,
      generation: generation,
      name: null,
      lines: const <String>[],
      stale: true,
    );
  }
  // Use the value text when available.
  final lines = <String>[];
  for (final (type, store) in world.stores.entries) {
    if (!store.containsIndex(index)) continue;
    final value = store is ObjectComponentStore
        ? _overriddenToString(store.valueOf(index))
        : null;
    lines.add(value ?? '$type');
  }
  return EntityDetailSnapshot(
    index: index,
    generation: generation,
    name: world.tryGet<Name>(entity)?.value,
    lines: lines,
    stale: false,
  );
}