Hex Terrains Framework
Search Results for

    Show / Hide Table of Contents

    Struct HexTerrainSettings

    Struct for storing hex terrain settings like TerrainSize, ChunkSize, HexRotation, HexLayout, etc. Has methods for converting between pixel and cell coordinates, getting cell index by coordinates, etc.

    Implements
    IEquatable<HexTerrainSettings>
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Fwt.HexTerrains.Data
    Assembly: fwt.hexterrains.dll
    Syntax
    [BurstCompile]
    [Serializable]
    public struct HexTerrainSettings : IEquatable<HexTerrainSettings>

    Fields

    ChunkSize

    Size of the chunk in cells (usually it's 16x16, because the chunk has one mesh and the amount of vertexes must be under 64000)

    Declaration
    public int2 ChunkSize
    Field Value
    Type Description
    int2

    HexHeight

    Height of the hexagon in world space. Cell Height is a byte value that is multiplied by this value to get the height of the cell in world space.

    Declaration
    public float HexHeight
    Field Value
    Type Description
    float

    HexLayout

    HexLayout of the hexagon the terrain is composed of.

    Declaration
    public HexLayouts HexLayout
    Field Value
    Type Description
    HexLayouts

    HexRadius

    Radius of the hexagon in world space. The half of the distance between two opposite corners of the hexagon.

    Declaration
    public float HexRadius
    Field Value
    Type Description
    float

    HexRotation

    HexRotation of the hexagon the terrain is composed of.

    Declaration
    public HexRotations HexRotation
    Field Value
    Type Description
    HexRotations

    IsConnectedHorizontally

    If true, the top and bottom edges of the terrain are seamlessly connected

    Declaration
    public bool IsConnectedHorizontally
    Field Value
    Type Description
    bool

    IsConnectedVertically

    If true, the right and left edges of the terrain are seamlessly connected

    Declaration
    public bool IsConnectedVertically
    Field Value
    Type Description
    bool

    TerrainSize

    Size of the terrain in cells (width and height).

    Declaration
    public int2 TerrainSize
    Field Value
    Type Description
    int2

    Properties

    CellsCount

    Total mount of cells on terrain.

    Declaration
    public int CellsCount { get; }
    Property Value
    Type Description
    int

    ChunksCount

    Total number of chunks in the terrain

    Declaration
    public int ChunksCount { get; }
    Property Value
    Type Description
    int

    ChunksGridSize

    Size of the chunks grid (one item = one chunk)

    Declaration
    public int2 ChunksGridSize { get; }
    Property Value
    Type Description
    int2

    Default

    returns a default HexTerrainSettings

    Declaration
    public static HexTerrainSettings Default { get; }
    Property Value
    Type Description
    HexTerrainSettings

    TerrainAreaSize

    Size of the rectangle area that the whole terrain occupies in world space.

    Declaration
    public float2 TerrainAreaSize { get; }
    Property Value
    Type Description
    float2

    Methods

    CellIndexToPixel(int)

    Calculates a cell coordinate by cell index, then converts a cell coord to the world point (assuming the terrain origin is 0:0:0). Clamps the coordinate to the terrain size, meaning takes into account if terrain's edges are connected or not

    Declaration
    [BurstCompile]
    public float3 CellIndexToPixel(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex
    Returns
    Type Description
    float3

    ClampCellIndex(int)

    Clamps the cell index to the terrain size. Takes into account if Terrain's edges are connected or not.

    Declaration
    [BurstCompile]
    public int ClampCellIndex(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex

    Raw cell index (can be outside of terrain)

    Returns
    Type Description
    int

    clamped cell index

    ClampCoordinate(int2)

    Takes a cell coordinate and wraps it around the terrain size taking into account if terrain's edges are connected or not. So if IsConnectedHorizontally is true, the x coordinate will be wrapped around the terrain's width, If IsConnectedVertically is true, the y coordinate will be wrapped around the terrain's height. Negative cell coordinates are also wrapped around.

    Declaration
    [BurstCompile]
    public int2 ClampCoordinate(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord

    raw cell coordinate

    Returns
    Type Description
    int2

    clamped cell coordinate

    CoordToPixel(int2)

    Converts a cell coordinate to the world point (assuming the terrain origin is 0:0:0). Clamps the coordinate to the terrain size, meaning takes into account if terrain's edges are connected or not ClampCoordinate(int2)

    Declaration
    [BurstCompile]
    public float3 CoordToPixel(int2 coord)
    Parameters
    Type Name Description
    int2 coord

    cell coordinate

    Returns
    Type Description
    float3

    world point

    CoordToPixelRaw(int2)

    Converts a cell coordinate to the world point (assuming the terrain origin is 0:0:0).

    Declaration
    [BurstCompile]
    public float3 CoordToPixelRaw(int2 coord)
    Parameters
    Type Name Description
    int2 coord

    cell coordinate

    Returns
    Type Description
    float3

    world point

    Equals(HexTerrainSettings)

    Declaration
    public bool Equals(HexTerrainSettings other)
    Parameters
    Type Name Description
    HexTerrainSettings other
    Returns
    Type Description
    bool

    GetCellCoord(int)

    Converts a cell index into a cell coordinate

    Declaration
    [BurstCompile]
    public int2 GetCellCoord(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex
    Returns
    Type Description
    int2

    GetCellHeightInMeters(byte)

    Calculates a cell height in meters from the heightmap value

    Declaration
    [BurstCompile]
    public float GetCellHeightInMeters(byte cellHeight)
    Parameters
    Type Name Description
    byte cellHeight

    heightmap value of the cell

    Returns
    Type Description
    float

    cell height in meters

    GetCellIndex(int2)

    Converts a cell coordinate to the cell index. Takes into account if terrain's edges are connected or not

    Declaration
    [BurstCompile]
    public int GetCellIndex(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord

    cell coordinate

    Returns
    Type Description
    int

    cell index

    GetCellIndexRaw(int2)

    Converts a cell coordinate to the cell index. Does NOT take into account if terrain's edges are connected or not

    Declaration
    [BurstCompile]
    public int GetCellIndexRaw(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord

    cell coordinate

    Returns
    Type Description
    int

    cell index

    GetChunkCoord(int)

    Converts a chunk index into a chunk coordinate (in chunks grid, not cells grid)

    Declaration
    [BurstCompile]
    public int2 GetChunkCoord(int chunkIndex)
    Parameters
    Type Name Description
    int chunkIndex

    chunk index

    Returns
    Type Description
    int2

    chunk coordinate in a chunks grid

    GetChunkCoordByCellCoord(int2)

    Returns chunk coordinate (in chunks grid) by cell coordinate (in cells grid)

    Declaration
    [BurstCompile]
    public int2 GetChunkCoordByCellCoord(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord
    Returns
    Type Description
    int2

    GetChunkCoordByCellCoordRaw(int2)

    Returns chunk coordinate for cell with a giving coord

    Declaration
    [BurstCompile]
    public int2 GetChunkCoordByCellCoordRaw(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord
    Returns
    Type Description
    int2

    GetChunkIndex(int2)

    Returns a chunk index of giving chunk coordinate (in chunks grid, not cells grid)

    Declaration
    [BurstCompile]
    public int GetChunkIndex(int2 chunkCoord)
    Parameters
    Type Name Description
    int2 chunkCoord

    chunk coordinate in a chunks grid

    Returns
    Type Description
    int

    chunk index

    GetChunkIndexByCellCoord(int2)

    Returns a chunk index for cell at provided cell coordinate (not chunk coordinate)

    Declaration
    [BurstCompile]
    public int GetChunkIndexByCellCoord(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord
    Returns
    Type Description
    int

    GetChunkIndexByCellCoordRaw(int2)

    Returns a chunk index for cell with a giving coordinate

    Declaration
    [BurstCompile]
    public int GetChunkIndexByCellCoordRaw(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord
    Returns
    Type Description
    int

    GetChunkIndexByCellIndex(int)

    Returns a chunk index for giving cell index

    Declaration
    [BurstCompile]
    public int GetChunkIndexByCellIndex(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex
    Returns
    Type Description
    int

    IsCellInsideTheTerrain(int)

    Checks if the cell index is inside the terrain. Takes into account if terrain's edges are connected or not

    Declaration
    [BurstCompile]
    public bool IsCellInsideTheTerrain(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex
    Returns
    Type Description
    bool

    IsCellInsideTheTerrain(int2)

    Checks if the cell coordinate is inside the terrain. Takes into account if terrain's edges are connected or not

    Declaration
    [BurstCompile]
    public bool IsCellInsideTheTerrain(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord
    Returns
    Type Description
    bool

    PixelToCoord(float2)

    Converts a world point to a cell coordinate (assuming the terrain origin is 0:0:0).

    Declaration
    [BurstCompile]
    public int2 PixelToCoord(float2 pixel)
    Parameters
    Type Name Description
    float2 pixel

    world point

    Returns
    Type Description
    int2

    cell coordinate

    PixelToCoordRaw(float2)

    Converts a world 2D point (without height) to a cell coordinate (assuming the terrain origin is 0:0:0).

    Declaration
    [BurstCompile]
    public int2 PixelToCoordRaw(float2 pixel)
    Parameters
    Type Name Description
    float2 pixel

    world point

    Returns
    Type Description
    int2

    cell coordinate

    PixelToCoordRaw(float3)

    Converts a world point to a cell coordinate (assuming the terrain origin is 0:0:0).

    Declaration
    [BurstCompile]
    public int2 PixelToCoordRaw(float3 pixel)
    Parameters
    Type Name Description
    float3 pixel

    world point

    Returns
    Type Description
    int2

    cell coordinate

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    Implements

    IEquatable<T>

    Extension Methods

    HashExtensions.GetHashCode_ValueType<TValue>(TValue, int)
    HashExtensions.GetHashCode_ValueType<TValue>(TValue, int)
    Extensions_UnityObject.SmartDestroy(object)
    Extensions_UnityObject.SmartDestroy(object)
    Extensions_UnityObject.SmartGetComponent<TComponent>(object)
    Extensions_UnityObject.SmartGetComponent<TComponent>(object)
    Extensions_UnityObject.SmartGetGameGameObject(object)
    Extensions_UnityObject.SmartGetGameGameObject(object)
    In this article
    Back to top Generated by DocFX