Class CellMineralsLayer
Terrain layer that holds the mineral data for each cell in the hex terrain. It contains two maps: one for the mineral indices and another for the mineral amounts. The mineral index map uses an unsigned integer to represent the type of mineral present in each cell, while the mineral amount map uses a float to represent the quantity of minerals present in each cell.
Implements
Inherited Members
Namespace: Fwt.HexTerrains.Minerals.Data
Assembly: fwt.hexterrains.dll
Syntax
public class CellMineralsLayer : HexTerrainLayer, IDisposable
Fields
AmountMap
Map of mineral amounts, where the value of each cell is a float representing the amount of minerals present in that cell.
Declaration
public CellValueDataLayer<float> AmountMap
Field Value
| Type | Description |
|---|---|
| CellValueDataLayer<float> |
MaxMineralAmount
List of max values per each type of mineral in cell. Technically this does not restrict the actual amount of minerals in a cell, but it can be used for visualization purposes (e.g. to calculate the transparency of the mineral color in the color map, where MinMineralsAmount means fully transparent and MaxMineralsAmount means fully opaque). Index = mineral id, value = max amount for that mineral in a cell.
Declaration
public NativeListDataLayer<float> MaxMineralAmount
Field Value
| Type | Description |
|---|---|
| NativeListDataLayer<float> |
MinMineralAmount
List of min values per each type of mineral in cell. Technically this does not restrict the actual amount of minerals in a cell, but it can be used for visualization purposes (e.g. to calculate the transparency of the mineral color in the color map, where MinMineralsAmount means fully transparent and MaxMineralsAmount means fully opaque). Index = mineral id, value = max amount for that mineral in a cell.
Declaration
public NativeListDataLayer<float> MinMineralAmount
Field Value
| Type | Description |
|---|---|
| NativeListDataLayer<float> |
MineralIndexMap
Map of mineral indices, where the value of each cell is an index representing the type of mineral present in that cell.
Declaration
public ColorMapCellValueDataLayer_UInt MineralIndexMap
Field Value
| Type | Description |
|---|---|
| ColorMapCellValueDataLayer_UInt |
Methods
CalculateColorMap(JobHandle)
Schedules the calculation of the color map, ensuring it is executed after the specified job dependency completes.
Declaration
public override 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. |
Overrides
CalculateMineralsColorMap(JobHandle)
Calculates the color map for the minerals layer (minerals color with transparency related to mineral amount), which can be used for visualization purposes.
Declaration
protected virtual JobHandle CalculateMineralsColorMap(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency |
Returns
| Type | Description |
|---|---|
| JobHandle |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException |
Cleanup()
Every frame there is a cleanup stage. This function is called. Usually used to clean the dirty flags.
Declaration
public override void Cleanup()
Overrides
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 override JobHandle CleanupAsync(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency |
Returns
| Type | Description |
|---|---|
| JobHandle |
Overrides
Dispose()
Disposes all allocated native memory.
Declaration
public override void Dispose()
Overrides
GetMineralIndex(int)
Returns the index of the mineral in the specified cell, or null if there is no mineral index map or if the cell index is out of range.
Declaration
public uint? GetMineralIndex(int cellIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | cell index to get a value from |
Returns
| Type | Description |
|---|---|
| uint? | the mineral index from the specified cell or null if there is no such cell |
GetMineralsAmount(int)
Returns the amount of minerals in the specified cell, or null if there is no minerals amount map or if the cell index is out of range.
Declaration
public float? GetMineralsAmount(int cellIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | cell index to get a value from |
Returns
| Type | Description |
|---|---|
| float? | the minerals amount in the specified cell or null if there is no such cell |
Init(HexTerrainSettings)
Initializes/Reinitializes the area data.
Declaration
public override void Init(HexTerrainSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | new terrain settings |
Overrides
Init<TInitArgs>(HexTerrainSettings, TInitArgs)
Initializes the terrain system using the specified settings and initialization arguments.
Declaration
public override 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. |
Overrides
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 override void SetAllDirty(bool isDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isDirty |
Overrides
SetMineralIndex(int, uint)
Sets the mineral index for the specified cell in the mineral index map.
Declaration
public bool SetMineralIndex(int cellIndex, uint mineralIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | The zero-based index of the cell whose mineral index is to be set. Must be within the bounds of the mineral index map. |
| uint | mineralIndex | The mineral index value to assign to the specified cell. This value should correspond to a valid mineral type. |
Returns
| Type | Description |
|---|---|
| bool | true if the mineral index was successfully set; otherwise, false if the mineral index map is not initialized. |
Remarks
This method does not modify the mineral index map if it has not been initialized.
SetMineralsAmount(int, float)
Sets the amount of minerals for the specified cell index.
Declaration
public bool SetMineralsAmount(int cellIndex, float mineralsAmount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | The zero-based index of the cell whose minerals amount is to be set. Must be within the valid range of the minerals amount map. |
| float | mineralsAmount | The amount of minerals to assign to the specified cell. This value must be non-negative. |
Returns
| Type | Description |
|---|---|
| bool | true if the minerals amount was successfully set; otherwise, false if the minerals amount map is not initialized. |