mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
24 lines
863 B
GDScript
24 lines
863 B
GDScript
tool
|
|
extends TerramanLevelGenerator
|
|
|
|
|
|
func _generate_chunk(chunk: TerraChunk) -> void:
|
|
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
|
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)
|
|
|
|
var s : OpenSimplexNoise = OpenSimplexNoise.new()
|
|
|
|
for x in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
|
for z in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
|
var vx : int = x + (chunk.position_x * chunk.size_x)
|
|
var vz : int = z + (chunk.position_z * chunk.size_z)
|
|
|
|
var val : float = (s.get_noise_2d(vx, vz) + 2) * 20.0
|
|
|
|
chunk.set_voxel(val, x, z, TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
|
|
|
if val < 33:
|
|
chunk.set_voxel(2, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE)
|
|
elif val > 42:
|
|
chunk.set_voxel(4, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE)
|