- Description
- Field Summary
- Method Summary
- Field Details
- Method Details
- getStoreIndex()
- getRegistry()
- getExternalData()
- getResourceStorage()
- getParallelTask()
- getFetchTask()
- getSystemMetrics()
- isShutdown()
- shutdown()
- saveAllResources()
- getEntityCount()
- getEntityCountFor(Query)
- getEntityCountFor(int)
- getArchetypeChunkCount()
- collectArchetypeChunkData()
- getArchetypeChunkCountFor(int)
- addEntity(Archetype, AddReason)
- addEntity(Archetype, AddReason, Ref)
- addEntity(Holder, AddReason)
- addEntity(Holder, AddReason, Ref)
- addEntity(Holder, Ref, AddReason)
- addEntity(Holder, Ref, AddReason, Ref)
- addEntities(Holder[], AddReason)
- addEntities(Holder[], int, int, AddReason)
- addEntities(Holder[], Ref[], AddReason)
- addEntities(Holder[], int, Ref[], int, int, AddReason)
- addEntities(Holder[], int, Ref[], int, int, AddReason, Ref)
- copyEntity(Ref)
- copyEntity(Ref, Holder)
- copySerializableEntity(Ref)
- copySerializableEntity(Ref, Holder, Predicate)
- getArchetype(Ref)
- removeEntity(Ref, RemoveReason)
- removeEntity(Ref, Holder, RemoveReason)
- removeEntities(Ref[], RemoveReason)
- removeEntities(Ref[], int, int, RemoveReason)
- removeEntities(Ref[], Holder[], RemoveReason)
- removeEntities(Ref[], int, Holder[], int, int, RemoveReason)
- getParent(Ref)
- setParent(Ref, Ref)
- ensureComponent(Ref, ComponentType)
- ensureAndGetComponent(Ref, ComponentType)
- addComponent(Ref, ComponentType)
- addComponent(Ref, ComponentType, T)
- replaceComponent(Ref, ComponentType, T)
- putComponent(Ref, ComponentType, T)
- getComponent(Ref, ComponentType)
- getComponentConcurrent(Ref, ComponentType)
- removeComponent(Ref, ComponentType)
- tryRemoveComponent(Ref, ComponentType)
- removeComponentIfExists(Ref, ComponentType)
- replaceResource(ResourceType, T)
- getResource(ResourceType)
- forEachChunk(BiConsumer)
- forEachChunk(BiPredicate)
- forEachChunk(Query, BiConsumer)
- forEachChunk(Ref, Query, BiConsumer)
- forEachChunk(Query, BiPredicate)
- forEachChunk(int, BiConsumer)
- forEachChunk(int, BiPredicate)
- forEachEntityParallel(IntBiObjectConsumer)
- forEachEntityParallel(Query, IntBiObjectConsumer)
- forEachEntityParallel(Ref, Query, IntBiObjectConsumer)
- fetch(SystemType, Q, List)
- fetch(Collection, SystemType, Q, List)
- invoke(Ref, Event)
- invoke(EntityEventType, Ref, Event)
- invoke(Holder, Event)
- invoke(EntityHolderEventType, Holder, Event)
- invoke(Event)
- invoke(WorldEventType, Event)
- tick(float)
- pausedTick(float)
- tick(ArchetypeTickingSystem, float, int)
- assertWriteProcessing()
- isProcessing()
- assertThread()
- isInThread()
- isAliveInDifferentThread()
- toString()
Class Store<ECS_TYPE>
- Type Parameters:
ECS_TYPE- The ECS entity data type.
- All Implemented Interfaces:
ComponentAccessor<ECS_TYPE>
ComponentRegistry.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Store[]An array of stores that represents an empty set.static final MetricsRegistry<Store<?>> The metrics registry for stores.static final intThe parent id of an entity that no other entity owns and that owns children.static final intThe parent id of an entity that no other entity owns and that owns no children. -
Method Summary
Modifier and TypeMethodDescriptionaddComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) Adds and returns the given component to the given entity reference.addComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType, T component) Adds the given component to the given entity reference.addEntities(Holder<ECS_TYPE>[] holders, int start, int length, AddReason reason) voidaddEntities(Holder<ECS_TYPE>[] holders, int holderStart, Ref<ECS_TYPE>[] refs, int refStart, int length, AddReason reason) The refs parameter places the invalid ref's at the end of the sub-array (refStart to refStart + length).voidaddEntities(Holder<ECS_TYPE>[] holders, int holderStart, Ref<ECS_TYPE>[] refs, int refStart, int length, AddReason reason, Ref<ECS_TYPE> parent) addEntities(Holder<ECS_TYPE>[] holders, AddReason reason) Adds the given entities to the store of this component accessor.voidAdds the given entity to the store of this component accessor.voidvoidCollects diagnostic data about all archetype chunks in the store.copyEntity(Ref<ECS_TYPE> ref) copyEntity(Ref<ECS_TYPE> ref, Holder<ECS_TYPE> holder) copySerializableEntity(Ref<ECS_TYPE> ref, Holder<ECS_TYPE> holder, Predicate<ComponentType<ECS_TYPE, ?>> filter) ensureAndGetComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) Ensures and fetches the component instance of the given type for the given entity reference.ensureComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) <T extends ArchetypeDataSystem<ECS_TYPE,Q, R>, Q, R>
voidfetch(SystemType<ECS_TYPE, T> systemType, Q query, List<R> results) Runs aSystemTypefor a subset ofArchetypeDataSystem's for allArchetypeChunkwith anArchetypethat fulfills theQueryprovided byQuerySystem.getQuery()}.<T extends EntityDataSystem<ECS_TYPE,Q, R>, Q, R>
voidfetch(Collection<Ref<ECS_TYPE>> refs, SystemType<ECS_TYPE, T> systemType, Q query, List<R> results) Runs aSystemTypefor a subset ofEntityDataSystem's for a specificRefwith anArchetypethat fulfills theQueryprovided byQuerySystem.getQuery()}voidforEachChunk(int systemIndex, BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates everyArchetypeChunkin the component store that contains a matchingQuery, this includes non-ticking archetypes.booleanforEachChunk(int systemIndex, BiPredicate<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> predicate) Iterates everyArchetypeChunkin the component store that contains a matchingQueryuntil thepredicatereturnstrue, this includes non-ticking archetypes.voidforEachChunk(Query<ECS_TYPE> query, BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates everyArchetypeChunkin the component store that contains a matchingQuery, this includes non-ticking archetypes.booleanforEachChunk(Query<ECS_TYPE> query, BiPredicate<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> predicate) Iterates everyArchetypeChunkin the component store that contains a matchingQueryuntil thepredicatereturnstrue, this includes non-ticking archetypes.voidforEachChunk(Ref<ECS_TYPE> parent, Query<ECS_TYPE> query, BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) voidforEachChunk(BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates everyArchetypeChunkin the component store, this includes non-ticking archetypes.booleanforEachChunk(BiPredicate<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> predicate) Iterates everyArchetypeChunkin the component store until thepredicatereturnstrue, this includes non-ticking archetypes.voidforEachEntityParallel(Query<ECS_TYPE> query, IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates every entity in the component store that contains a matchingQuery, this includes non-ticking entities.voidforEachEntityParallel(Ref<ECS_TYPE> parent, Query<ECS_TYPE> query, IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates every entity owned byparentthat contains a matchingQuery.voidforEachEntityParallel(IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates every entity in the component store, this includes non-ticking entities.getArchetype(Ref<ECS_TYPE> ref) Fetches the archetype for the given entity reference.intintgetArchetypeChunkCountFor(int systemIndex) getComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) Fetches the component instance of the given type for the given entity reference.getComponentConcurrent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) Reads a component from any thread, without holding the world lock.intintgetEntityCountFor(int systemIndex) intgetEntityCountFor(Query<ECS_TYPE> query) getResource(ResourceType<ECS_TYPE, T> resourceType) Fetches a resource from the given resource type.int<Event extends EcsEvent>
voidinvoke(EntityEventType<ECS_TYPE, Event> systemType, Ref<ECS_TYPE> ref, Event param) <Event extends EcsEvent>
voidinvoke(EntityHolderEventType<ECS_TYPE, Event> systemType, Holder<ECS_TYPE> holder, Event param) <Event extends EcsEvent>
voidinvoke(WorldEventType<ECS_TYPE, Event> systemType, Event param) <Event extends EcsEvent>
void<Event extends EcsEvent>
void<Event extends EcsEvent>
voidinvoke(Event param) booleanbooleanbooleanDeprecated.this method should only be used to bridge legacy code all new code should work in such a way that this isn't neededbooleanvoidpausedTick(float dt) putComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType, T component) Called to put the given component onto the given entity.removeComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) Called to remove the component of the given type from the given entity.removeComponentIfExists(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) Called to remove the component from an entity if it exists.removeEntities(Ref<ECS_TYPE>[] refs, int start, int length, RemoveReason reason) removeEntities(Ref<ECS_TYPE>[] refArr, int refStart, Holder<ECS_TYPE>[] holders, int holderStart, int length, RemoveReason reason) Removes a batch of entities, and every entity they own.removeEntities(Ref<ECS_TYPE>[] refs, Holder<ECS_TYPE>[] holders, RemoveReason reason) removeEntities(Ref<ECS_TYPE>[] refs, RemoveReason reason) removeEntity(Ref<ECS_TYPE> ref, Holder<ECS_TYPE> holder, RemoveReason reason) Called to remove the given entity from the store of this component accessor.removeEntity(Ref<ECS_TYPE> ref, RemoveReason reason) Removes an entity, and every entity it owns.replaceComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType, T component) replaceResource(ResourceType<ECS_TYPE, T> resourceType, T resource) voidMoves an entity to a different owner, keeping all of its components.voidshutdown()voidtick(float dt) voidtick(ArchetypeTickingSystem<ECS_TYPE> system, float dt, int systemIndex) Required reading:CommandBuffertoString()tryRemoveComponent(Ref<ECS_TYPE> ref, ComponentType<ECS_TYPE, T> componentType) Called to try to remove the component og the given type from the given entity.
-
Field Details
-
EMPTY_ARRAY
An array of stores that represents an empty set. -
ROOT_PARENT_ID
public static final int ROOT_PARENT_IDThe parent id of an entity that no other entity owns and that owns no children. Never allocated to a real entity.- See Also:
-
OWNER_ROOT_ID
public static final int OWNER_ROOT_IDThe parent id of an entity that no other entity owns and that owns children. Never allocated to a real entity.- See Also:
-
METRICS_REGISTRY
The metrics registry for stores.
-
-
Method Details
-
getStoreIndex
public int getStoreIndex()- Returns:
- the index of the store in the registry.
-
getRegistry
- Returns:
- the component registry associated with the store.
-
getExternalData
- Specified by:
getExternalDatain interfaceComponentAccessor<ECS_TYPE>- Returns:
- the external data of this component accessor.
-
getResourceStorage
- Returns:
- the resource storage for this store.
-
getParallelTask
-
getFetchTask
-
getSystemMetrics
- Returns:
- the system metrics for tickable systems in the store.
-
isShutdown
public boolean isShutdown()- Returns:
trueif this store is shutdown,falseotherwise.
-
shutdown
public void shutdown() -
saveAllResources
-
getEntityCount
public int getEntityCount() -
getEntityCountFor
-
getEntityCountFor
public int getEntityCountFor(int systemIndex) - Parameters:
systemIndex- The index for a registered system.- Returns:
- The number of entities that match a system.
-
getArchetypeChunkCount
public int getArchetypeChunkCount() -
collectArchetypeChunkData
Collects diagnostic data about all archetype chunks in the store.- Returns:
- an array of archetype chunk data for diagnostics
-
getArchetypeChunkCountFor
public int getArchetypeChunkCountFor(int systemIndex) - Parameters:
systemIndex- The index for a registered system.- Returns:
- The number of archetype chunks that match a system.
-
addEntity
-
addEntity
-
addEntity
@Nullable public Ref<ECS_TYPE> addEntity(@Nonnull Holder<ECS_TYPE> holder, @Nonnull AddReason reason) Description copied from interface:ComponentAccessorAdds the given entity to the store of this component accessor.- Specified by:
addEntityin interfaceComponentAccessor<ECS_TYPE>- Parameters:
holder- The holder of the entity to add.reason- The reason that we are adding this entity.- Returns:
- the entity
Refof the added entity.
-
addEntity
-
addEntity
-
addEntity
@Nullable public Ref<ECS_TYPE> addEntity(@Nonnull Holder<ECS_TYPE> holder, @Nonnull Ref<ECS_TYPE> ref, @Nonnull AddReason reason, @Nullable Ref<ECS_TYPE> parent) - Parameters:
parent- The entity that owns the new entity, ornullfor the store root. When it is no longer valid the entity is not added andnullis returned, which is the same signal as a system removing the entity during the add.- See Also:
-
addEntities
@Nonnull public Ref<ECS_TYPE>[] addEntities(@Nonnull Holder<ECS_TYPE>[] holders, @Nonnull AddReason reason) Description copied from interface:ComponentAccessorAdds the given entities to the store of this component accessor.- Specified by:
addEntitiesin interfaceComponentAccessor<ECS_TYPE>- Parameters:
holders- The holders of the entities to add.reason- The reason that we are adding these entities.- Returns:
- an array of entity
Refinstances, representing the added entities. - See Also:
-
addEntities
-
addEntities
-
addEntities
public void addEntities(@Nonnull Holder<ECS_TYPE>[] holders, int holderStart, @Nonnull Ref<ECS_TYPE>[] refs, int refStart, int length, @Nonnull AddReason reason) The refs parameter places the invalid ref's at the end of the sub-array (refStart to refStart + length). TODO: Since the ref's are shifted the index of the input holder isn't the same as the output refs. What do we care about more? Array sparsity or holder -> ref mapping? Should we provide an alternative method that doesn't shift the refs? -
addEntities
public void addEntities(@Nonnull Holder<ECS_TYPE>[] holders, int holderStart, @Nonnull Ref<ECS_TYPE>[] refs, int refStart, int length, @Nonnull AddReason reason, @Nullable Ref<ECS_TYPE> parent) - Parameters:
parent- The entity that owns every new entity, ornullfor the store root. When it is no longer valid nothing is added.- See Also:
-
copyEntity
-
copyEntity
-
copySerializableEntity
-
copySerializableEntity
-
getArchetype
Description copied from interface:ComponentAccessorFetches the archetype for the given entity reference.- Specified by:
getArchetypein interfaceComponentAccessor<ECS_TYPE>- Parameters:
ref- The entityRefto fetch the archetype for.- Returns:
- the
Archetypeof the given reference.
-
removeEntity
@Nonnull public Holder<ECS_TYPE> removeEntity(@Nonnull Ref<ECS_TYPE> ref, @Nonnull RemoveReason reason) Removes an entity, and every entity it owns. Only the named entity's data reachesholder; a child's data is discarded with it.- Parameters:
ref- The entity reference of the entity to remove.reason- The removal reason.- Returns:
- a holder containing the removed entity's components.
-
removeEntity
@Nonnull public Holder<ECS_TYPE> removeEntity(@Nonnull Ref<ECS_TYPE> ref, @Nonnull Holder<ECS_TYPE> holder, @Nonnull RemoveReason reason) Description copied from interface:ComponentAccessorCalled to remove the given entity from the store of this component accessor.- Specified by:
removeEntityin interfaceComponentAccessor<ECS_TYPE>- Parameters:
ref- The entity reference of the entity being removed.holder- The holder of the entity being removed.reason- The reason that we are removing this entity.- Returns:
- the holder of the removed entity.
-
removeEntities
@Nonnull public Holder<ECS_TYPE>[] removeEntities(@Nonnull Ref<ECS_TYPE>[] refs, @Nonnull RemoveReason reason) -
removeEntities
@Nonnull public Holder<ECS_TYPE>[] removeEntities(@Nonnull Ref<ECS_TYPE>[] refs, int start, int length, @Nonnull RemoveReason reason) -
removeEntities
-
removeEntities
-
getParent
-
setParent
Moves an entity to a different owner, keeping all of its components.Hierarchy is two layers deep. An entity that owns children cannot be given a parent, and an entity that has a parent cannot be given children.
- Parameters:
ref- The entity reference of the entity to move.parent- The new owner, ornullto give the entity back to the store root.
-
ensureComponent
-
ensureAndGetComponent
@Nonnull public <T extends Component<ECS_TYPE>> T ensureAndGetComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType) Description copied from interface:ComponentAccessorEnsures and fetches the component instance of the given type for the given entity reference.- Specified by:
ensureAndGetComponentin interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The component class type.- Parameters:
ref- The entity reference that we are fetching the component for.componentType- The component type of the component.- Returns:
- the component of the reference.
-
addComponent
@Nonnull public <T extends Component<ECS_TYPE>> T addComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType) Description copied from interface:ComponentAccessorAdds and returns the given component to the given entity reference.- Specified by:
addComponentin interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The component class type.- Parameters:
ref- The entityRefthat we are adding this component to.componentType- The type of the component.- Returns:
- the newly instantiated instance of the component.
-
addComponent
public <T extends Component<ECS_TYPE>> void addComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType, @Nonnull T component) Description copied from interface:ComponentAccessorAdds the given component to the given entity reference.- Specified by:
addComponentin interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The component class type.- Parameters:
ref- The entityRefthat we are adding this component to.componentType- The type of the component.component- The component instance to be added.
-
replaceComponent
-
putComponent
public <T extends Component<ECS_TYPE>> void putComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType, @Nonnull T component) Description copied from interface:ComponentAccessorCalled to put the given component onto the given entity.- Specified by:
putComponentin interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The component class type.- Parameters:
ref- The entity reference of the entity.componentType- The component type of the component being put.component- The component instance that is being put.
-
getComponent
public <T extends Component<ECS_TYPE>> T getComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType) Description copied from interface:ComponentAccessorFetches the component instance of the given type for the given entity reference.- Specified by:
getComponentin interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The component class type.- Parameters:
ref- The entity reference that we are fetching the component for.componentType- The component type of the component.- Returns:
- the component of the reference, or
nullif one doesn't exist.
-
getComponentConcurrent
@Nullable public <T extends Component<ECS_TYPE>> T getComponentConcurrent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType) Reads a component from any thread, without holding the world lock. The returned object belongs torefand is never one from a different entity that has reused the same chunk slot.Returns
nullwhen the entity does not havecomponentType, or whenrefis invalidated during the read.This protects against slot reuse, not against field mutation. The world thread can write fields on the returned component while the reader is using it, so individual field reads can be torn. Copy out the fields you need on the world thread if you require a consistent snapshot.
Each call takes its own seqlock pass. Two calls for the same entity can resolve in different ticks, so this is not a way to read several components and expect them to agree with each other.
-
removeComponent
public <T extends Component<ECS_TYPE>> void removeComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType) Description copied from interface:ComponentAccessorCalled to remove the component of the given type from the given entity.- Specified by:
removeComponentin interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The component type based on the store type.- Parameters:
ref- The entity reference of the entity that we are removing the component from.componentType- The component type of the component that we are removing.
-
tryRemoveComponent
public <T extends Component<ECS_TYPE>> void tryRemoveComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType) Description copied from interface:ComponentAccessorCalled to try to remove the component og the given type from the given entity.- Specified by:
tryRemoveComponentin interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The component type based on the store type.- Parameters:
ref- The entity reference of the entity that we are removing the component from.componentType- The component type of the component that we are removing.
-
removeComponentIfExists
public <T extends Component<ECS_TYPE>> boolean removeComponentIfExists(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE, T> componentType) Called to remove the component from an entity if it exists.- Type Parameters:
T- The component type.- Parameters:
ref- The entity reference of the entity.componentType- The component type of the component to remove.- Returns:
trueif the component was removed,falseif the entity didn't have the component.
-
replaceResource
public <T extends Resource<ECS_TYPE>> void replaceResource(@Nonnull ResourceType<ECS_TYPE, T> resourceType, @Nonnull T resource) -
getResource
@Nonnull public <T extends Resource<ECS_TYPE>> T getResource(@Nonnull ResourceType<ECS_TYPE, T> resourceType) Description copied from interface:ComponentAccessorFetches a resource from the given resource type.- Specified by:
getResourcein interfaceComponentAccessor<ECS_TYPE>- Type Parameters:
T- The resource type.- Parameters:
resourceType- The resource type to fetch.- Returns:
- the
Resourceof the given class type.
-
forEachChunk
public void forEachChunk(@Nonnull BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates everyArchetypeChunkin the component store, this includes non-ticking archetypes.- Parameters:
consumer- the task to run for eachArchetypeChunk.
-
forEachChunk
public boolean forEachChunk(@Nonnull BiPredicate<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> predicate) Iterates everyArchetypeChunkin the component store until thepredicatereturnstrue, this includes non-ticking archetypes.- Parameters:
predicate- The task to run for eachArchetypeChunk. If the predicate returnstruethen iteration is stopped.- Returns:
trueif thepredicatereturnstruefor any chunk.
-
forEachChunk
public void forEachChunk(Query<ECS_TYPE> query, @Nonnull BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates everyArchetypeChunkin the component store that contains a matchingQuery, this includes non-ticking archetypes.- Parameters:
query- TheQuerythat is used to filter the iteratedArchetypeChunk's.consumer- The task to run for eachArchetypeChunk.
-
forEachChunk
public void forEachChunk(@Nullable Ref<ECS_TYPE> parent, @Nonnull Query<ECS_TYPE> query, @Nonnull BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates everyArchetypeChunkowned byparentthat contains a matchingQuery.Parent scoping is a runtime argument and never part of a
Query, becauseQuery.test(Archetype)is what builds the cached system bitsets and those describe an archetype, not a parent.- Parameters:
parent- The owning entity, ornullfor the entities the store owns directly.query- TheQuerythat is used to filter the iteratedArchetypeChunk's.consumer- The task to run for eachArchetypeChunk.
-
forEachChunk
public boolean forEachChunk(Query<ECS_TYPE> query, @Nonnull BiPredicate<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> predicate) Iterates everyArchetypeChunkin the component store that contains a matchingQueryuntil thepredicatereturnstrue, this includes non-ticking archetypes.- Parameters:
query- TheQuerythat is used to filter the iteratedArchetypeChunk's.predicate- The task to run for eachArchetypeChunk. If the predicate returnstruethen iteration is stopped.- Returns:
trueif thepredicatereturnstruefor any chunk
-
forEachChunk
public void forEachChunk(int systemIndex, @Nonnull BiConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates everyArchetypeChunkin the component store that contains a matchingQuery, this includes non-ticking archetypes.- Parameters:
systemIndex- The systemIndex of aQuerySystemthat is used to filter the iteratedArchetypeChunk's.consumer- The task to run for eachArchetypeChunk.
-
forEachChunk
public boolean forEachChunk(int systemIndex, @Nonnull BiPredicate<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> predicate) Iterates everyArchetypeChunkin the component store that contains a matchingQueryuntil thepredicatereturnstrue, this includes non-ticking archetypes.- Parameters:
systemIndex- The systemIndex of aQuerySystemthat is used to filter the iteratedArchetypeChunk's.predicate- The task to run for eachArchetypeChunk. If the predicate returnstruethen iteration is stopped.- Returns:
trueif thepredicatereturnstruefor any chunk
-
forEachEntityParallel
public void forEachEntityParallel(IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates every entity in the component store, this includes non-ticking entities.- Parameters:
consumer- the task to run for each entity.
-
forEachEntityParallel
public void forEachEntityParallel(Query<ECS_TYPE> query, IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates every entity in the component store that contains a matchingQuery, this includes non-ticking entities.- Parameters:
query- TheQuerythat is used to filter the iterated entities.consumer- The task to run for eachArchetypeChunk.
-
forEachEntityParallel
public void forEachEntityParallel(@Nullable Ref<ECS_TYPE> parent, @Nonnull Query<ECS_TYPE> query, @Nonnull IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer) Iterates every entity owned byparentthat contains a matchingQuery.- Parameters:
parent- The owning entity, ornullfor the entities the store owns directly.query- TheQuerythat is used to filter the iterated entities.consumer- The task to run for each entity.
-
fetch
public <T extends ArchetypeDataSystem<ECS_TYPE,Q, void fetchR>, Q, R> (@Nonnull SystemType<ECS_TYPE, T> systemType, Q query, @Nonnull List<R> results) Runs aSystemTypefor a subset ofArchetypeDataSystem's for allArchetypeChunkwith anArchetypethat fulfills theQueryprovided byQuerySystem.getQuery()}.- Type Parameters:
T-Q-R-
-
fetch
public <T extends EntityDataSystem<ECS_TYPE,Q, void fetchR>, Q, R> (@Nonnull Collection<Ref<ECS_TYPE>> refs, @Nonnull SystemType<ECS_TYPE, T> systemType, @Nonnull Q query, @Nonnull List<R> results) Runs aSystemTypefor a subset ofEntityDataSystem's for a specificRefwith anArchetypethat fulfills theQueryprovided byQuerySystem.getQuery()}- Type Parameters:
T- The system type.Q- The query type.R- The result type.
-
invoke
-
invoke
public <Event extends EcsEvent> void invoke(@Nonnull EntityEventType<ECS_TYPE, Event> systemType, @Nonnull Ref<ECS_TYPE> ref, @Nonnull Event param) - Specified by:
invokein interfaceComponentAccessor<ECS_TYPE>
-
invoke
-
invoke
public <Event extends EcsEvent> void invoke(@Nonnull EntityHolderEventType<ECS_TYPE, Event> systemType, @Nonnull Holder<ECS_TYPE> holder, @Nonnull Event param) - Specified by:
invokein interfaceComponentAccessor<ECS_TYPE>
-
invoke
- Specified by:
invokein interfaceComponentAccessor<ECS_TYPE>
-
invoke
public <Event extends EcsEvent> void invoke(@Nonnull WorldEventType<ECS_TYPE, Event> systemType, @Nonnull Event param) - Specified by:
invokein interfaceComponentAccessor<ECS_TYPE>
-
tick
public void tick(float dt) -
pausedTick
public void pausedTick(float dt) -
tick
Required reading:CommandBufferThis is a utility method that contains the underlying ticking functionality for
ArchetypeTickingSystem. This allows systems to provide functionality before the ticking of anArchetypeChunkby overridingTickingSystem.tick(float, int, Store)and then calling to this method when ticking ofArchetypeChunk's is wanted.For example, to only tick the
ArchetypeChunk's when a condition is met:
This allows for greatly improved performance by only checking the condition once per tick instead of for eachpublic void tick(float dt, int systemIndex, Store<ECS_TYPE> store, CommandBuffer<ECS_TYPE> commandBuffer) { if (someCondition) { store.tick(this, dt, systemIndex); } }ArchetypeChunk. -
assertWriteProcessing
public void assertWriteProcessing() -
isProcessing
Deprecated.this method should only be used to bridge legacy code all new code should work in such a way that this isn't needed- Returns:
-
assertThread
public void assertThread() -
isInThread
public boolean isInThread() -
isAliveInDifferentThread
public boolean isAliveInDifferentThread() -
toString
-