Table of Contents

Class Chunk

Namespace
TileWorld.Engine.World.Chunks
Assembly
TileWorld.Engine.dll

Stores cell data and runtime state for a single chunk.

public sealed class Chunk
Inheritance
Chunk
Inherited Members

Constructors

Chunk(ChunkCoord)

Creates a chunk with a fresh cell buffer at the supplied coordinate.

public Chunk(ChunkCoord coord)

Parameters

coord ChunkCoord

The chunk coordinate.

Chunk(ChunkCoord, ChunkCellStorage)

Creates a chunk with an explicit cell buffer.

public Chunk(ChunkCoord coord, ChunkCellStorage cellStorage)

Parameters

coord ChunkCoord

The chunk coordinate.

cellStorage ChunkCellStorage

The cell storage backing the chunk.

Properties

CellStorage

Gets the cell storage backing this chunk.

public ChunkCellStorage CellStorage { get; }

Property Value

ChunkCellStorage

Coord

Gets the coordinate of the chunk.

public ChunkCoord Coord { get; }

Property Value

ChunkCoord

DirtyFlags

Gets or sets the dirty flags currently applied to the chunk.

public ChunkDirtyFlags DirtyFlags { get; set; }

Property Value

ChunkDirtyFlags

State

Gets or sets the chunk lifecycle state.

public ChunkState State { get; set; }

Property Value

ChunkState

Methods

GetCell(int, int)

Reads a cell from local chunk coordinates.

public TileCell GetCell(int localX, int localY)

Parameters

localX int

The local X coordinate.

localY int

The local Y coordinate.

Returns

TileCell

The resolved cell value.

IsInside(int, int)

Returns whether the supplied local coordinate lies inside the chunk.

public bool IsInside(int localX, int localY)

Parameters

localX int

The local X coordinate.

localY int

The local Y coordinate.

Returns

bool

true when the coordinate is inside the chunk.

SetCell(int, int, TileCell)

Writes a cell to local chunk coordinates.

public void SetCell(int localX, int localY, TileCell cell)

Parameters

localX int

The local X coordinate.

localY int

The local Y coordinate.

cell TileCell

The cell value to store.

ToIndex(int, int)

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

public int ToIndex(int localX, int localY)

Parameters

localX int

The local X coordinate.

localY int

The local Y coordinate.

Returns

int

The row-major index into the chunk cell buffer.