Skip to main content

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.

Constructors​

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

Fields​

14 private and internal fields
MemberWhat it is
private Vector3 alignmentDirectionFacing direction in the parent's space, kept flat.
private float angleToRotateDot product threshold (set as an angle) below which the part swings round.
private Quaternion backwardPositionLocal rotation when turned to the other side.
private bool isInStartPositionTrue while at startingPosition; flips after each swing.
private bool isRotatingTrue while a swing is in progress.
private float rotationDurationSeconds a swing takes.
private float rotationProgress0 to 1 progress of the current swing.
private SkillShrine shrineThe skill shrine whose player is tracked.
private Quaternion startingPositionLocal rotation at the start side.
private IPlayer targetPlayerThe shrine's current player.
private IUnityUpdateMethod updateHandle of the late update.
private static UpdateModule updateModuleLate-update module the rotation runs in.
private Vector3 worldAlignementDirectionCached world-space alignment direction.
private Vector3 worldPositionCached world position of the part.

Methods​

8 private and internal methods
MemberWhat 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.