You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
557 B
21 lines
557 B
[Tool] |
|
[GlobalClass] |
|
public partial class TerrainData |
|
: Resource |
|
{ |
|
[Export] public Godot.Collections.Dictionary<Vector2I, TerrainChunk> Chunks { get; set; } = []; |
|
|
|
public ref Tile this[TilePos pos] { get { |
|
var chunkPos = TerrainChunk.ToChunkPos(pos); |
|
if (!Chunks.TryGetValue(chunkPos, out var chunk)) |
|
Chunks.Add(chunkPos, chunk = new()); |
|
return ref chunk[pos]; |
|
} } |
|
|
|
public Tile GetTileOrDefault(TilePos pos) |
|
{ |
|
var chunkPos = TerrainChunk.ToChunkPos(pos); |
|
return Chunks.TryGetValue(chunkPos, out var chunk) |
|
? chunk[pos] : default; |
|
} |
|
}
|
|
|