Dart Documentationsystem_entity_stateComponentProvider

ComponentProvider class

class ComponentProvider {
 static int _cnt = -1000000;
 static alwaysNewId() => _cnt++;
 static nullId() => null;

 /// Type of the provided Component
 final ComponentType type;

 final CreateComponent createComponent;

 final ComponentProviderId id;

 /**
  * Creates a new [ComponentProvider].
  *
  * The [createComponent] always has to create a [Component] that is returned
  * using the factory constructor of that [Component]. Do not return the same
  * instance for multiple calls, because it can return to [ObjectPool]
  * when it gets removed from the entity on a state change
  * if it extends [Poolable].
  */
 ComponentProvider(Type ctype, this.createComponent, [this.id = nullId]) : type = ComponentTypeManager.getTypeFor(ctype);
}

Static Methods

dynamic alwaysNewId() #

static alwaysNewId() => _cnt++;

dynamic nullId() #

static nullId() => null;

Constructors

new ComponentProvider(Type ctype, CreateComponent createComponent, [ComponentProviderId id = nullId]) #

Creates a new ComponentProvider.

The createComponent always has to create a Component that is returned using the factory constructor of that Component. Do not return the same instance for multiple calls, because it can return to ObjectPool when it gets removed from the entity on a state change if it extends Poolable.

ComponentProvider(Type ctype, this.createComponent, [this.id = nullId]) : type = ComponentTypeManager.getTypeFor(ctype);

Properties

final CreateComponent createComponent #

final CreateComponent createComponent

final ComponentProviderId id #

final ComponentProviderId id

final ComponentType type #

Type of the provided Component

final ComponentType type