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, wait
getEntities, getEntitiesAsType, getEntitiesOfType, getEntityAsType, getOptEntity, getOptEntityAsType, hasEntities, hasEntity, hasEntityListener, newEntity, newEntity, newEntity, newEntity, newEntity, newEntity, streamEntitiesAsType, streamEntitiesOfType, streamEntityIDs, transferAllEntities, transferEntities, transferEntities
public 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)
EntityContainer
addEntityListener
in interface EntityContainer
listener
- 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.Object
public EntityContainer getDelegateContainer()
public Entity getEntity(java.util.UUID id)
EntityContainer
getEntity
in interface EntityContainer
id
- Unique ID of the entity.public int getEntityCount()
EntityContainer
getEntityCount
in interface EntityContainer
public java.util.Set<java.util.UUID> getEntityIDs()
EntityContainer
getEntityIDs
in interface EntityContainer
public java.util.Set<? extends EntityListener> getEntityListeners()
EntityContainer
getEntityListeners
in interface EntityContainer
public EntityFactory getFactory()
public int hashCode()
hashCode
in class java.lang.Object
public void killEntities()
EntityContainer
killEntities
in interface EntityContainer
public boolean killEntity(java.util.UUID id)
EntityContainer
killEntity
in interface EntityContainer
id
- Entity ID.public Entity newEntity(java.util.UUID id, AttributeContainer sourceContainer)
EntityContainer
newEntity
in interface EntityContainer
id
- Entity ID.sourceContainer
- Source attribute container.public <T extends Entity> T newEntity(java.util.UUID id, java.lang.Class<T> type, AttributeContainer sourceContainer)
EntityContainer
newEntity
in interface EntityContainer
id
- Entity ID.type
- Entity type.sourceContainer
- Source attribute container.Entity.markAsType(Class)
,
Entities.asType(Entity, Class)
public boolean receiveEntity(Entity e)
EntityContainer
receiveEntity
in interface EntityContainer
e
- Entity to receive.EntityContainer.transferEntity(UUID, EntityContainer)
public boolean removeEntityListener(EntityListener listener)
EntityContainer
removeEntityListener
in interface EntityContainer
listener
- Listener to remove.true
if the listener was removed.ListenerSet.remove(Object)
public void removeEntityListeners()
EntityContainer
removeEntityListeners
in interface EntityContainer
public java.util.stream.Stream<Entity> streamEntities()
EntityContainer
streamEntities
in interface EntityContainer
public java.lang.String toString()
toString
in class java.lang.Object
public boolean transferEntity(java.util.UUID id, EntityContainer destination)
EntityContainer
transferEntity
in interface EntityContainer
id
- Entity ID.destination
- Target container.EntityContainer.receiveEntity(Entity)