mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-18 01:06:47 +01:00
31 lines
1.0 KiB
GDScript
31 lines
1.0 KiB
GDScript
tool
|
|
extends TerramanLevelGenerator
|
|
|
|
var lseed = 0
|
|
|
|
func setup(world : TerraWorld, level_seed : int, spawn_mobs : bool, library: TerramanLibrary) -> void:
|
|
lseed = level_seed
|
|
|
|
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()
|
|
s.seed = lseed
|
|
|
|
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)
|
|
val *= val
|
|
val *= 20.0
|
|
|
|
chunk.set_voxel(val, x, z, TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
|
|
|
if val < 50:
|
|
chunk.set_voxel(2, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE)
|
|
elif val > 70:
|
|
chunk.set_voxel(4, x, z, TerraChunkDefault.DEFAULT_CHANNEL_TYPE)
|