CreateEntityBatch.md
July 25, 2024 · View on GitHub
Friflo.Engine.ECS
Friflo.Engine.ECS
CreateEntityBatch Class
A create batch is used to optimize entity creation.
Components and tags are buffered before creating an entity with CreateEntity().
See Example.
public sealed class CreateEntityBatch
Inheritance System.Object 🡒 CreateEntityBatch
Remarks
Multiple entities can be created using the same batch.
Creating an entity via a batch stores the entity directly in the target Archetype
This prevents any structural changes caused when creating an entity in steps using
CreateEntity() a subsequent calls to AddComponent<T>()
and AddTag<TTag>().
| Constructors | |
|---|---|
| CreateEntityBatch(EntityStoreBase) | Creates a batch used to create entities with components and tags added to the batch. The created batch instance can be cached. |
| Properties | |
|---|---|
| ComponentCount | Return the of components added to the batch. |
| TagCount | Return the of tags added to the batch. |
| Methods | |
|---|---|
| Add<T>() | Add a component that will be added to the entity when calling CreateEntity(). |
| Add<T>(T) | Add the given component that will be added to the entity when calling CreateEntity(). |
| AddTag<T>() | Add a tag that will be added to the entity when calling CreateEntity(). |
| AddTags(Tags) | Adds the given tags that will be added to the entity when calling CreateEntity(). |
| Clear() | Clear all components and tags previously added to the batch. |
| CreateEntity() | Creates an entity with the components and tags previously added. Added batch components and tags are not cleared. |
| CreateEntity(int) | Creates an entity with the specified id and the components and tags previously added. Added batch components and tags are not cleared. |
| Disable() | |
| Get<T>() | Get a component by reference previously added to the batch. This enables creation of multiple entities using the same batch. |
| Return() | Return the batch instance to its EntityStore to prevent memory allocations for future Batch(bool) calls. |
| ToString() |