2015-11-30 15:30:49 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Mapping
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represent a column of chunks of terrain in a Minecraft world
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class ChunkColumn
|
|
|
|
|
|
{
|
2022-07-23 22:34:16 +08:00
|
|
|
|
public int ColumnSize;
|
2015-11-30 15:30:49 +01:00
|
|
|
|
|
2022-07-25 03:19:24 +08:00
|
|
|
|
public bool FullyLoaded = false;
|
|
|
|
|
|
|
2015-11-30 15:30:49 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Blocks contained into the chunk
|
|
|
|
|
|
/// </summary>
|
2022-08-25 10:40:55 +08:00
|
|
|
|
private readonly Chunk?[] chunks;
|
2015-11-30 15:30:49 +01:00
|
|
|
|
|
2022-07-23 22:34:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new ChunkColumn
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ChunkColumn(int size = 16)
|
|
|
|
|
|
{
|
|
|
|
|
|
ColumnSize = size;
|
2022-08-25 10:40:55 +08:00
|
|
|
|
chunks = new Chunk?[size];
|
2022-07-23 22:34:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-11-30 15:30:49 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get or set the specified chunk column
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="chunkX">ChunkColumn X</param>
|
|
|
|
|
|
/// <param name="chunkY">ChunkColumn Y</param>
|
|
|
|
|
|
/// <returns>chunk at the given location</returns>
|
2022-08-25 10:40:55 +08:00
|
|
|
|
public Chunk? this[int chunkY]
|
2015-11-30 15:30:49 +01:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2022-08-25 01:34:07 +08:00
|
|
|
|
return chunks[chunkY];
|
2015-11-30 15:30:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2022-08-25 01:34:07 +08:00
|
|
|
|
chunks[chunkY] = value;
|
2015-11-30 15:30:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get chunk at the specified location
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="location">Location, a modulo will be applied</param>
|
|
|
|
|
|
/// <returns>The chunk, or null if not loaded</returns>
|
2022-08-24 18:16:16 +08:00
|
|
|
|
public Chunk? GetChunk(Location location)
|
2015-11-30 15:30:49 +01:00
|
|
|
|
{
|
2016-07-22 23:47:32 +02:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
return this[location.ChunkY];
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (IndexOutOfRangeException)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2015-11-30 15:30:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|