Skip to main content

SpawnPointsDisplay

A class in Root.Township, Alta.Populations.

Map generator display that turns a chunk layer's non-zero cells into spawn points for one population and hands them to the ecosystem. Server only (Render does nothing on clients).

Constructors​

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

Fields​

19 private and internal fields
MemberWhat it is
private float floorThresholdFloor layer value at or below which a height level counts as open, used to lift the point to the first open level.
private bool hasIdentityRotationIf true, spawn points always face the default rotation.
private bool isOrientedWithFaceIf true (and the point is raycasted), the point is rotated to match the surface normal it hit.
private bool isOrientedWithFaceUpForcedWhen orienting with the hit surface, skips the extra 90 degree tilt that would otherwise be applied.
private bool isRaycastDownRaycast direction: down if true, up if false.
private bool isRaycastedIf true, each point is raycast onto geometry and dropped if nothing is hit or the surface slope is out of range.
private bool isRotationRandomIf true, uses a fully random rotation instead of a random yaw (when not identity or face oriented).
private bool isUsingFloorLayerIf true, reads the render generator's floor layer to set each point's height.
private float offsetHeight offset added to each point, and added again above the raycast hit point.
private float orientationWeightHow much face orientation wins over a random yaw (1 is fully aligned to the surface).
private float raycastDistanceLength of the placement raycast.
private LayerMask raycastMaskLayers the placement raycast hits.
private int spawnPointIndexRunning index given to each accepted spawn point, reset to -1 at the start of Render.
private Vector3 spawnPositionScratch position of the point being placed.
private Quaternion spawnRotationScratch rotation of the point being placed.
private int spawnSeedHashed seed for the current point. Computed but not passed on to the spawn point.
private PopulationDefinition targetPopulationPopulation definition whose hash the spawn points are registered under.
private float yNormalMaximumHighest allowed Y of the hit surface normal; points on flatter ground are rejected.
private float yNormalMinimumLowest allowed Y of the hit surface normal; points on steeper ground are rejected.

Methods​

MemberWhat it is
override void Initialize()Does nothing.
override IEnumerator Render() (iterator)Server: walks the layer's non-zero cells, makes a spawn point for each, then passes the list to the layer streamer's Ecosystem.SetPoints with the population's hash.
1 private and internal method
MemberWhat it is
private SpawnPoint Spawn(MapChunkLayer layer, MapChunkLayer floor, int renderIndex, int x, int z, float value, ref int index)Places one spawn point for a cell: random jitter, floor height, optional raycast and normal check, and rotation. Returns null if rejected.