Schedule features from mutable regions

This commit is contained in:
Daniar Mannanov 2026-08-11 13:23:45 +03:00
parent 4ff62d7c96
commit d01e576dcc
2 changed files with 72 additions and 5 deletions

View file

@ -128,6 +128,28 @@ func (r *decorationRegion) sourceBiomes() []string {
return names
}
func (r *decorationRegion) scheduledFeatures(stage int) ([]worldgen.ScheduledFeature, error) {
set, err := worldgen.LoadFeatureSet()
if err != nil {
return nil, err
}
if err := r.ensureSourceNeighborhood(); err != nil {
return nil, err
}
return set.FeatureSchedule(possibleBiomeOrder(), r.sourceBiomes(), stage)
}
func (r *decorationRegion) ensureSourceNeighborhood() error {
for cx := r.sourceX - 1; cx <= r.sourceX+1; cx++ {
for cz := r.sourceZ - 1; cz <= r.sourceZ+1; cz++ {
if _, ok := r.chunks[[2]int32{cx, cz}]; !ok {
return fmt.Errorf("world: source biome neighborhood missing (%d,%d)", cx, cz)
}
}
}
return nil
}
func (r *decorationRegion) placementContext(biomeAllows func(worldgen.FeaturePosition) bool) worldgen.PlacementContext {
set, err := worldgen.LoadFeatureSet()
if err != nil {