World gen stuff
This commit is contained in:
@@ -109,6 +109,8 @@ export type SurfaceConditionJson =
|
||||
| { type: "bare_cliffs" }
|
||||
// at or above where a density function says
|
||||
| { type: "y_at_least"; function: DensityJson }
|
||||
// where a density function is in a range
|
||||
| ({ type: "density"; function: DensityJson } & RangeJson)
|
||||
| { type: "biome"; biome_is: string[] }
|
||||
| { type: "not"; invert: SurfaceConditionJson };
|
||||
|
||||
@@ -283,6 +285,10 @@ const surface_condition: z.ZodType<SurfaceConditionJson> = z.lazy(() =>
|
||||
z.object({ type: z.literal(["filler_depth", "surface_underwater", "steep", "bare_cliffs"]) }),
|
||||
z.object({ type: z.literal("above_preliminary_surface"), offset: z.number().optional() }),
|
||||
z.object({ type: z.literal("y_at_least"), function: density }),
|
||||
z.object({ type: z.literal("density"), function: density, ...bounds(z.number()) }).refine(
|
||||
has_bound,
|
||||
NEEDS_BOUND,
|
||||
),
|
||||
z.object({ type: z.literal("biome"), biome_is: z.array(biome_id) }),
|
||||
z.object({ type: z.literal("not"), invert: surface_condition }),
|
||||
])
|
||||
|
||||
@@ -90,6 +90,11 @@ function compile_condition(json: SurfaceConditionJson, terrain: NoiseTerrain): C
|
||||
const at = terrain.compiler.compile(json.function);
|
||||
return (context) => context.y >= at(context.x, context.y, context.z);
|
||||
}
|
||||
case "density": {
|
||||
const value = terrain.compiler.compile(json.function);
|
||||
const test = range_test(json);
|
||||
return (context) => test(value(context.x, context.y, context.z));
|
||||
}
|
||||
case "biome": {
|
||||
const biomes = new Set(json.biome_is);
|
||||
return (context) => biomes.has(context.biome);
|
||||
|
||||
Reference in New Issue
Block a user