Table of Contents

Class PrefabSpawnRule

Namespace
FishMMO.Shared.Biomes
Assembly
FishMMO.Shared.dll

Where and how densely a set of prefabs is scattered wherever its texture layer dominates. Field names match the WorldEditor asset layout so exported biome templates load unchanged.

[Serializable]
public class PrefabSpawnRule
Inheritance
PrefabSpawnRule
Inherited Members

Fields

alignToTerrainNormal

public bool alignToTerrainNormal

Field Value

bool

densityPer100m2

[Header("Density & Limits")]
[Tooltip("Expected prefab count per 100 square meters of dominant texture.")]
[Range(0, 50)]
public float densityPer100m2

Field Value

float

detailDryColor

[Tooltip("Tint applied when the detail patch is considered dry.")]
public Color detailDryColor

Field Value

Color

detailHealthyColor

[Tooltip("Tint applied when the detail patch is considered healthy.")]
public Color detailHealthyColor

Field Value

Color

detailInstancesPerSpawn

[Tooltip("How many instances are written into the detail map for every accepted spawn sample.")]
[Range(64, 255)]
public int detailInstancesPerSpawn

Field Value

int

detailNoiseSpread

[Header("Detail Rendering")]
[Tooltip("Controls how widely detail prototypes spread noise across the terrain patch.")]
[Range(0.05, 5)]
public float detailNoiseSpread

Field Value

float

enableSpawning

[Tooltip("Enable or disable this spawn rule without removing configuration.")]
public bool enableSpawning

Field Value

bool

heightFalloff

[Range(0.001, 0.2)]
public float heightFalloff

Field Value

float

heightRange

public MinMaxRange heightRange

Field Value

MinMaxRange

heightScaleRange

[Tooltip("Random scale range for tree height (only used when non-uniform scaling is enabled).")]
public Vector2 heightScaleRange

Field Value

Vector2

maxPerChunk

[Tooltip("Absolute safety cap per terrain chunk. 0 = unlimited (not recommended).")]
[Min(0)]
public int maxPerChunk

Field Value

int

minSpacing

[Tooltip("Minimum spacing in meters between spawned prefabs.")]
[Range(0, 50)]
public float minSpacing

Field Value

float

minTextureWeight

[Header("Texture Weight")]
[Tooltip("Require the target texture weight to exceed this threshold in the alphamap to consider spawning.")]
[Range(0, 1)]
public float minTextureWeight

Field Value

float

prefabs

[Tooltip("List of prefabs to spawn. One will be randomly selected per spawn location for variation.")]
public GameObject[] prefabs

Field Value

GameObject[]

ruleName

[Header("Identification")]
public string ruleName

Field Value

string

seedOffset

[Tooltip("Seed offset applied on top of the global prefab seed to keep results deterministic per rule.")]
public int seedOffset

Field Value

int

slopeFalloff

[Range(1, 20)]
public float slopeFalloff

Field Value

float

slopeRange

public MinMaxRange slopeRange

Field Value

MinMaxRange

spawnChannel

[Header("Spawn Channel")]
[Tooltip("Choose whether this rule writes to Unity detail layers or tree instances.")]
public PrefabSpawnChannel spawnChannel

Field Value

PrefabSpawnChannel

spawnProbabilityMultiplier

[Tooltip("Optional multiplier applied to the computed spawn probability.")]
[Range(0.1, 5)]
public float spawnProbabilityMultiplier

Field Value

float

uniformScaleRange

[Tooltip("Random scale range applied uniformly to width and height (when non-uniform scaling is disabled).")]
public Vector2 uniformScaleRange

Field Value

Vector2

useHeightConstraint

[Header("Height Constraint")]
public bool useHeightConstraint

Field Value

bool

useNonUniformScaling

[Header("Randomization")]
[Tooltip("Enable independent width and height scaling for more natural tree variation.")]
public bool useNonUniformScaling

Field Value

bool

useSlopeConstraint

[Header("Slope Constraint")]
public bool useSlopeConstraint

Field Value

bool

widthScaleRange

[Tooltip("Random scale range for tree width (only used when non-uniform scaling is enabled).")]
public Vector2 widthScaleRange

Field Value

Vector2

yRotationRange

public Vector2 yRotationRange

Field Value

Vector2

Properties

StableGuid

public string StableGuid { get; }

Property Value

string

Methods

EnsureStableGuid()

public void EnsureStableGuid()

GetRandomPrefab(DeterministicRNG)

One of the rule's prefabs, drawn with the given RNG; null when it has none.

public GameObject GetRandomPrefab(DeterministicRNG rng)

Parameters

rng DeterministicRNG

Returns

GameObject

HasValidPrefabs()

public bool HasValidPrefabs()

Returns

bool