SkillsStructureRotator
A class in Root.Township, the global namespace.
Client-side shrine part that swings between two rotations when the shrine's active player walks around to the other side of it. Destroyed on headless servers.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
SkillsStructureRotator() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private Vector3 alignmentDirection | Facing direction in the parent's space, kept flat. |
private float angleToRotate | Dot product threshold (set as an angle) below which the part swings round. |
private Quaternion backwardPosition | Local rotation when turned to the other side. |
private bool isInStartPosition | True while at startingPosition; flips after each swing. |
private bool isRotating | True while a swing is in progress. |
private float rotationDuration | Seconds a swing takes. |
private float rotationProgress | 0 to 1 progress of the current swing. |
private SkillShrine shrine | The skill shrine whose player is tracked. |
private Quaternion startingPosition | Local rotation at the start side. |
private IPlayer targetPlayer | The shrine's current player. |
private IUnityUpdateMethod update | Handle of the late update. |
private static UpdateModule updateModule | Late-update module the rotation runs in. |
private Vector3 worldAlignementDirection | Cached world-space alignment direction. |
private Vector3 worldPosition | Cached world position of the part. |
Methods
8 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Destroys itself on headless builds; otherwise listens for the shrine's UpdatedPlayer. |
private Quaternion GetRotation() | Blends between the start and backward rotations by rotationProgress, in the current direction. |
private void OnDrawGizmosSelected() | Draws the facing direction and the angle limits that trigger a swing. |
private void OnValidate() | Flattens and normalizes alignmentDirection. |
private void Start() | Caches the world position and alignment direction. |
private void UpdatePlayer(IPlayer player) | Starts the update when the shrine gets a player and stops it when the player leaves, unless mid-swing. |
private void UpdateRotation() | Advances a running swing, or starts one when the player's feet move past angleToRotate from the facing side. |
private void UpdateValues() | Caches the world position and the alignment direction in world space. |