Add terrain biomes jumping and extensible gathering professions

This commit is contained in:
dingo
2026-09-08 21:54:23 -04:00
parent 141cb9e6b2
commit df7b245ca7
34 changed files with 1895 additions and 184 deletions
+10 -6
View File
@@ -10,20 +10,24 @@ import (
"github.com/ojrac/opensimplex-go"
)
const GeneratorVersion = 1
const GeneratorVersion = 2
type Terrain struct {
Seed int64
B content.Balance
noise opensimplex.Noise
Version int
Seed int64
B content.Balance
noise opensimplex.Noise
}
func NewTerrain(seed int64, b content.Balance) *Terrain {
return &Terrain{seed, b, opensimplex.New(seed)}
return &Terrain{Version: GeneratorVersion, Seed: seed, B: b, noise: opensimplex.New(seed)}
}
func (t *Terrain) rawHeight(x, z float64) float64 {
// A low, flat arrival clearing blends into broad hills and fine detail.
d := math.Min(1, math.Hypot(x, z)/55)
if t.Version >= 2 {
return (t.noise.Eval2(x/220, z/220)*t.B.GatheringRules.HillHeight + t.noise.Eval2(x/55, z/55)*t.B.GatheringRules.DetailHeight) * d
}
return (t.noise.Eval2(x/220, z/220)*17 + t.noise.Eval2(x/55, z/55)*3) * d
}
func ChunkCoord(v, size float64) int { return int(math.Floor(v / size)) }
@@ -42,7 +46,7 @@ func (t *Terrain) Height(x, z float64) float64 {
return d + (c-d)*(1-fx) + (b-d)*(1-fz)
}
func (t *Terrain) Position(x, z float64) p.Vec3 { return p.Vec3{X: x, Y: t.Height(x, z), Z: z} }
func (t *Terrain) Chunk(x, z int) p.Chunk {
func (t *Terrain) legacyChunk(x, z int) p.Chunk {
c := p.Chunk{Key: Key(x, z), X: int64(x), Z: int64(z), Size: t.B.ChunkSize, Resolution: int64(t.B.TerrainResolution), Biome: "highlands", Heights: []float64{}, Resources: []p.Entity{}}
for iz := 0; iz <= t.B.TerrainResolution; iz++ {
for ix := 0; ix <= t.B.TerrainResolution; ix++ {