Class HexTerrainLayer
Base class for HexTerrain layer. Your custom layers can be derived from this class to keep the proposed terrain layers standard. But system does not require you to derive from this class, you can create your own layers that do not inherit from it.
Inheritance
Implements
Inherited Members
Namespace: Fwt.HexTerrains.Data
Assembly: fwt.hexterrains.dll
Syntax
public abstract class HexTerrainLayer : IDisposable
Fields
Settings
Settings of the HexTerrain this area is attached to
Declaration
public HexTerrainSettings Settings
Field Value
| Type | Description |
|---|---|
| HexTerrainSettings |
Properties
Name
Name of the layer. Optional, but recommended to set a unique name for each layer instance, as if the terrain layer is a nested layer of the HexTerrainLayerGroup, this name is used to get layer by name.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ParentLayer
Reference to the parent terrain layer (if present). Is not disposed when this layer is disposed.
Declaration
public HexTerrainLayer ParentLayer { get; set; }
Property Value
| Type | Description |
|---|---|
| HexTerrainLayer |
Methods
CalculateColorMap(JobHandle)
Schedules the calculation of the color map, ensuring it is executed after the specified job dependency completes.
Declaration
public virtual JobHandle CalculateColorMap(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | A job handle representing the dependency that must be completed before the color map calculation begins. |
Returns
| Type | Description |
|---|---|
| JobHandle | A job handle that can be used to track the completion of the color map calculation job. |
Cleanup()
Every frame there is a cleanup stage. This function is called. Usually used to clean the dirty flags.
Declaration
public abstract void Cleanup()
CleanupAsync(JobHandle)
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 abstract JobHandle CleanupAsync(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency |
Returns
| Type | Description |
|---|---|
| JobHandle |
CompleteAllJobs()
Completes all jobs that affect data layers.
Declaration
public virtual void CompleteAllJobs()
Dispose()
Disposes all allocated native memory.
Declaration
public virtual void Dispose()
GetTerrainLayerFromParent<TLayer>(HexTerrainLayerReference)
Retrieves a terrain layer of the specified type from the parent layer group using the provided reference.
Declaration
public virtual TLayer GetTerrainLayerFromParent<TLayer>(HexTerrainLayerReference layerArgs) where TLayer : HexTerrainLayer
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainLayerReference | layerArgs | A reference that identifies the terrain layer to retrieve from the parent group. |
Returns
| Type | Description |
|---|---|
| TLayer | The terrain layer of type TLayer if found in the parent group; otherwise, the default value for TLayer. |
Type Parameters
| Name | Description |
|---|---|
| TLayer | The type of terrain layer to retrieve. Must derive from HexTerrainLayer. |
Remarks
If the parent layer is not a HexTerrainLayerGroup or does not contain a layer matching the reference, the method returns the default value for TLayer.
GetTerrainLayerFromParent<TLayer>(int)
Returns the terrain layer of the specified type from the parent layers list (if present).
Declaration
public virtual TLayer GetTerrainLayerFromParent<TLayer>(int layerIndex) where TLayer : HexTerrainLayer
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerIndex | Index of layer in the parent layers list |
Returns
| Type | Description |
|---|---|
| TLayer | Layer from parent layers list if found or null if not found |
Type Parameters
| Name | Description |
|---|---|
| TLayer | Type of layer to find |
GetTerrainLayerFromParent<TLayer>(int, string)
Returns the terrain layer of the specified type from the parent layers list (if present).
Declaration
public virtual TLayer GetTerrainLayerFromParent<TLayer>(int layerIndex, string layerName) where TLayer : HexTerrainLayer
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerIndex | |
| string | layerName | Name of layer in the parent layers list |
Returns
| Type | Description |
|---|---|
| TLayer | Layer from parent layers list if found or null if not found |
Type Parameters
| Name | Description |
|---|---|
| TLayer | Type of layer to find |
GetTerrainLayerFromParent<TLayer>(string)
Returns the terrain layer of the specified type from the parent layers list (if present).
Declaration
public virtual TLayer GetTerrainLayerFromParent<TLayer>(string layerName) where TLayer : HexTerrainLayer
Parameters
| Type | Name | Description |
|---|---|---|
| string | layerName | Name of layer in the parent layers list |
Returns
| Type | Description |
|---|---|
| TLayer | Layer from parent layers list if found or null if not found |
Type Parameters
| Name | Description |
|---|---|
| TLayer | Type of layer to find |
Init(HexTerrainSettings)
Initializes/Reinitializes the area data.
Declaration
public virtual void Init(HexTerrainSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | new terrain settings |
InitColoredDataLayer<TValue>(ColorMapCellValueDataLayer<TValue>, IInitColorMapCellValueDataLayerArgs<TValue>)
Initializes the specified colored data layer using the provided initialization arguments.
Declaration
public virtual void InitColoredDataLayer<TValue>(ColorMapCellValueDataLayer<TValue> dataLayer, IInitColorMapCellValueDataLayerArgs<TValue> args) where TValue : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| ColorMapCellValueDataLayer<TValue> | dataLayer | The colored data layer to initialize. |
| IInitColorMapCellValueDataLayerArgs<TValue> | args | The arguments used to configure and initialize the colored data layer. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the cell value contained in the data layer. Must be an unmanaged type. |
InitDataLayer<TValue>(CellValueDataLayer<TValue>, IInitCellValueDataLayerArgs<TValue>)
Initializes the specified cell value data layer using the provided initialization arguments.
Declaration
public virtual void InitDataLayer<TValue>(CellValueDataLayer<TValue> dataLayer, IInitCellValueDataLayerArgs<TValue> args) where TValue : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| CellValueDataLayer<TValue> | dataLayer | The cell value data layer to initialize. Cannot be null. |
| IInitCellValueDataLayerArgs<TValue> | args | The initialization arguments to use for configuring the data layer. Cannot be null. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of value stored in the data layer. Must be an unmanaged type. |
Init<TInitArgs>(HexTerrainSettings, TInitArgs)
Initializes the terrain system using the specified settings and initialization arguments.
Declaration
public virtual void Init<TInitArgs>(HexTerrainSettings settings, TInitArgs initArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | The configuration settings to apply when initializing the terrain system. Cannot be null. |
| TInitArgs | initArgs | Additional arguments required for initialization. The expected type and usage depend on the implementation. |
Type Parameters
| Name | Description |
|---|---|
| TInitArgs | The type of the initialization arguments to be used during terrain system setup. |
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 |
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 abstract void SetAllDirty(bool isDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isDirty |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |