Skip to main content

ServerSelector

A class in Root.Township, the global namespace.

Main-menu server list helper: when a server is selected it fills a gauge, then fires the selection finished event; deselecting fades the gauge out.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private Coroutine gaugeAnimationThe running gauge coroutine.
private float gaugeFadeAwayDurationSeconds to fade the gauge out. Default 1.5.
private float gaugeFillDurationSeconds to fill the gauge. Default 0.8.
private GaugeProgressBar gaugeProgressThe gauge progress bar.
private static Logger loggerNLog logger for this class.
private ServerSelectionMenu menuBoardsThe server selection menu whose selection it watches.
private ServerElementEvent oldElementDeselectedEvent fired with the server that was deselected (or null).
private ServerElementEvent selectionFinishedEvent fired with the server once the gauge is full (or null).

Methods​

9 private and internal methods
MemberWhat it is
private IEnumerator AnimateGaugeAlpha(float startAlpha, float targetAlpha) (iterator)Coroutine that fades the gauge alpha over gaugeFadeAwayDuration.
private IEnumerator AnimateGaugeProgress(ServerElement selectedServer) (iterator)Coroutine that fills the gauge over gaugeFillDuration, then finishes the selection.
private void Deselect()Deselects with no old element. Called on logout.
private void NewServerElementSelected(ServerElement oldElement, ServerElement newElement)Handles a selection change: deselects the old one, then starts the gauge or finishes with null.
private void OnDestroy()Unhooks from logout.
private void OnSelectionFinished(ServerElement selectedServer)Fires selectionFinished with the server.
private void OnServerDeselected(ServerElement oldElement)Fades the gauge out if there was an old element, and fires oldElementDeselected.
private void OnServerDisplaySettled(ServerElement selectedServer)Restarts the gauge fill for the newly selected server.
private void Start()Hooks logout and the menu's selection change.