20 lines
587 B
C#
20 lines
587 B
C#
namespace VoxelEngine.World;
|
|
|
|
public sealed class Chunk
|
|
{
|
|
public const int Size = 16;
|
|
|
|
private readonly ushort[] _ids = new ushort[Chunk.Size * Chunk.Size * Chunk.Size];
|
|
|
|
public ushort this[int x, int y, int z]
|
|
{
|
|
get => this._ids[Chunk.Index(x, y, z)];
|
|
set => this._ids[Chunk.Index(x, y, z)] = value;
|
|
}
|
|
|
|
public static bool InBounds(int x, int y, int z) =>
|
|
x is >= 0 and < Chunk.Size && y is >= 0 and < Chunk.Size && z is >= 0 and < Chunk.Size;
|
|
|
|
private static int Index(int x, int y, int z) => (x * Chunk.Size + y) * Chunk.Size + z;
|
|
}
|