World class

The primary instance for the framework. It contains all the managers.

You must use this to create, delete and retrieve entities.

It is also important to set the delta each game loop iteration, and initialize before game loop.

Implementers

Constructors

World({EntityManager? entityManager, ComponentManager? componentManager})
Create the World with the default EntityManager and ComponentManager.

Properties

componentManager ComponentManager
Returns a manager that takes care of all the components in the world.
no setter
delta double
The time that passed since the last time process was called.
getter/setter pair
entityManager EntityManager
Returns a manager that takes care of all the entities in the world. entities of this world.
no setter
hashCode int
The hash code for this object.
no setterinherited
properties Map<String, Object>
World-related properties that can be written and read by the user.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
systems Iterable<EntitySystem>
Gives you all the systems in this world for possible iteration.
no setter

Methods

addComponent<T extends Component>(int entity, T component) → void
Adds a component to the entity.
addComponents<T extends Component>(int entity, List<T> components) → void
Adds components to the entity.
addEntity(int entity) → void
Adds a int entity to this world.
addManager(Manager manager) → void
Add a manager into this world. It can be retrieved later. World will notify this manager of changes to entity.
addSystem(EntitySystem system, {bool passive = false, int group = 0}) → void
Adds a system to this world that will be processed by process(). If passive is set to true the system will not be processed by the world. If a group is set, this system will only be processed when calling process() with the same group.
createEntity<T extends Component>([List<T> components = const []]) int
Create and return a new or reused int instance, optionally with components.
deleteAllEntities() → void
Removes all entities from the world.
deleteEntity(int entity) → void
Mark an entity for deletion from the world. Will be deleted after the current system finished running.
deleteManager(Manager manager) → void
Deletes the manager from this world.
deleteSystem(EntitySystem system) → void
Removed the specified system from the world.
destroy() → void
Destroy the World by destroying all EntitySystems and Managers.
frame([int group = 0]) int
Returns the current frame/how often the systems in group have been processed.
getComponents(int entity) List<Component>
Get all components belonging to this entity.
getManager<T extends Manager>() → T
Returns a Manager of the specified type T.
getSystem<T extends EntitySystem>() → T
Retrieve a system for specified system type.
initialize() → void
Makes sure all managers systems are initialized in the order they were added.
moveComponent<T extends Component>(int srcEntity, int dstEntity) → void
Moves a Component of type T from the srcEntity to the dstEntity. if the srcEntity does not have the Component of type T nothing will happen.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
process([int group = 0]) → void
Processes all changes to entities and executes all non-passive systems.
removeComponent<T extends Component>(int entity) → void
Removes a Component of type T from the entity.
time([int group = 0]) double
Returns the time that has elapsed for the systems in the group since the game has started (sum of all deltas).
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String key) Object?
Returns the value for key from properties.
operator []=(String key, Object value) → void
Set the value of key in properties.