getComponent<T extends Component> method

T? getComponent<T extends Component>(
  1. int entity,
  2. ComponentType componentType
)

Returns the component of type T for the given entity.

Implementation

T? getComponent<T extends Component>(
  int entity,
  ComponentType componentType,
) {
  final index = componentType._bitIndex;
  final components = _componentInfoByType[index];
  if (components != null && entity < components.components.length) {
    return components.components[entity] as T?;
  }
  return null;
}