Class ChunkData
Represents a chunk of the grid, containing heights and materials for each tile.
Inherited Members
Namespace: TerraProc.Core.Terrain
Assembly: TerraProc.Core.dll
Syntax
public sealed class ChunkData
Properties
| Edit this page View SourceByteSize
Size of the chunk data in bytes in memory.
Declaration
public int ByteSize { get; }
Property Value
| Type | Description |
|---|---|
| int | Size in bytes. |
Heights
Read-only span of heights in the chunk.
Declaration
public ReadOnlySpan<Height> Heights { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<Height> |
HeightsMemory
Read-only memory of heights in the chunk.
Declaration
public ReadOnlyMemory<Height> HeightsMemory { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyMemory<Height> |
this[int, int]
Get the Tile by the local coordinates within the chunk.
Declaration
public Tile this[int x, int y] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Local X coordinate within the chunk (0 to ChunkSize-1) |
| int | y | Local Y coordinate within the chunk (0 to ChunkSize-1) |
Property Value
| Type | Description |
|---|---|
| Tile |
this[TileCoords]
Get the Tile by the global tile coordinates.
Declaration
public Tile this[TileCoords coords] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| TileCoords | coords | Global tile coordinates. |
Property Value
| Type | Description |
|---|---|
| Tile |
Materials
Read-only span of materials in the chunk.
Declaration
public ReadOnlySpan<Material> Materials { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<Material> |
MaterialsMemory
Read-only memory of materials in the chunk.
Declaration
public ReadOnlyMemory<Material> MaterialsMemory { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyMemory<Material> |
TileCount
Number of tiles in the chunk (should be equal to ChunkTileCount).
Declaration
public int TileCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceFromOwned(Height[], Material[])
Create a chunk from owned arrays of heights and materials. Caller promises that they will not be modified after being passed to this method. Arrays must be of length ChunkTileCount.
Declaration
public static ChunkData FromOwned(Height[] heights, Material[] materials)
Parameters
| Type | Name | Description |
|---|---|---|
| Height[] | heights | |
| Material[] | materials |
Returns
| Type | Description |
|---|---|
| ChunkData | Created chunk. |
FromSpan(ReadOnlySpan<Height>, ReadOnlySpan<Material>)
Create a chunk from spans of heights and materials. Spans will be copied into new arrays. Arrays must be of length ChunkTileCount.
Declaration
public static ChunkData FromSpan(ReadOnlySpan<Height> heights, ReadOnlySpan<Material> materials)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Height> | heights | |
| ReadOnlySpan<Material> | materials |
Returns
| Type | Description |
|---|---|
| ChunkData | Created chunk. |
Zero()
Create a chunk with all heights set to zero and all materials set to Void.
Declaration
public static ChunkData Zero()
Returns
| Type | Description |
|---|---|
| ChunkData | Created chunk. |