Package tripleplay.entity
Class World
java.lang.Object
tripleplay.entity.World
A collection of entities and systems. A world is completely self-contained, so it would be
possible to have multiple separate worlds running simultaneously, though this would be uncommon.
-
Field Summary
Modifier and TypeFieldDescriptionfinal react.Signal<Entity>
A signal emitted when an entity is added to this world.final react.Signal<Entity>
A signal emitted when an entity in this world has changed (usually this means components have been added to or removed from the entity).final react.Signal<Entity>
A signal emitted when an entity in this world which was enabled becomes disabled.final react.Signal<Entity>
A signal emitted when an entity in this world which was disabled becomes enabled.final react.Signal<Entity>
A signal emitted when an entity is removed from the world. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionreact.Closeable
Connects this world to the suppliedupdate
andpaint
signals.create
(boolean enabled) Creates and returns an entity.entities()
Returns an iterator over all entities in the world.entity
(int id) Returns the entity with the specified id.iterator()
void
Paints all of theSystem
s in this world.Creates an entity with the specified id and component bitvec.void
Updates all of theSystem
s in this world.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
entityAdded
A signal emitted when an entity is added to this world. -
entityChanged
A signal emitted when an entity in this world has changed (usually this means components have been added to or removed from the entity). -
entityEnabled
A signal emitted when an entity in this world which was disabled becomes enabled. -
entityDisabled
A signal emitted when an entity in this world which was enabled becomes disabled. -
entityRemoved
A signal emitted when an entity is removed from the world. This happens when an entity is disabled, as well as when it is destroyed.
-
-
Constructor Details
-
World
public World()
-
-
Method Details
-
connect
Connects this world to the suppliedupdate
andpaint
signals.- Returns:
- an object that can be used to disconnect both connections.
-
create
Creates and returns an entity. The entity may actually be obtained from a pool of free entities to avoid unnecessary garbage generation.- Parameters:
enabled
- whether the entity should be enabled by default. If it is enabled, it will automatically be queued for addition to the world. If it is not enabled, it will remain dormant untilEntity.setEnabled(boolean)
is used to enable it.
-
restore
Creates an entity with the specified id and component bitvec. This is only used when restoring entities from persistent storage. Usecreate(boolean)
to create new entities. -
entity
Returns the entity with the specified id. Note: this method is optimized for speed, which means that passing an invalid/unused entity id to this method may return a destroyed entity or it may throw an exception. -
entities
Returns an iterator over all entities in the world.Iterator.remove()
is not implemented for this iterator. -
update
-
paint
Paints all of theSystem
s in this world. -
iterator
-