public class DefaultEntitySet extends java.util.AbstractSet<Entity> implements EntitySet
Modifier and Type | Class and Description |
---|---|
protected static class |
DefaultEntitySet.RemovedComponent
A special entity component that is used during transaction processing
to temporarily mark a component as "removed".
|
protected class |
DefaultEntitySet.Transaction
Keeps accumulated data about a set of changes.
|
Modifier and Type | Field and Description |
---|---|
protected static DefaultEntitySet.RemovedComponent |
REMOVED_COMPONENT
Constant used during transaction processing to mark
removed components in already loaded entities.
|
protected DefaultEntitySet.Transaction |
transaction |
Constructor and Description |
---|
DefaultEntitySet(EntityData ed,
ComponentFilter filter,
java.lang.Class<EntityComponent>[] types) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Entity e) |
boolean |
applyChanges()
Applies any accumulated changes to this list's entities since
the last time it was called and returns true if there were
changes.
|
boolean |
applyChanges(java.util.Set<EntityChange> updates)
Deprecated.
|
protected boolean |
applyChanges(java.util.Set<EntityChange> updates,
boolean clearChangeSets) |
protected boolean |
buildTransactionChanges(java.util.Set<EntityChange> updates) |
void |
clear() |
void |
clearChangeSets()
Clears all pending change sets accumulated during the last
applyChanges().
|
protected boolean |
completeEntity(DefaultEntity e)
Called by the Transaction object to fill in the missing
components for an entity if this is the first time it's
been seen by the set and may not have all of its components
yet.
|
boolean |
contains(java.lang.Object e) |
boolean |
containsId(EntityId id)
Returns true if this set contains the entity with the
specified ID.
|
java.lang.String |
debugId() |
protected void |
entityChange(EntityChange change) |
protected boolean |
entityMatches(Entity e) |
boolean |
equals(java.lang.Object o) |
java.util.Set<Entity> |
getAddedEntities()
Returns the entities that were added during applyChanges.
|
java.util.Set<Entity> |
getChangedEntities()
Returns the entities that were changed during applyChanges.
|
protected java.util.concurrent.ConcurrentLinkedQueue<EntityChange> |
getChangeQueue() |
Entity |
getEntity(EntityId id)
Returns this set's version of the Entity for the specified
ID or null if this set does not contain the specified entity.
|
java.util.Set<EntityId> |
getEntityIds()
Returns all of the EntityIds currently in this set.
|
protected ComponentFilter |
getMainFilter() |
java.util.Set<Entity> |
getRemovedEntities()
Returns the entities that were removed during applyChanges.
|
protected java.lang.Class<EntityComponent>[] |
getTypes() |
boolean |
hasChanges()
Returns true if there were entity changes during the last
applyChanges().
|
boolean |
hasFilterChanged() |
boolean |
hasType(java.lang.Class type)
Returns true if this EntitySet is made of entities
that have the specified type of component.
|
protected boolean |
isMatchingComponent(EntityComponent c)
Returns true if the specific component matches the criteria
for this entity set.
|
protected boolean |
isReleased() |
protected boolean |
isRelevantChange(EntityChange change) |
java.util.Iterator<Entity> |
iterator() |
protected void |
loadEntities(boolean reload)
Called to have the entity set load its initial set of
data.
|
protected void |
purgeEntities()
Removes entities from the set that no longer match the
set's criteria.
|
void |
release()
Releases this entity set from processing further entity
updates and destroys any internal data structures.
|
protected Entity |
remove(EntityId id) |
boolean |
remove(java.lang.Object e) |
void |
resetFilter(ComponentFilter filter)
Swaps out the current main filter for a new one.
|
protected void |
setMainFilter(ComponentFilter filter) |
int |
size() |
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
protected static final DefaultEntitySet.RemovedComponent REMOVED_COMPONENT
protected DefaultEntitySet.Transaction transaction
public DefaultEntitySet(EntityData ed, ComponentFilter filter, java.lang.Class<EntityComponent>[] types)
protected java.lang.Class<EntityComponent>[] getTypes()
public java.lang.String debugId()
protected void setMainFilter(ComponentFilter filter)
protected ComponentFilter getMainFilter()
protected void loadEntities(boolean reload)
protected void purgeEntities()
public void resetFilter(ComponentFilter filter)
resetFilter
in interface EntitySet
public boolean containsId(EntityId id)
EntitySet
containsId
in interface EntitySet
public java.util.Set<EntityId> getEntityIds()
EntitySet
getEntityIds
in interface EntitySet
public Entity getEntity(EntityId id)
EntitySet
public boolean equals(java.lang.Object o)
public int size()
public java.util.Iterator<Entity> iterator()
public void clear()
public boolean add(Entity e)
public boolean remove(java.lang.Object e)
public boolean contains(java.lang.Object e)
public java.util.Set<Entity> getAddedEntities()
getAddedEntities
in interface EntitySet
public java.util.Set<Entity> getChangedEntities()
getChangedEntities
in interface EntitySet
public java.util.Set<Entity> getRemovedEntities()
getRemovedEntities
in interface EntitySet
public void clearChangeSets()
EntitySet
clearChangeSets
in interface EntitySet
public boolean hasChanges()
EntitySet
hasChanges
in interface EntitySet
public boolean applyChanges()
applyChanges
in interface EntitySet
@Deprecated public boolean applyChanges(java.util.Set<EntityChange> updates)
applyChanges
in interface EntitySet
protected boolean buildTransactionChanges(java.util.Set<EntityChange> updates)
public boolean hasFilterChanged()
protected boolean applyChanges(java.util.Set<EntityChange> updates, boolean clearChangeSets)
public void release()
protected boolean isReleased()
protected boolean entityMatches(Entity e)
protected boolean isMatchingComponent(EntityComponent c)
public final boolean hasType(java.lang.Class type)
EntitySet
protected boolean isRelevantChange(EntityChange change)
protected void entityChange(EntityChange change)
protected boolean completeEntity(DefaultEntity e)
protected java.util.concurrent.ConcurrentLinkedQueue<EntityChange> getChangeQueue()