Class CompositeTerrain
- Namespace
- Valheim.Testing
- Assembly
- Valheim.Testing.dll
Ordered fixture composition. Last matching region wins for height, biome and river facts together. This is explicit replacement, not native biome blending. Use pure terrain inputs and predicates when sharing a fixture across workers.
public sealed class CompositeTerrain : ITerrain
- Inheritance
-
objectCompositeTerrain
- Implements
Examples
Give a real mod algorithm a declared slope with a flat, half-open terrace; assert the result independently in the mod's test project. No Unity process or game data is involved:
ITerrain terrain = new CompositeTerrain(
new PlaneTerrain(40f, 0.25f, -0.5f),
TerrainRegion.Rectangle(4f, -2f, 8f, 2f, new PlaneTerrain(60f)));
float terraceHeight = terrain.GetHeight(4f, -2f); // 60; minimum edge included
float outsideHeight = terrain.GetHeight(8f, 0f); // 42; maximum edge excluded
See the runnable shared-world example for a complete pure test fixture.
Constructors
CompositeTerrain(ITerrain, params TerrainRegion[])
Copies the region list; the last matching region wins, or background when none matches.
public CompositeTerrain(ITerrain background, params TerrainRegion[] regions)
Parameters
backgroundITerrainregionsTerrainRegion[]
Methods
GetBiome(float, float)
Returns the selected region's biome, with the same precedence as height.
public TerrainBiome GetBiome(float x, float z)
Parameters
xfloatzfloat
Returns
GetHeight(float, float)
Returns the selected region's height in metres; non-finite coordinates are refused.
public float GetHeight(float x, float z)
Parameters
xfloatzfloat
Returns
- float
GetRiverWeight(float, float, out float, out float)
Returns the selected region's river facts, with the same precedence as height.
public void GetRiverWeight(float x, float z, out float weight, out float width)
Parameters
xfloatzfloatweightfloatwidthfloat