Skip to main content

ServerBoard

A class in Root.Township, the global namespace.

A server list board in the main menu (public, my servers, open or discover). Fetches its list from the Alta API every updateInterval seconds while logged in, filters and shows it. Client only.

Constructors​

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

Fields​

18 private and internal fields
MemberWhat it is
private Coroutine createServerBoardsThe running UpdateServersList coroutine, if any.
private ServerSelectionDisplay displayThe curved ServerSelectionDisplay that shows and selects this board's elements.
private Transform elementParentTransform that spawned server elements go under. Shown and hidden with the board.
private ServerBoardFilter filterThe ServerBoardFilter applied to the received servers.
private bool hasFilterChangedSet when the filter changes so the next rebuild selects the first server.
private string headingTextHeading shown for this board, read through HeadingText.
private int intervalSeconds left until the next refresh. Reset to updateInterval on each refresh.
private bool isFirstServerLoadTrue until the first rebuild with servers, which selects the first server.
private TextRenderer joiningServerTextText shown by DisableUpdate while joining a server.
private IEnumerable<GameServerInfo> lastFilteredServersThe received servers after filtering and validity checks, as last shown.
private IEnumerable<GameServerInfo> lastReceivedServersThe last unfiltered server list from the API.
private Coroutine loadServersThe running LoadServers coroutine, if any.
private List<ServerElement> serverDisplaysSpawned ServerElement objects in display order, reused across refreshes.
private ServerElement serverElementPrefabPrefab spawned for each server in the list.
private Dictionary<int, ServerElement> serverElementsServer elements keyed by server identifier, rebuilt on each refresh to restore the selection.
private ServerBoardType typeWhich API list this board shows: public, my (joined), open or discover servers.
private TextRenderer updateCountdownTextText that shows "Updating in Ns".
private int updateIntervalSeconds between list refreshes. Default 30.

Properties​

MemberWhat it is
ServerSelectionDisplay Display { get; }The selection display that holds the server elements.
string HeadingText { get; }Heading shown for this board.
bool IsEmptyOrOnlyTutorial { get; }True if every server in the last list is on scene index 1 (the tutorial), or the list is empty.
ServerBoardType Type { get; }Which API list this board shows.

Events​

MemberWhat it is
event Action OnRefreshFinishedRaised once after the next refresh, then cleared. Add a handler again for each refresh.
event SelectedElementChanged SelectedChangedRaised when the selected server entry changes.

Methods​

MemberWhat it is
void DisableUpdate()Stops refreshing and hides the server entries, showing the joining text instead.
async Task RefreshServersList()Fetches this board type's servers from the API, then filters and rebuilds the list.
void ResumeUpdate()Hides the joining text, shows the entries again and restarts refreshing.
void SelectServer(GameServerInfo server)Selects the entry for the given server.
void SetActive(bool isActive)Shows or hides the board and starts or stops refreshing.
void UpdateValue(float value)Adds to the display's scroll value.
9 private and internal methods
MemberWhat it is
private void FilterServers()Runs the last received server list through filter and then sorts and rebuilds the displayed list.
private IEnumerator LoadServers() (iterator)Coroutine started by SetActive(true): refreshes the list, then counts down updateInterval seconds on updateCountdownText, repeating while logged in.
private void OnEnable()Subscribes OnFilterChanged to the filter's change event.
private void OnFilterChanged()Marks the filter as changed (so the first server gets selected again) and refilters the list.
private void OnSelectedChanged(ServerElement oldElement, ServerElement newElement)Forwards the display's selection change to this board's SelectedChanged event.
private void SortAndUpdateServersList()Reverses the filtered list, drops servers ServerFeatureSetProvider says are invalid, and restarts the UpdateServersList coroutine.
private void StartUpdatingServers()Stops any running refresh loop and starts LoadServers again.
private void StopUpdatingServer()Stops the LoadServers refresh loop.
private IEnumerator UpdateServersList() (iterator)Coroutine that reuses or spawns one ServerElement per server (one per frame), removes extras, and keeps or resets the selection.

Used in​

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