Table of Contents

Class WorldCoordinateConverter

Namespace
TileWorld.Engine.World.Coordinates
Assembly
TileWorld.Engine.dll

Converts between world-tile, chunk, and local chunk coordinate systems.

public static class WorldCoordinateConverter
Inheritance
WorldCoordinateConverter
Inherited Members

Methods

IsInsideLocal(int, int)

Returns whether the supplied local chunk coordinate lies inside the fixed chunk bounds.

public static bool IsInsideLocal(int localX, int localY)

Parameters

localX int

The local chunk X coordinate.

localY int

The local chunk Y coordinate.

Returns

bool

true when the coordinate is inside the chunk.

ToChunkCoord(WorldTileCoord)

Converts a world-tile coordinate into the containing chunk coordinate using floor semantics for negative values.

public static ChunkCoord ToChunkCoord(WorldTileCoord coord)

Parameters

coord WorldTileCoord

The world-tile coordinate to convert.

Returns

ChunkCoord

The containing chunk coordinate.

ToChunkOrigin(ChunkCoord)

Converts a chunk coordinate into the world-tile origin of that chunk.

public static WorldTileCoord ToChunkOrigin(ChunkCoord coord)

Parameters

coord ChunkCoord

The chunk coordinate to convert.

Returns

WorldTileCoord

The world-tile origin of the chunk.

ToIndex(int, int)

Converts local chunk coordinates into a row-major cell index.

public static int ToIndex(int localX, int localY)

Parameters

localX int

The local chunk X coordinate.

localY int

The local chunk Y coordinate.

Returns

int

The row-major index into a chunk cell buffer.

Exceptions

ArgumentOutOfRangeException

Thrown when the supplied local coordinate is outside chunk bounds.

ToLocalCoord(WorldTileCoord)

Converts a world-tile coordinate into its local coordinate inside the containing chunk.

public static Int2 ToLocalCoord(WorldTileCoord coord)

Parameters

coord WorldTileCoord

The world-tile coordinate to convert.

Returns

Int2

The local chunk-space coordinate.