public class DefaultJALSE extends AbstractIdentifiable implements JALSE
JALSE implementation that using default implementations.DefaultEntityFactory (with no Entity limit) and
ForkJoinActionEngine.commonPoolEngine() by default if no EntityFactory or
ActionEngine are provided.| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultJALSE.Builder
A
DefaultJALSE instance builder that uses the defined ActionEngine
implementation with DefaultEntityFactory.By default this builder uses the common pool ( ForkJoinActionEngine.commonPoolEngine()
), has a random ID and has no entity limit. |
| Modifier and Type | Field and Description |
|---|---|
protected ActionEngine |
engine
Action engine to be supplied to entities.
|
protected DefaultEntityContainer |
entities
Backing entity container for top level entities.
|
protected EntityFactory |
factory
Entity factory for creating/killing entities.
|
protected DefaultActionScheduler<JALSE> |
scheduler
Self action scheduler.
|
protected TagTypeSet |
tags
Current state information.
|
id| Constructor and Description |
|---|
DefaultJALSE(java.util.UUID id,
ActionEngine engine,
EntityFactory factory)
Creates a new instance of DefaultJALSE with the supplied engine and factory.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addEntityListener(EntityListener listener)
Adds a listener for entities.
|
void |
cancelAllScheduledForActor()
Cancels all tasks currently running/scheduled (scheduled by this).
|
ActionBindings |
getBindings()
Bindings for this engine.
|
Entity |
getEntity(java.util.UUID id)
Gets the entity with the specified ID.
|
int |
getEntityCount()
Gets the direct entity count.
|
java.util.Set<java.util.UUID> |
getEntityIDs()
Gets the IDs of all the entities within the container.
|
java.util.Set<? extends EntityListener> |
getEntityListeners()
Gets all the entity listeners.
|
java.util.Set<java.util.UUID> |
getIDsInTree()
Gets the current set of IDs for the entire tree.
|
int |
getTreeCount()
Gets the current total number of entities.
|
boolean |
isPaused()
Whether the engine is paused.
|
boolean |
isStopped()
Whether the engine is stopped.
|
void |
killEntities()
Kills all entities.
|
boolean |
killEntity(java.util.UUID id)
Kills the specified entity.
|
<T> SchedulableActionContext<T> |
newContext(Action<T> action)
Creates an action context to define how the action will be scheduled for execution.
|
SchedulableActionContext<JALSE> |
newContextForActor(Action<JALSE> action)
Creates a new mutable context for the supplied action and this actor.
|
Entity |
newEntity(java.util.UUID id,
AttributeContainer sourceContainer)
Creates new entity with the specified ID.
|
<T extends Entity> |
newEntity(java.util.UUID id,
java.lang.Class<T> type,
AttributeContainer sourceContainer)
Creates new entity with the specified ID.
|
void |
pause()
Pauses action processing.
|
boolean |
receiveEntity(Entity e)
Receives an entity (from a transfer).
|
boolean |
removeEntityListener(EntityListener listener)
Removes a entity listener.
|
void |
removeEntityListeners()
Removes all listeners for entities.
|
void |
resume()
Resumes performing actions.
|
ActionContext<JALSE> |
scheduleForActor(Action<JALSE> action,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
Schedules an action for execution with a supplied initial delay and repeat period.
|
void |
stop()
Permanently stops the engine.
|
java.util.stream.Stream<Entity> |
streamEntities()
Provides a stream of entities from the container.
|
java.util.stream.Stream<Entity> |
streamEntityTree()
Streams the entire entity tree.
|
java.util.stream.Stream<Tag> |
streamTags()
Streams all tag state information.
|
boolean |
transferEntity(java.util.UUID id,
EntityContainer destination)
Transfers the entity to the supplied destination container.
|
equals, getID, hashCode, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetEntityTreeequals, getID, getID, hashCode, is, not, toStringputInBindings, removeFromBindings, schedule, schedulescheduleForActor, scheduleForActorgetEntities, getEntitiesAsType, getEntitiesOfType, getEntityAsType, getOptEntity, getOptEntityAsType, hasEntities, hasEntity, hasEntityListener, newEntity, newEntity, newEntity, newEntity, newEntity, newEntity, streamEntitiesAsType, streamEntitiesOfType, streamEntityIDs, transferAllEntities, transferEntities, transferEntitiesprotected final ActionEngine engine
protected final DefaultEntityContainer entities
protected final EntityFactory factory
protected final DefaultActionScheduler<JALSE> scheduler
protected final TagTypeSet tags
public DefaultJALSE(java.util.UUID id,
ActionEngine engine,
EntityFactory factory)
id - The ID used to identify between JALSE instances.engine - Action engine to associate to factory and schedule actions.factory - Entity factory to create/kill child entities.public boolean addEntityListener(EntityListener listener)
EntityContaineraddEntityListener in interface EntityContainerlistener - Listener to add.true if container did not already contain this listener.ListenerSet.add(Object)public void cancelAllScheduledForActor()
ActionSchedulercancelAllScheduledForActor in interface ActionScheduler<JALSE>public ActionBindings getBindings()
ActionEnginegetBindings in interface ActionEnginepublic Entity getEntity(java.util.UUID id)
EntityContainergetEntity in interface EntityContainerid - Unique ID of the entity.public int getEntityCount()
EntityContainergetEntityCount in interface EntityContainerpublic java.util.Set<java.util.UUID> getEntityIDs()
EntityContainergetEntityIDs in interface EntityContainerpublic java.util.Set<? extends EntityListener> getEntityListeners()
EntityContainergetEntityListeners in interface EntityContainerpublic java.util.Set<java.util.UUID> getIDsInTree()
JALSEgetIDsInTree in interface JALSEEntities.getEntityIDsRecursively(EntityContainer)public int getTreeCount()
JALSEgetTreeCount in interface JALSEEntities.getEntityCountRecursively(EntityContainer)public boolean isPaused()
ActionEngineisPaused in interface ActionEnginepublic boolean isStopped()
ActionEngineisStopped in interface ActionEnginepublic void killEntities()
EntityContainerkillEntities in interface EntityContainerpublic boolean killEntity(java.util.UUID id)
EntityContainerkillEntity in interface EntityContainerid - Entity ID.public <T> SchedulableActionContext<T> newContext(Action<T> action)
ActionEnginenewContext in interface ActionEngineaction - Action to create context for.public SchedulableActionContext<JALSE> newContextForActor(Action<JALSE> action)
ActionSchedulernewContextForActor in interface ActionScheduler<JALSE>action - Action to create context for.public Entity newEntity(java.util.UUID id, AttributeContainer sourceContainer)
EntityContainernewEntity in interface EntityContainerid - Entity ID.sourceContainer - Source attribute container.public <T extends Entity> T newEntity(java.util.UUID id, java.lang.Class<T> type, AttributeContainer sourceContainer)
EntityContainernewEntity in interface EntityContainerid - Entity ID.type - Entity type.sourceContainer - Source attribute container.Entity.markAsType(Class),
Entities.asType(Entity, Class)public void pause()
ActionEnginepause in interface ActionEnginepublic boolean receiveEntity(Entity e)
EntityContainerreceiveEntity in interface EntityContainere - Entity to receive.EntityContainer.transferEntity(UUID, EntityContainer)public boolean removeEntityListener(EntityListener listener)
EntityContainerremoveEntityListener in interface EntityContainerlistener - Listener to remove.true if the listener was removed.ListenerSet.remove(Object)public void removeEntityListeners()
EntityContainerremoveEntityListeners in interface EntityContainerpublic void resume()
ActionEngineresume in interface ActionEnginepublic ActionContext<JALSE> scheduleForActor(Action<JALSE> action, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
ActionSchedulerscheduleForActor in interface ActionScheduler<JALSE>action - Action to schedule.initialDelay - Initial delay before schedule (can be 0).period - Period for repeating (can be 0).unit - Time unit of initial delay and period.public void stop()
ActionEnginestop in interface ActionEnginepublic java.util.stream.Stream<Entity> streamEntities()
EntityContainerstreamEntities in interface EntityContainerpublic java.util.stream.Stream<Entity> streamEntityTree()
JALSEstreamEntityTree in interface JALSEEntities.walkEntities(EntityContainer)public java.util.stream.Stream<Tag> streamTags()
TaggablestreamTags in interface Taggablepublic boolean transferEntity(java.util.UUID id,
EntityContainer destination)
EntityContainertransferEntity in interface EntityContainerid - Entity ID.destination - Target container.EntityContainer.receiveEntity(Entity)