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.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
ServerBoard() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
18 private and internal fields
| Member | What it is |
|---|---|
private Coroutine createServerBoards | The running UpdateServersList coroutine, if any. |
private ServerSelectionDisplay display | The curved ServerSelectionDisplay that shows and selects this board's elements. |
private Transform elementParent | Transform that spawned server elements go under. Shown and hidden with the board. |
private ServerBoardFilter filter | The ServerBoardFilter applied to the received servers. |
private bool hasFilterChanged | Set when the filter changes so the next rebuild selects the first server. |
private string headingText | Heading shown for this board, read through HeadingText. |
private int interval | Seconds left until the next refresh. Reset to updateInterval on each refresh. |
private bool isFirstServerLoad | True until the first rebuild with servers, which selects the first server. |
private TextRenderer joiningServerText | Text shown by DisableUpdate while joining a server. |
private IEnumerable<GameServerInfo> lastFilteredServers | The received servers after filtering and validity checks, as last shown. |
private IEnumerable<GameServerInfo> lastReceivedServers | The last unfiltered server list from the API. |
private Coroutine loadServers | The running LoadServers coroutine, if any. |
private List<ServerElement> serverDisplays | Spawned ServerElement objects in display order, reused across refreshes. |
private ServerElement serverElementPrefab | Prefab spawned for each server in the list. |
private Dictionary<int, ServerElement> serverElements | Server elements keyed by server identifier, rebuilt on each refresh to restore the selection. |
private ServerBoardType type | Which API list this board shows: public, my (joined), open or discover servers. |
private TextRenderer updateCountdownText | Text that shows "Updating in Ns". |
private int updateInterval | Seconds between list refreshes. Default 30. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event Action OnRefreshFinished | Raised once after the next refresh, then cleared. Add a handler again for each refresh. |
event SelectedElementChanged SelectedChanged | Raised when the selected server entry changes. |
Methods
| Member | What 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
| Member | What 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: