Skip to main content

PositionSurfaceDefinition

An abstract class in Root.Township, Alta.Chunks.

Base for components that pick random points (with normals) on a shape, used as spawn positions and population spawn points. Subclasses define the shape.

Constructors​

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

Fields​

MemberWhat it is
protected PositionSurfaceDefinitionSettings settingsThe global PositionSurfaceDefinitionSettings, set in Awake.
2 private and internal fields
MemberWhat it is
private PositionSurfaceDefinition.RotationMode rotationModeHow spawned objects are turned: up or forward along the surface normal with random spin, flat facing the normal, or none.
private int seedRandom seed picked on Awake, so each index gives the same point every time.

Methods​

MemberWhat it is
static bool Failed(out Vector3 position, out Vector3 normal)Helper that zeroes the outputs and returns false, for a GetPosition that found nothing.
PointNormal? GetPoint()A random point with its normal, or null if GetPosition failed.
abstract bool GetPosition(out Vector3 position, out Vector3 normal)Picks a random position and normal on the shape. False if none was found.
abstract void SetSize(float size)Resizes the shape.
protected void DrawArrow(Vector3 from, Vector3 to, Vector3 normal)Editor: draws an arrow gizmo, raycast onto the surface layers (blue on a hit, red on a miss).
protected bool PreviewArrows()Always false in this build.
2 private and internal methods
MemberWhat it is
private void Awake()Loads the global surface settings and picks a random seed.
private SpawnPoint ISpawnPositions.GetSpawnPosition(int index)Gets spawn point index with a seeded random state, turned by rotationMode. Returns null if no position was found.