Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- emptyArray()
- getArchetype()
- getParent()
- size()
- getReferenceTo(int)
- setComponent(int, ComponentType, T)
- getComponent(int, ComponentType)
- addEntity(Ref, Holder)
- addEntityFrom(Ref, ArchetypeChunk, int)
- addEntityFrom(Ref, ArchetypeChunk, int, ComponentType, Component)
- copyEntity(int, Holder)
- copySerializableEntity(ComponentRegistry.Data, int, Holder, Predicate)
- removeEntity(int, Holder)
- transferTo(Holder, ArchetypeChunk, Consumer, IntObjectConsumer)
- transferSomeTo(Holder, ArchetypeChunk, IntPredicate, Consumer, IntObjectConsumer)
- appendDump(String, StringBuilder)
- toString()
Class ArchetypeChunk<ECS_TYPE>
java.lang.Object
com.hypixel.hytale.component.ArchetypeChunk<ECS_TYPE>
- Type Parameters:
ECS_TYPE- The ECS entity data type.
A chunk of entities that all share the same archetype and the same parent.
-
Constructor Summary
ConstructorsConstructorDescriptionArchetypeChunk(Store<ECS_TYPE> store, Archetype<ECS_TYPE> archetype) Constructs a chunk that belongs to the store root. -
Method Summary
Modifier and TypeMethodDescriptionintCalled to add an entity to this chunk.voidaddEntityFrom(Ref<ECS_TYPE> ref, ArchetypeChunk<ECS_TYPE> source, int sourceIndex) Called to add an entity to this chunk by copying its components directly from a source chunk.voidaddEntityFrom(Ref<ECS_TYPE> ref, ArchetypeChunk<ECS_TYPE> source, int sourceIndex, ComponentType<ECS_TYPE, ?> addedType, Component<ECS_TYPE> addedComponent) Called to add an entity to this chunk by copying its components directly from a source chunk, usingaddedComponentfor the one-component type that does not exist in the source.voidappendDump(String prefix, StringBuilder sb) Called to append a dump of this chunk to the provided string builder.copyEntity(int entityIndex, Holder<ECS_TYPE> target) Called to copy an entity at the given index into the provided target holder.copySerializableEntity(ComponentRegistry.Data<ECS_TYPE> data, int entityIndex, Holder<ECS_TYPE> target, Predicate<ComponentType<ECS_TYPE, ?>> filter) Called to copy the serializable components of an entity at the given index into the provided target holder.static <ECS_TYPE> ArchetypeChunk<ECS_TYPE>[]Called to fetch and return an empty array of archetype chunks.getComponent(int index, ComponentType<ECS_TYPE, T> componentType) Called to fetch the component of an entity at the given index.getReferenceTo(int index) Called to fetch the entity reference of an entity at the given index.removeEntity(int entityIndex, Holder<ECS_TYPE> target) Called to remove an entity at the given index into the provided target holder.setComponent(int index, ComponentType<ECS_TYPE, T> componentType, T component) Called to set the component of an entity at the given index.intsize()toString()voidtransferSomeTo(Holder<ECS_TYPE> tempInternalEntityHolder, ArchetypeChunk<ECS_TYPE> chunk, IntPredicate shouldTransfer, Consumer<Holder<ECS_TYPE>> modification, IntObjectConsumer<Ref<ECS_TYPE>> referenceConsumer) Called to transfer some entities in this chunk to the provided target chunk, applying the provided modification to each entity.voidtransferTo(Holder<ECS_TYPE> tempInternalEntityHolder, ArchetypeChunk<ECS_TYPE> chunk, Consumer<Holder<ECS_TYPE>> modification, IntObjectConsumer<Ref<ECS_TYPE>> referenceConsumer) Called to transfer all entities in this chunk to the provided target chunk, applying the provided modification to each entity.
-
Constructor Details
-
ArchetypeChunk
-
-
Method Details
-
emptyArray
Called to fetch and return an empty array of archetype chunks.- Type Parameters:
ECS_TYPE- the type of ECS- Returns:
- an empty array of archetype chunks
-
getArchetype
-
getParent
-
size
public int size()- Returns:
- the number of entities in this chunk.
-
getReferenceTo
-
setComponent
public <T extends Component<ECS_TYPE>> void setComponent(int index, @Nonnull ComponentType<ECS_TYPE, T> componentType, @Nonnull T component) Called to set the component of an entity at the given index.- Type Parameters:
T- The type of component.- Parameters:
index- The index of the entity.componentType- The type of component to set.component- The component to set.
-
getComponent
@Nullable public <T extends Component<ECS_TYPE>> T getComponent(int index, @Nonnull ComponentType<ECS_TYPE, T> componentType) Called to fetch the component of an entity at the given index.- Type Parameters:
T- The type of component.- Parameters:
index- The index of the entity.componentType- The type of component to fetch.- Returns:
- the component, or
nullif the entity doesn't have the component.
-
addEntity
-
addEntityFrom
public void addEntityFrom(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ArchetypeChunk<ECS_TYPE> source, int sourceIndex) Called to add an entity to this chunk by copying its components directly from a source chunk.- Parameters:
ref- The reference of the entity to add.source- The source chunk to copy components from.sourceIndex- The index of the entity in the source chunk.
-
addEntityFrom
public void addEntityFrom(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ArchetypeChunk<ECS_TYPE> source, int sourceIndex, @Nonnull ComponentType<ECS_TYPE, ?> addedType, @Nonnull Component<ECS_TYPE> addedComponent) Called to add an entity to this chunk by copying its components directly from a source chunk, usingaddedComponentfor the one-component type that does not exist in the source.- Parameters:
ref- The reference of the entity to add.source- The source chunk to copy components from.sourceIndex- The index of the entity in the source chunk.addedType- The component type being added (not present in source).addedComponent- The component instance to store foraddedType.
-
copyEntity
Called to copy an entity at the given index into the provided target holder.- Parameters:
entityIndex- The index of the entity to copy.target- The target holder to copy the entity into.- Returns:
- the target holder.
-
copySerializableEntity
@Nonnull public Holder<ECS_TYPE> copySerializableEntity(@Nonnull ComponentRegistry.Data<ECS_TYPE> data, int entityIndex, @Nonnull Holder<ECS_TYPE> target, @Nullable Predicate<ComponentType<ECS_TYPE, ?>> filter) Called to copy the serializable components of an entity at the given index into the provided target holder.- Parameters:
data- The component data registry.entityIndex- The index of the entity to copy.target- The target holder to copy the entity into.- Returns:
- the target holder.
-
removeEntity
Called to remove an entity at the given index into the provided target holder.- Parameters:
entityIndex- The index of the entity to remove.target- The target holder to copy the entity into.- Returns:
- the target holder.
-
transferTo
public void transferTo(@Nonnull Holder<ECS_TYPE> tempInternalEntityHolder, @Nonnull ArchetypeChunk<ECS_TYPE> chunk, @Nonnull Consumer<Holder<ECS_TYPE>> modification, @Nonnull IntObjectConsumer<Ref<ECS_TYPE>> referenceConsumer) Called to transfer all entities in this chunk to the provided target chunk, applying the provided modification to each entity.- Parameters:
tempInternalEntityHolder- The temporary holder to use for transferring entities.chunk- The target chunk to transfer entities to.modification- The modification to apply to each entity before transferring.referenceConsumer- The consumer to accept the new entity index and reference after transfer.
-
transferSomeTo
public void transferSomeTo(@Nonnull Holder<ECS_TYPE> tempInternalEntityHolder, @Nonnull ArchetypeChunk<ECS_TYPE> chunk, @Nonnull IntPredicate shouldTransfer, @Nonnull Consumer<Holder<ECS_TYPE>> modification, @Nonnull IntObjectConsumer<Ref<ECS_TYPE>> referenceConsumer) Called to transfer some entities in this chunk to the provided target chunk, applying the provided modification to each entity.- Parameters:
tempInternalEntityHolder- The temporary holder to use for transferring entities.chunk- The target chunk to transfer entities to.shouldTransfer- The predicate to determine which entities to transfer.modification- The modification to apply to each entity before transferring.referenceConsumer- The consumer to accept the new entity index and reference after transfer.
-
appendDump
Called to append a dump of this chunk to the provided string builder.- Parameters:
prefix- The prefix to use for each line.sb- The string builder to append to.
-
toString
-