public class DefaultEntityFactory extends java.lang.Object implements EntityFactory
EntityFactory
implementation that creates/kills DefaultEntity
. Default entity
factory can have a total entity limit set. When this factory kills an entity it will kill the
entity tree under it (can only kill entities his factory has created).ActionEngine
is supplied ForkJoinActionEngine.commonPoolEngine()
will be
used.Constructor and Description |
---|
DefaultEntityFactory()
Creates a default entity factory with no entity limit.
|
DefaultEntityFactory(int entityLimit)
Creates a default entity factory with the supplied entity limit.
|
Modifier and Type | Method and Description |
---|---|
void |
exportEntity(Entity e)
Exports an entity (removing all references).
|
ActionEngine |
getEngine()
Gets the associated engine.
|
int |
getEntityCount()
Gets the current total entity count.
|
int |
getEntityLimit()
Gets the total entity limit.
|
DefaultEntity |
newEntity(java.util.UUID id,
EntityContainer target)
Creates a new entity with the specified ID and parent container.
|
void |
setEngine(ActionEngine engine)
Sets the engine to supply to new entities.
|
java.lang.String |
toString() |
boolean |
tryImportEntity(Entity e,
EntityContainer target)
Imports the entity into the factory.
|
boolean |
tryKillEntity(Entity e)
Kills the specified entity.
|
boolean |
tryTakeFromTree(Entity e,
EntityContainer target)
Tries to take the entity from within the tree if possible.
|
boolean |
withinSameTree(EntityContainer source,
EntityContainer target)
Checks if the two containers are within the same tree (for in tree transfer or export).
|
public DefaultEntityFactory()
public DefaultEntityFactory(int entityLimit)
entityLimit
- Maximum entity limit.public void exportEntity(Entity e)
EntityFactory
exportEntity
in interface EntityFactory
e
- Entity to detach.public ActionEngine getEngine()
public int getEntityCount()
public int getEntityLimit()
public DefaultEntity newEntity(java.util.UUID id, EntityContainer target)
EntityFactory
newEntity
in interface EntityFactory
id
- Entity ID.target
- Parent container.public void setEngine(ActionEngine engine)
EntityFactory
setEngine
in interface EntityFactory
engine
- Action engine.public java.lang.String toString()
toString
in class java.lang.Object
public boolean tryImportEntity(Entity e, EntityContainer target)
EntityFactory
tryImportEntity
in interface EntityFactory
e
- Entity to import.target
- Target container.public boolean tryKillEntity(Entity e)
EntityFactory
tryKillEntity
in interface EntityFactory
e
- Entity to kill.public boolean tryTakeFromTree(Entity e, EntityContainer target)
EntityFactory
tryTakeFromTree
in interface EntityFactory
e
- Entity to take.target
- Target container.public boolean withinSameTree(EntityContainer source, EntityContainer target)
EntityFactory
withinSameTree
in interface EntityFactory
source
- Source container.target
- Target container.