Class CellEntitiesLayer
Base class for HexTerrain layers that contain an Entity per cell.
Implements
Inherited Members
Namespace: Fwt.HexTerrains.CellEntities.Data
Assembly: fwt.hexterrains.dll
Syntax
public abstract class CellEntitiesLayer : IDisposable
Fields
CellEntities
Data layer for storing a CellEntity per cell
Declaration
public HexCellEntityDataLayer CellEntities
Field Value
| Type | Description |
|---|---|
| HexCellEntityDataLayer |
CellEntityViews
Data layer for storing a CellEntityView (Entity instances) per cell
Declaration
public HexCellEntityViewDataLayer CellEntityViews
Field Value
| Type | Description |
|---|---|
| HexCellEntityViewDataLayer |
CellTransforms
Data layer for storing a CellTransform per cell (taken from the HexSurfaceLayer layer)
Declaration
public CellTransformDataLayer CellTransforms
Field Value
| Type | Description |
|---|---|
| CellTransformDataLayer |
EntitiesColorMap
Data layer for storing a Color per cell
Declaration
public CellColorsDataLayer EntitiesColorMap
Field Value
| Type | Description |
|---|---|
| CellColorsDataLayer |
EntityManager
Cached EntityManager used to destroy CellEntity instances when the terrain is destroyed or resized
Declaration
public EntityManager EntityManager
Field Value
| Type | Description |
|---|---|
| EntityManager |
ItemConfigs
List of configs for every possible CellEntity index
Declaration
public NativeList<HexCellEntityConfig> ItemConfigs
Field Value
| Type | Description |
|---|---|
| NativeList<HexCellEntityConfig> |
SetChunkIndexCommandBuffer
CommandBuffer that holds commands for updating the CellEntity instances (entities)
Declaration
public EntityCommandBuffer SetChunkIndexCommandBuffer
Field Value
| Type | Description |
|---|---|
| EntityCommandBuffer |
SetChunkIndexCommandBufferDependency
Job handle for the job that updates chunk index of every CellEntity instance
Declaration
public JobHandle SetChunkIndexCommandBufferDependency
Field Value
| Type | Description |
|---|---|
| JobHandle |
Properties
ColorMapTextureIndex
Index of the texture in the list of ColorMapTextures. Used externally in systems. Systems read this value to know which texture to fill with colors from EntitiesColorMap data layer EntitiesColorMap. That texture is expected to be used in materials or/and UI like minimap.
Declaration
public int ColorMapTextureIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Settings
Settings of the Terrain this layer is attached to
Declaration
public HexTerrainSettings Settings { get; protected set; }
Property Value
| Type | Description |
|---|---|
| HexTerrainSettings |
Methods
Cleanup()
Every frame there is a cleanup stage. This function is called. Usually used to clean the dirty flags.
Declaration
public virtual void Cleanup()
CleanupAsync()
Async version of Cleanup() Cleanup() Difference between regular Cleanup() is that it schedules jobs that clean up data layers, so you don't have to wait for the results and can continue working. Every frame there is a cleanup stage. This function is called. Usually used to clean the dirty flags.
Declaration
public virtual void CleanupAsync()
CompleteAllJobs()
Completes all jobs that are scheduled for this layer.
Declaration
public virtual void CompleteAllJobs()
Dispose()
Declaration
public virtual void Dispose()
GetCellEntity(int)
Gets the CellEntity value from the cell at the given index.
Declaration
public virtual CellEntity? GetCellEntity(int cellIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | cell index where to get data from |
Returns
| Type | Description |
|---|---|
| CellEntity? | CellEntity if found, otherwise - null |
Init(HexTerrainSettings)
Initializes/Reinitializes the CellEntities data.
Declaration
public virtual void Init(HexTerrainSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | new terrain settings |
Init(HexTerrainSettings, NativeArray<HexCellEntityConfig>, EntityManager)
Initializes/Reinitializes the cell entities data. Calls InitCellEntitiesConfigs() internally to copy the color palette from the given array InitCellEntitiesConfigs(NativeArray<HexCellEntityConfig>). Only copies data from the copyItemConfigsFrom array, does not change or cache, so it is safe to dispose it after this call.
Declaration
public virtual void Init(HexTerrainSettings settings, NativeArray<HexCellEntityConfig> copyItemConfigsFrom, EntityManager entityManager)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | new terrain settings |
| NativeArray<HexCellEntityConfig> | copyItemConfigsFrom | array of colors per CellEntity index to copy a ItemConfigs from |
| EntityManager | entityManager |
Init(HexTerrainSettings, EntityManager)
Initializes/Reinitializes the CellEntities data.
Declaration
public virtual void Init(HexTerrainSettings settings, EntityManager entityManager)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | new terrain settings |
| EntityManager | entityManager | EntityManager used to destroy CellEntities instances when the terrain is destroyed or resized |
InitCellEntitiesConfigs(NativeArray<HexCellEntityConfig>)
Copies an ItemConfigs from the given array. Does not change or cache the array, so it is safe to dispose it after this call. copyFrom array is expected to have the CellEntity indexes length, so there is one config per possible CellEntity index. CellEntity.Index == index in copyFrom array.
Declaration
public void InitCellEntitiesConfigs(NativeArray<HexCellEntityConfig> copyFrom)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArray<HexCellEntityConfig> | copyFrom | array of configs to copy into the ItemConfigs |
Resize(int2)
Resizes the CellEntities data. Calls Init() method to reinitialize the CellEntities data.
Declaration
public virtual void Resize(int2 terrainSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | terrainSize |
SetAllCellsEntity(CellEntity)
Sets the CellEntity value to all cells in the layer.
Declaration
public virtual bool SetAllCellsEntity(CellEntity value)
Parameters
| Type | Name | Description |
|---|---|---|
| CellEntity | value | value to set to every cell |
Returns
| Type | Description |
|---|---|
| bool | true if data was set, otherwise - false |
SetAllDirty(bool)
Sets the dirty flag for all the data layers. If isDirty is true, all data layers will be marked as dirty and will be recalculated. If isDirty is false, all data layers will be marked as clean and will not be recalculated.
Declaration
public virtual void SetAllDirty(bool isDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isDirty |
SetCellEntity(int, CellEntity)
Sets the CellEntity value to the cell at the given index.
Declaration
public virtual bool SetCellEntity(int cellIndex, CellEntity item)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | cell index of the cell to set data to |
| CellEntity | item | data to set into the cell at cellIndex index |
Returns
| Type | Description |
|---|---|
| bool | true if data was set, otherwise - false |