Struct TerrainGrid
The terrain grid class is responsible for containing the LandTile data in a flattened 2D array.
Namespace: TycoonTerrain.Core
Assembly: TycoonTerrainAssembly.dll
Syntax
public struct TerrainGrid
Fields
Length
The grid length.
Declaration
public int Length
Field Value
Type | Description |
---|---|
Int32 | The number of tiles in the |
MaxHeight
Gets the maximum tile height.
Declaration
public byte MaxHeight
Field Value
Type | Description |
---|---|
Byte | The maximum tile height. |
WaterHeightStepsPerTileHeight
The water height steps per tile height.
Declaration
public int WaterHeightStepsPerTileHeight
Field Value
Type | Description |
---|---|
Int32 | The number of water levels that can be within a single tile height step. |
Width
The grid width.
Declaration
public int Width
Field Value
Type | Description |
---|---|
Int32 | The number of tiles in the |
Properties
Bounds
Gets the grid bounds.
Declaration
public IntBound Bounds { get; }
Property Value
Type | Description |
---|---|
IntBound | The grid bounds. |
MinHeight
Gets the minimum tile height.
Declaration
public byte MinHeight { get; }
Property Value
Type | Description |
---|---|
Byte | The minimum tile height. |
Methods
GetTile(Int32, Int32)
Gets the tile handle for a given tile position.
Declaration
public TileHandle GetTile(int x, int z)
Parameters
Type | Name | Description |
---|---|---|
Int32 | x | |
Int32 | z |
Returns
Type | Description |
---|---|
TileHandle | A TileHandle instance that refers to the tile at ( |
GetTile(int2)
Gets a handle to the tile at tilePosition
Declaration
public TileHandle GetTile(int2 tilePosition)
Parameters
Type | Name | Description |
---|---|---|
Unity.Mathematics.int2 | tilePosition | The tile position. |
Returns
Type | Description |
---|---|
TileHandle | The tile handle that points to the tile at |
GetTilesIn(IntBound)
Gets a TileHandle instance for every tile within the specified bounds.
Declaration
public IEnumerable<TileHandle> GetTilesIn(IntBound bounds)
Parameters
Type | Name | Description |
---|---|---|
IntBound | bounds | The bounds. |
Returns
Type | Description |
---|---|
IEnumerable<TileHandle> | An enumerable of TileHandle instances that each refers to a tile within |
GetTilesInDonut(int2, Single, Single)
Gets a TileHandle instance for every tile that lies in a donut shape, given the centerPosition
, innerRadius
and outerRadius
.
Declaration
public IEnumerable<TileHandle> GetTilesInDonut(int2 centerPosition, float innerRadius, float outerRadius)
Parameters
Type | Name | Description |
---|---|---|
Unity.Mathematics.int2 | centerPosition | The center position. |
Single | innerRadius | The inner radius. |
Single | outerRadius | The outer radius. |
Returns
Type | Description |
---|---|
IEnumerable<TileHandle> | A TileHandle instance for every tile that lies in a donut shape, given the |
GetTilesInRadius(int2, Single)
Gets a TileHandle instance for every tile that lies within the radius
of the centerPosition
.
Declaration
public IEnumerable<TileHandle> GetTilesInRadius(int2 centerPosition, float radius)
Parameters
Type | Name | Description |
---|---|---|
Unity.Mathematics.int2 | centerPosition | The center position. |
Single | radius | The radius. |
Returns
Type | Description |
---|---|
IEnumerable<TileHandle> | A TileHandle instance for every tile that lies within the |
IntersectBound(IntBound)
Gets the intersection of the given tile bounds with the grid bounds.
Declaration
public IntBound IntersectBound(IntBound bounds)
Parameters
Type | Name | Description |
---|---|---|
IntBound | bounds | The tile bounds. |
Returns
Type | Description |
---|---|
IntBound | A IntBound instance that represents the intersection of |
IsFlatInBounds(IntBound)
Checks whether the tiles within the given bounds are all flat and at the same height.
Declaration
public bool IsFlatInBounds(IntBound bounds)
Parameters
Type | Name | Description |
---|---|---|
IntBound | bounds | The tile bounds. |
Returns
Type | Description |
---|---|
Boolean |
|
IsInBounds(int2)
Check if a certain position is within the map bounds.
Declaration
public bool IsInBounds(int2 tilePosition)
Parameters
Type | Name | Description |
---|---|---|
Unity.Mathematics.int2 | tilePosition | The tile position. |
Returns
Type | Description |
---|---|
Boolean |
|
ResetData()
Resets all tile data to a flat surface at half the height limit.
Declaration
public void ResetData()