Show / Hide Table of Contents

Struct TileCoords

Represents the coordinates of a tile within the grid.

Implements
IEquatable<TileCoords>
Inherited Members
ValueType.Equals(object)
ValueType.GetHashCode()
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: TerraProc.Core.Terrain
Assembly: TerraProc.Core.dll
Syntax
public readonly record struct TileCoords : IEquatable<TileCoords>

Constructors

| Edit this page View Source

TileCoords(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 Source

X

X coordinate of the tile.

Declaration
public int X { get; init; }
Property Value
Type Description
int
| Edit this page View Source

Y

Y coordinate of the tile.

Declaration
public int Y { get; init; }
Property Value
Type Description
int

Methods

| Edit this page View Source

Deconstruct(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

ToString()

String representation of the tile coordinates.

Declaration
public override string ToString()
Returns
Type Description
string

String in the format "TileCoords(X, Y)".

Overrides
ValueType.ToString()

Operators

| Edit this page View Source

operator +(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

Implements

IEquatable<T>
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX