Skip to main content

ConstrainedSpawnerDisplay

A class in Root.Township, Alta.Caves.

Cave chunk display that spawns a networked prefab at cells of its layer with a value above zero, limited by a quantity and a list of SpawnConstrain checks. Server only.

Constructors​

MemberWhat it is
ConstrainedSpawnerDisplay()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

17 private and internal fields
MemberWhat it is
private int baseQuantityToSpawnStarting number of prefabs to spawn per chunk before constraints change it.
private SpawnConstrain[] constrainsChecks that can change the quantity or cancel spawning for this chunk.
private float floorThresholdFloor layer value below which a cell counts as open, used to find the floor height.
private bool hasIdentityRotationIf set, spawned objects are not rotated.
private bool isOrientedWithFaceIf set, objects are rotated to the surface normal found by the raycast.
private bool isOrientedWithFaceUpForcedWith face orientation, skips the extra 90 degree tilt so the object's forward points along the normal.
private bool isRaycastDownRaycast down if set, otherwise up.
private bool isRaycastedIf set, raycasts to find the surface and drops the spawn if nothing is hit.
private bool isRotationRandomIf set, uses a fully random rotation instead of a random Y rotation.
private bool isUsingFloorLayerIf set, lifts the spawn to the floor height read from the floor plugin's layer.
private float offsetHeight offset added to the spawn position (and above the raycast hit).
private float orientationWeightBlend between a random Y rotation (0) and the surface orientation (1).
private NetworkPrefab prefabThe networked prefab to spawn.
private float raycastDistanceMaximum raycast length.
private LayerMask raycastMaskLayers the raycast can hit.
private float yNormalMaximumHighest allowed Y of the hit normal; steeper or flatter surfaces are skipped.
private float yNormalMinimumLowest allowed Y of the hit normal.

Methods​

MemberWhat it is
override void Initialize()Does nothing.
override IEnumerator Render() (iterator)Server: runs the constraints to get a quantity, then spawns at non-zero cells until the quantity runs out.
1 private and internal method
MemberWhat it is
private bool Spawn(MapChunkLayer layer, MapChunkLayer floor, int renderIndex, int x, int z, float value, ref int index)Works out a hashed position and rotation for a cell, optionally raycasts to the surface and checks its slope, then spawns the prefab in the generator's chunk.