A class in Root.Township, Alta.Bezier.
Item modifier for a SplineDecorator that picks a prefab for each point by how sharply the spline turns there, flipping it 180 degrees for left turns where needed.
Constructors
| Member | What it is |
|---|
WedgeChooser() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
2 private and internal fields
| Member | What it is |
|---|
private List<bool> isReverse | Per-point flags recorded by FindClosest, saying which items to flip; cleared at the first point. |
private WedgeChooser.Wedge[] wedges | The wedge options, each with a turn angle and its prefabs (and optional mirrored prefabs). |
Methods
| Member | What it is |
|---|
override GameObject GetPrefab(List<SplineDecorator.Part> parts, int index) | Works out the average turn angle at this point from its neighbours and returns a random prefab from the closest wedge. |
override void Modify(List<SplineDecorator.Part> parts, int index, GameObject result) | Rotates the spawned item 180 degrees around Y if it was marked as reversed. |
2 private and internal methods
| Member | What it is |
|---|
private WedgeChooser.Wedge FindClosest(float angle) | Returns the wedge whose angle is closest to the turn angle and records whether that item should be flipped. |
private float GetRotation(Vector3 forward) | Converts a forward vector to its heading angle in degrees on the XZ plane. |