Struct TileCoords
Represents the coordinates of a tile within the grid.
Implements
Inherited Members
Namespace: TerraProc.Core.Terrain
Assembly: TerraProc.Core.dll
Syntax
public readonly record struct TileCoords : IEquatable<TileCoords>
Constructors
| Edit this page View SourceTileCoords(int, int)
Represents the coordinates of a tile within the grid.
Declaration
public TileCoords(int X, int Y)
Parameters
| Type | Name | Description |
|---|---|---|
| int | X | X coordinate of the tile. |
| int | Y | Y coordinate of the tile. |
Properties
| Edit this page View SourceX
X coordinate of the tile.
Declaration
public int X { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Y
Y coordinate of the tile.
Declaration
public int Y { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceDeconstruct(out int, out int)
Deconstructs the tile coordinates into individual X and Y components.
Declaration
public void Deconstruct(out int x, out int y)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | X coordinate. |
| int | y | Y coordinate. |
ToChunkCoords()
Converts the global tile coordinates to chunk coordinates by dividing by ChunkSize, discarding the local (within-chunk) offset.
Declaration
public ChunkCoords ToChunkCoords()
Returns
| Type | Description |
|---|---|
| ChunkCoords | Corresponding chunk coordinates. |
ToLocal()
Converts the global tile coordinates to local chunk coordinates by taking the modulus with ChunkSize, discarding the chunk offset.
Declaration
public TileCoords ToLocal()
Returns
| Type | Description |
|---|---|
| TileCoords | Local tile coordinates within the chunk. |
ToLocalAndChunk()
Separate the tile coordinates into local tile and chunk components. Uses ChunkSize to determine the chunk size.
Declaration
public (TileCoords, ChunkCoords) ToLocalAndChunk()
Returns
| Type | Description |
|---|---|
| (TileCoords, ChunkCoords) | Tuple containing the local tile coordinates and the chunk coordinates. |
ToString()
String representation of the tile coordinates.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | String in the format "TileCoords(X, Y)". |
Overrides
Operators
| Edit this page View Sourceoperator +(TileCoords, TileCoords)
Addition operator for tile coordinates.
Declaration
public static TileCoords operator +(TileCoords a, TileCoords b)
Parameters
| Type | Name | Description |
|---|---|---|
| TileCoords | a | First operand. |
| TileCoords | b | Second operand. |
Returns
| Type | Description |
|---|---|
| TileCoords | Sum of the two tile coordinates. |
explicit operator TileCoords((int x, int y))
Explicit conversion from tuple.
Declaration
public static explicit operator TileCoords((int x, int y) tuple)
Parameters
| Type | Name | Description |
|---|---|---|
| (int x, int y) | tuple | Tuple containing the X and Y coordinates. |
Returns
| Type | Description |
|---|---|
| TileCoords | Tile coordinates. |
implicit operator (int x, int y)(TileCoords)
Implicit conversion to tuple.
Declaration
public static implicit operator (int x, int y)(TileCoords tc)
Parameters
| Type | Name | Description |
|---|---|---|
| TileCoords | tc | Tile coordinates. |
Returns
| Type | Description |
|---|---|
| (int x, int y) | Tuple containing the X and Y coordinates. |
operator -(TileCoords, TileCoords)
Subtraction operator for tile coordinates.
Declaration
public static TileCoords operator -(TileCoords a, TileCoords b)
Parameters
| Type | Name | Description |
|---|---|---|
| TileCoords | a | First operand. |
| TileCoords | b | Second operand. |
Returns
| Type | Description |
|---|---|
| TileCoords | Difference of the two tile coordinates. |