public class World extends Object
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.
| Modifier and Type | Field and Description |
|---|---|
float |
delta
The time passed since the last update.
|
| Constructor and Description |
|---|
World()
Creates a new world.
|
World(int expectedEntityCount)
Deprecated.
World(WorldConfiguration) provides more fine-grained control. |
World(WorldConfiguration configuration)
Creates a new world.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEntity(Entity e)
Deprecated.
internally managed by artemis
|
void |
changedEntity(Entity e)
Deprecated.
does nothing, internally tracked by artemis now.
|
Entity |
createEntity()
Create and return a new or reused entity instance.
|
Entity |
createEntity(ArchetypeBuilder.Archetype archetype)
Create and return an
EntityEdit wrapping a new or reused entity instance. |
Entity |
createEntity(UUID uuid)
Create and return a new or reused entity instance.
|
void |
deleteEntity(Entity e)
Deprecated.
Better invoke
Entity.deleteFromWorld() or EntityEdit.deleteEntity() |
void |
deleteManager(Manager manager)
Deprecated.
A world should be static once initialized
|
void |
deleteSystem(EntitySystem system)
Deprecated.
A world should be static once initialized
|
void |
disable(Entity e)
Deprecated.
create your own components to track state.
|
void |
dispose()
Disposes all managers and systems.
|
void |
enable(Entity e)
Deprecated.
create your own components to track state.
|
ComponentManager |
getComponentManager()
Returns a manager that takes care of all the components in the world.
|
float |
getDelta()
Time since last game loop.
|
Entity |
getEntity(int entityId)
Get a entity having the specified id.
|
EntityManager |
getEntityManager()
Returns a manager that takes care of all the entities in the world.
|
<T extends Manager> |
getManager(Class<T> managerType)
Returns a manager of the specified type.
|
ImmutableBag<Manager> |
getManagers() |
<T extends Component> |
getMapper(Class<T> type)
Retrieves a ComponentMapper instance for fast retrieval of components
from entities.
|
<T extends EntitySystem> |
getSystem(Class<T> type)
Retrieve a system for specified system type.
|
ImmutableBag<EntitySystem> |
getSystems()
Gives you all the systems in this world for possible iteration.
|
void |
initialize()
Makes sure all managers systems are initialized in the order they were
added.
|
void |
inject(Object target)
Inject dependencies on object.
|
void |
process()
Process all non-passive systems.
|
void |
setDelta(float delta)
You must specify the delta for the game here.
|
<T extends Manager> |
setManager(T manager)
Add a manager into this world.
|
<T extends EntitySystem> |
setSystem(T system)
Adds a system to this world that will be processed by
process(). |
<T extends EntitySystem> |
setSystem(T system,
boolean passive)
Will add a system to this world.
|
public World()
An EntityManager and ComponentManager are created and added upon creation.
@Deprecated public World(int expectedEntityCount)
World(WorldConfiguration) provides more fine-grained control.public World(WorldConfiguration configuration)
An EntityManager and ComponentManager are created and added upon creation.
expectedEntityCount - To avoid resizing entity containers needlessly.public void initialize()
public void inject(Object target)
Wire annotation is required on the target
or fields.
If you want to specify nonstandard dependencies to inject, use
WorldConfiguration.register(String, Object) instead.target - Object to inject into.for more details about dependency injection.public void dispose()
ArtemisMultiException - if any managers or systems throws an exception.public EntityManager getEntityManager()
public ComponentManager getComponentManager()
public final <T extends Manager> T setManager(T manager)
It can be retrieved later. World will notify this manager of changes to entity.
T - class type of the managermanager - manager to be addedpublic <T extends Manager> T getManager(Class<T> managerType)
T - class type of the managermanagerType - class type of the managerpublic ImmutableBag<Manager> getManagers()
@Deprecated public void deleteManager(Manager manager)
manager - manager to deletepublic float getDelta()
public void setDelta(float delta)
delta - time since last game loop@Deprecated public void addEntity(Entity e)
e - the entity to add@Deprecated public void changedEntity(Entity e)
@Deprecated public void deleteEntity(Entity e)
e - the entity to delete@Deprecated public void enable(Entity e)
Won't do anything unless it was already disabled.
e - the entity to enable@Deprecated public void disable(Entity e)
Won't delete it, it will continue to exist but won't get processed.
e - the entity to disablepublic Entity createEntity()
public Entity createEntity(ArchetypeBuilder.Archetype archetype)
EntityEdit wrapping a new or reused entity instance.
Entity is automatically added to the world.public Entity createEntity(UUID uuid)
The uuid parameter is ignored if UuidEntityManager hasn't been added to the
world.
uuid - the UUID to give to the entitypublic Entity getEntity(int entityId)
entityId - the entities idpublic ImmutableBag<EntitySystem> getSystems()
public <T extends EntitySystem> T setSystem(T system)
process().T - the system class typesystem - the system to addpublic <T extends EntitySystem> T setSystem(T system, boolean passive)
T - the system class typesystem - the system to addpassive - whether or not this system will be processed by
process()@Deprecated public void deleteSystem(EntitySystem system)
system - the system to be deleted from worldpublic <T extends EntitySystem> T getSystem(Class<T> type)
T - the class type of systemtype - type of systempublic void process()
public <T extends Component> ComponentMapper<T> getMapper(Class<T> type)
T - class type of the componenttype - type of component to get mapper forCopyright © 2014. All Rights Reserved.