getComponent<T extends Component> method

T? getComponent<T extends Component>(
  1. EntityID entityID
)

Implementation

T? getComponent<T extends Component>(EntityID entityID) {
  final componentID = _componentTypes[T];
  final record = _entityIndex[entityID];
  if (record == null) return null;
  final archetype = record.archetype;
  final archetypes = _componentIndex[componentID];
  final componentRow = archetypes?[archetype.setHash];
  if (componentRow == null) return null;
  return archetype.components[componentRow][record.entityRow] as T?;
}