Class HexByteAreasLayer
Base class for HexTerrain layers that have a byte value per cell
Implements
Inherited Members
Namespace: Fwt.HexTerrains.Areas.Data
Assembly: fwt.hexterrains.dll
Syntax
public abstract class HexByteAreasLayer : IDisposable
Fields
Settings
Settings of the HexTerrain this area is attached to
Declaration
public HexTerrainSettings Settings
Field Value
| Type | Description |
|---|---|
| HexTerrainSettings |
Properties
AreaCells
Cell indexes per area
Declaration
public ByteAreaCellsDataLayer AreaCells { get; set; }
Property Value
| Type | Description |
|---|---|
| ByteAreaCellsDataLayer |
AreaColors
Palette of colors for the areas. Index in this list = area index. Used to calculate the AreasColorMap data layer AreasColorMap, which is used to fill a ColorTexture to be placed on UI or in terrain materials.
Declaration
public NativeList<Color32> AreaColors { get; set; }
Property Value
| Type | Description |
|---|---|
| NativeList<Color32> |
AreaSizes
Size per area
Declaration
public ByteAreaSizesDataLayer AreaSizes { get; set; }
Property Value
| Type | Description |
|---|---|
| ByteAreaSizesDataLayer |
AreasColorMap
Cell Area color per cell
Declaration
public CellColorsDataLayer AreasColorMap { get; set; }
Property Value
| Type | Description |
|---|---|
| CellColorsDataLayer |
CellAreaMap
Area index per cell
Declaration
public CellByteAreaDataLayer CellAreaMap { get; set; }
Property Value
| Type | Description |
|---|---|
| CellByteAreaDataLayer |
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 AreasColorMap data layer AreasColorMap. 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 |
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 affect data layers.
Declaration
public virtual void CompleteAllJobs()
Dispose()
Declaration
public virtual void Dispose()
GetCellArea(int)
Returns the area index of the cell.
Declaration
public virtual byte? GetCellArea(int cellIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | cell index to take area index from |
Returns
| Type | Description |
|---|---|
| byte? | area index if found, otherwise - null |
Init(HexTerrainSettings)
Initializes/Reinitializes the area data.
Declaration
public virtual void Init(HexTerrainSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | new terrain settings |
Init(HexTerrainSettings, NativeArray<Color32>)
Initializes/Reinitializes the areas data. Calls InitAreaColors() internally to copy the color palette from the given array InitAreaColors(NativeArray<Color32>). Only copies data from the copyAreaColorsFrom array, does not change or cache, so it is safe to dispose it after this call.
Declaration
public virtual void Init(HexTerrainSettings settings, NativeArray<Color32> copyAreaColorsFrom)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | new terrain settings |
| NativeArray<Color32> | copyAreaColorsFrom | array of colors per area to copy a AreaColors palette from |
InitAreaColors(NativeArray<Color32>)
Copies an AreaColors palette from the given array AreaColors. Does not change or cache the array, so it is safe to dispose it after this call. copyFrom array is expected to have the areas count length, so there is one color per possible area index. AreaIndex == index in copyFrom array.
Declaration
public virtual void InitAreaColors(NativeArray<Color32> copyFrom)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArray<Color32> | copyFrom | array of colors to copy into the AreaColors palette |
Resize(int2)
Resizes the terrain to a new size. Internally calls Init() to reinitialize the data layers.
Declaration
public virtual void Resize(int2 terrainSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | terrainSize |
SetAllCellsArea(byte)
Sets the area index of all cells to the given value.
Declaration
public virtual bool SetAllCellsArea(byte value)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | value | area index to set for every cell |
Returns
| Type | Description |
|---|---|
| bool | true if data vas set, otherwise - false |
SetAllDirty(bool)
Sets all data layers dirty value. If isDirty is true, all data layers will be marked as dirty and will be recalculated on the next frame. If isDirty is false, all data layers will be marked as clean and will not be recalculated on the next frame.
Declaration
public void SetAllDirty(bool isDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isDirty |
SetCellArea(int, byte)
Sets the area index of the cell.
Declaration
public virtual bool SetCellArea(int cellIndex, byte value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | cell index to put area index to |
| byte | value | area index to put into the cell |
Returns
| Type | Description |
|---|---|
| bool | true if data has been set, otherwise - false |