public class World extends Object
It contains all the systems. 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 world without custom systems.
|
World(WorldConfiguration configuration)
Creates a new world.
|
Modifier and Type | Method and Description |
---|---|
int |
compositionId(int entityId)
Gets the
composition id uniquely identifying the
component composition of an entity. |
int |
create()
Create and return a new or reused entity id.
|
int |
create(Archetype archetype)
Create and return an
Entity wrapping a new or reused entity instance. |
Entity |
createEntity()
Create and return a new or reused entity instance.
|
Entity |
createEntity(Archetype archetype)
Create and return an
Entity wrapping a new or reused entity instance. |
void |
delete(int entityId)
Delete the entity from the world.
|
void |
deleteEntity(Entity e)
Delete the entity from the world.
|
void |
dispose()
Disposes all systems.
|
EntityEdit |
edit(int entityId)
Get entity editor for entity.
|
AspectSubscriptionManager |
getAspectSubscriptionManager()
Returns the manager responsible for creating and maintaining
subscriptions in the world. |
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 entity with the specified id.
|
EntityManager |
getEntityManager()
Returns a manager that takes care of all the entities in the world.
|
Injector |
getInjector() |
<T extends SystemInvocationStrategy> |
getInvocationStrategy() |
<T extends Component> |
getMapper(Class<T> type)
Retrieves a ComponentMapper instance for fast retrieval of components
from entities.
|
<T> T |
getRegistered(Class<T> type) |
<T> T |
getRegistered(String name) |
<T extends BaseSystem> |
getSystem(Class<T> type)
Retrieve a system for specified system type.
|
ImmutableBag<BaseSystem> |
getSystems()
Gives you all the systems in this world for possible iteration.
|
void |
inject(Object target)
Inject dependencies on object.
|
void |
inject(Object target,
boolean failIfNotInjectable)
Inject dependencies on object.
|
boolean |
isAlwaysDelayComponentRemoval()
When true, component removal is delayed for all components until all subscriptions have been notified.
|
void |
process()
Process all non-passive systems.
|
void |
setDelta(float delta)
You must specify the delta for the game here.
|
protected void |
setInvocationStrategy(SystemInvocationStrategy invocationStrategy)
Set strategy for invoking systems on
process() . |
public World()
EntityManager
, ComponentManager
and AspectSubscriptionManager
are
available by default.
World(WorldConfiguration)
to create a world with your own systems.public World(WorldConfiguration configuration)
EntityManager
, ComponentManager
and AspectSubscriptionManager
are
available by default, on top of your own systems.
WorldConfigurationBuilder
,
WorldConfiguration
public void inject(Object target)
WorldConfiguration.register(String, Object)
instead, or
configure an Injector
If you want a non-throwing alternative, use inject(Object, boolean)
target
- Object to inject into.
throws MundaneWireException
if target
is annotated with SkipWire
for more details about dependency injection.
,
inject(Object, boolean)
public void inject(Object target, boolean failIfNotInjectable)
Wire
.
If you want to specify nonstandard dependencies to inject, use
WorldConfiguration.register(String, Object)
instead, or
configure an Injector
.target
- Object to inject into.failIfNotInjectable
- if true, this method will
throws MundaneWireException
if target
is annotated with
SkipWire
and failIfNotInjectable
is truefor more details about dependency injection.
,
inject(Object)
public <T> T getRegistered(String name)
public <T> T getRegistered(Class<T> type)
public void dispose()
ArtemisMultiException
- if any system throws an exception.public EntityEdit edit(int entityId)
entityId
- entity to fetch editor for.public int compositionId(int entityId)
composition id
uniquely identifying the
component composition of an entity. Each composition identity maps
to one unique BitVector
.entityId
- Entity for which to get the composition idpublic EntityManager getEntityManager()
public ComponentManager getComponentManager()
public AspectSubscriptionManager getAspectSubscriptionManager()
subscriptions
in the world.public float getDelta()
public void setDelta(float delta)
delta
- time since last game looppublic void deleteEntity(Entity e)
e
- the entity to deleterecommended alternative.
public void delete(int entityId)
entityId
- the entity to deletepublic Entity createEntity()
recommended alternative.
public int create()
public Entity createEntity(Archetype archetype)
Entity
wrapping a new or reused entity instance.
Entity is automatically added to the world.
Use Entity.edit()
to set up your newly created entity.
You can also create entities using:
EntityBuilder
Convenient entity creation. Not useful when pooling.Archetype
Fastest, low level, no parameterized components.recommended alternative.
public int create(Archetype archetype)
Entity
wrapping a new or reused entity instance.
Entity is automatically added to the world.
Use Entity.edit()
to set up your newly created entity.
You can also create entities using:
- EntityBuilder
Convenient entity creation. Not useful when pooling.
- Archetype
Fastest, low level, no parameterized components.public Entity getEntity(int entityId)
entityId
- the entities idpublic ImmutableBag<BaseSystem> getSystems()
public <T extends BaseSystem> T getSystem(Class<T> type)
T
- the class type of systemtype
- type of systemprotected void setInvocationStrategy(SystemInvocationStrategy invocationStrategy)
process()
.public void process()
public <T extends Component> ComponentMapper<T> getMapper(Class<T> type)
T
- class type of the componenttype
- type of component to get mapper forpublic Injector getInjector()
public <T extends SystemInvocationStrategy> T getInvocationStrategy()
process()
.public boolean isAlwaysDelayComponentRemoval()
Copyright © 2019. All rights reserved.