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.
- Listed in World, chunks and saving
- Inherits or implements
MonoBehaviour,ISpawnPositions,IPointNormalEvaluator - Derived types
CylindricalBoundsSurface,DirectionalBoundsSurface,SphericalSurface - Nested types
RotationMode
Constructors
| Member | What it is |
|---|---|
protected PositionSurfaceDefinition() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected PositionSurfaceDefinitionSettings settings | The global PositionSurfaceDefinitionSettings, set in Awake. |
2 private and internal fields
| Member | What it is |
|---|---|
private PositionSurfaceDefinition.RotationMode rotationMode | How spawned objects are turned: up or forward along the surface normal with random spin, flat facing the normal, or none. |
private int seed | Random seed picked on Awake, so each index gives the same point every time. |
Methods
| Member | What 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
| Member | What 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. |