Skip to main content

RopePoweredElementBoard

A class in Root.Township, the global namespace.

Scrolling list board driven by pulling ropes: places its element transforms along a spline and moves them as the ropes are pulled. Used by the friends board and RopeUIList. Client side.

Constructors​

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

Fields​

15 private and internal fields
MemberWhat it is
private Vector3 alongsideAxisLocal axis used with the spline direction to work out each element's up direction.
private int boardDisplayCountHow many elements fit on the board at once.
private List<Transform> elementsBacking field for Elements.
private float firstValueSpline position of the first element when scrolled to the start.
private bool isSettingParentWhether added elements are parented to the spline transform.
private float lastValueSpline position of the last element when scrolled to the end; worked out by CalculateStartValue.
private float maximumEnabledTimeElements past this spline position are hidden.
private float minimumEnabledTimeElements before this spline position are hidden.
private float moveToTimeAnimationDurationDefault duration for a move animation. Not read in this class.
private Coroutine moveToTimeCoroutineRunning move animation, or null.
private RopeGrab[] ropeGrabsRopes whose pulling scrolls the board.
private float ropeSpeedMultiplierHow much the scroll position changes per unit of rope progress.
private float spacingGap between elements along the spline, in spline position units.
private BezierSpline splineBezier spline the elements sit on.
private float timeBacking field for Value.

Properties​

MemberWhat it is
List<Transform> Elements { get; }The transforms shown on the board, in order.
float Value { get; set; }Scroll position from 0 to 1. Setting it clamps the value and stops any move animation.

Methods​

MemberWhat it is
void AddElement(Transform element, bool isUpdatingCurve)Adds an element, parents it to the spline if isSettingParent is on, and optionally recalculates the end value.
void CalculateStartValue()Sets lastValue from firstValue, boardDisplayCount and spacing, which fixes how far the list can scroll.
void ClearAll()Removes every element from the list (the transforms are not destroyed).
void RemoveElement(Transform element)Removes one element and recalculates the end value.
void ResetAndSet(IEnumerable<Transform> elements, bool isUpdatingCurve)Replaces all elements with the given ones and scrolls back to the start.
10 private and internal methods
MemberWhat it is
private IEnumerator MoveToTime(float targetTime, float moveToTimeAnimationDuration) (iterator)Coroutine that eases the scroll position to a target over a duration. Nothing in this class starts it.
private void OnDisable()Stops listening to the rope grabs.
private void OnEnable()Hooks the rope grabs and recalculates the end value.
private void OnValidate()Editor: clamps time through Value.
private void PositionTransformAtTime(float targetTime, Transform target)Places an element at a point on the spline, facing along it, or hides it if outside the enabled range.
private void ScrollList(float oldRopeValue, float ropeValue)Rope progress handler: moves Value by the rope's change times ropeSpeedMultiplier.
private void Setup()Subscribes to every rope grab's progress change (once) and recalculates the end value.
private void StopCurrentMoveToTimeAnimation()Stops a running MoveToTime coroutine, if any.
private void Update()Repositions every element each frame.
private void UpdateTargets()Works out each element's spline position from the scroll value and places it.

Used in​

Members of other types that take, return or hold a RopePoweredElementBoard: