Class CellEntityLayerGroup
Represents a group of cell entity layers within a hex-based terrain, providing management and initialization CellEntity layers. CellEntity layers are specialized terrain layers that handle entities associated with terrain cells.
Inheritance
Inherited Members
Namespace: Fwt.HexTerrains.CellEntities.Data
Assembly: fwt.hexterrains.dll
Syntax
public class CellEntityLayerGroup : HexTerrainLayerGroup<CellEntityLayer>, IDisposable, ISerializableTerrainLayer, IComponentData, IQueryTypeParameter
Remarks
This class coordinates multiple cell entity layers and facilitates their initialization, configuration, and entity update operations. It is typically used in scenarios where terrain cells are represented as entities and require batch processing or coordinated updates. Thread safety depends on the usage context and the underlying systems managing the layers.
Fields
_allCellEntityConfigs
Represents the collection of all cell entity configurations available to the cell entity layers.
Declaration
protected NativeArray<CellEntityStateConfig> _allCellEntityConfigs
Field Value
| Type | Description |
|---|---|
| NativeArray<CellEntityStateConfig> |
Properties
EntityManager
Entity manager used for managing entity lifecycle within the cell entity layers.
Declaration
public EntityManager EntityManager { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityManager |
Methods
CalculateEntities(JobHandle)
Schedules entity calculation jobs for all layers and returns a handle that represents their combined dependencies.
Declaration
public virtual JobHandle CalculateEntities(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | A job handle representing the dependency that must be completed before entity calculation jobs are scheduled. |
Returns
| Type | Description |
|---|---|
| JobHandle | A job handle that represents the combined dependencies of all scheduled entity calculation jobs and the specified dependency. If there are no layers, returns the original dependency. |
Remarks
This method iterates through all layers, scheduling their entity calculation jobs and combining their dependencies. If a layer is null, it is skipped. The returned job handle can be used to ensure that all entity calculations are complete before proceeding.
CreateTerrainLayer<TInitArgs>(TInitArgs)
This function is called to create a new terrain layer of type TTerrainLayer. Default implementation uses an Activator to create a new instance of TTerrainLayer, expecting that the TTerrainLayer has a parameterless constructor. Override this function in your derived class to have a custom way of creating a terrain layer.
Declaration
public override CellEntityLayer CreateTerrainLayer<TInitArgs>(TInitArgs initArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| TInitArgs | initArgs | Initialization arguments for creating a layer |
Returns
| Type | Description |
|---|---|
| CellEntityLayer | Returns a created instance of the terrain layer of type (inherited from) TTerrainLayer |
Type Parameters
| Name | Description |
|---|---|
| TInitArgs | Init terrain layer arguments object that is used in create layer process. Default implementation ignores this parameter, but in your overrided implementation it may be needed |
Overrides
InitTerrainLayer<TInitArgs>(CellEntityLayer, HexTerrainSettings, TInitArgs)
Initializes the specified terrain cell entity layer using the provided settings and initialization arguments.
Declaration
public override void InitTerrainLayer<TInitArgs>(CellEntityLayer layer, HexTerrainSettings settings, TInitArgs initArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| CellEntityLayer | layer | The cell entity layer to initialize. Must not be null. |
| HexTerrainSettings | settings | The terrain settings to apply during initialization. |
| TInitArgs | initArgs | The initialization arguments used to configure the layer. Must be compatible with the expected argument type for the layer. |
Type Parameters
| Name | Description |
|---|---|
| TInitArgs | The type of the initialization arguments used to configure the terrain layer. |
Overrides
Remarks
If the initialization arguments are of type CreateCellEntityLayerRequest, the method sets up the layer with the current entity manager and configuration. Otherwise, the base implementation is called. The method does not throw an exception if the arguments are not compatible, but delegates to the base method.
Init<TInitLayerArgs>(HexTerrainSettings, IEnumerable<TInitLayerArgs>, NativeArray<CellEntityStateConfig>, EntityManager)
Declaration
public virtual void Init<TInitLayerArgs>(HexTerrainSettings settings, IEnumerable<TInitLayerArgs> initLayerArgs, NativeArray<CellEntityStateConfig> cellEntityConfigs, EntityManager entityManager)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | |
| IEnumerable<TInitLayerArgs> | initLayerArgs | |
| NativeArray<CellEntityStateConfig> | cellEntityConfigs | |
| EntityManager | entityManager |
Type Parameters
| Name | Description |
|---|---|
| TInitLayerArgs |
UpdateEntities(Entity, JobHandle)
Updates all entities in the collection of layers using the specified root entity and job dependency handle.
Declaration
public virtual JobHandle UpdateEntities(Entity layerEntity, JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| Entity | layerEntity | The root entity to be used when updating each layer. This entity is typically passed to each layer's update operation. |
| JobHandle | dependency | A job handle representing the dependency that must be completed before the update operations begin. This handle is combined with the handles returned by each layer's update. |
Returns
| Type | Description |
|---|---|
| JobHandle | A job handle that represents the combined dependencies of all update operations performed on the layers. If there are no layers, returns the original dependency handle. |
Remarks
If the collection of layers is null or empty, no update operations are performed and the input dependency is returned unchanged. The returned job handle can be used to ensure that all layer updates have completed before proceeding.