Dart Documentationentity_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] alsways 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 will be added to [FreeComponents]
  * when it gets removed from the entity on a state change.
  */
 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 alsways 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 will be added to FreeComponents when it gets removed from the entity on a state change.

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