public class DefaultEntityContainer extends java.lang.Object implements EntityContainer
EntityContainer. EntityEvent. Entity
updates will trigger these events using EntityListener.DefaultEntityFactory with no delegate
container.| Constructor and Description |
|---|
DefaultEntityContainer()
Creates an entity container with the default entity factory and no delegate container.
|
DefaultEntityContainer(EntityFactory factory)
Creates an entity container with the supplied factory and no delegate container.
|
DefaultEntityContainer(EntityFactory factory,
EntityContainer delegateContainer)
Creates an entity container with the supplied factory and delegate container.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addEntityListener(EntityListener listener)
Adds a listener for entities.
|
boolean |
equals(java.lang.Object obj) |
EntityContainer |
getDelegateContainer()
Gets the delegate container for events and entity creation.
|
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.
|
EntityFactory |
getFactory()
Gets entity factory for this set.
|
int |
hashCode() |
void |
killEntities()
Kills all entities.
|
boolean |
killEntity(java.util.UUID id)
Kills the specified entity.
|
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.
|
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.
|
java.util.stream.Stream<Entity> |
streamEntities()
Provides a stream of entities from the container.
|
java.lang.String |
toString() |
boolean |
transferEntity(java.util.UUID id,
EntityContainer destination)
Transfers the entity to the supplied destination container.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetEntities, getEntitiesAsType, getEntitiesOfType, getEntityAsType, getOptEntity, getOptEntityAsType, hasEntities, hasEntity, hasEntityListener, newEntity, newEntity, newEntity, newEntity, newEntity, newEntity, streamEntitiesAsType, streamEntitiesOfType, streamEntityIDs, transferAllEntities, transferEntities, transferEntitiespublic DefaultEntityContainer()
public DefaultEntityContainer(EntityFactory factory)
factory - Entity creation/death factory.public DefaultEntityContainer(EntityFactory factory, EntityContainer delegateContainer)
factory - Entity creation/death factory.delegateContainer - Delegate container for events and entity creation.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 boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic EntityContainer getDelegateContainer()
public 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 EntityFactory getFactory()
public int hashCode()
hashCode in class java.lang.Objectpublic void killEntities()
EntityContainerkillEntities in interface EntityContainerpublic boolean killEntity(java.util.UUID id)
EntityContainerkillEntity in interface EntityContainerid - Entity ID.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 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 java.util.stream.Stream<Entity> streamEntities()
EntityContainerstreamEntities in interface EntityContainerpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean transferEntity(java.util.UUID id,
EntityContainer destination)
EntityContainertransferEntity in interface EntityContainerid - Entity ID.destination - Target container.EntityContainer.receiveEntity(Entity)