Skip to main content

ServerCreator

A class in Root.Township, the global namespace.

Client main-menu panel for creating a new server through the Alta API: pick a region, name, description and visibility. Shows a fallback panel if the account can't create one.

Constructors​

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

Fields​

11 private and internal fields
MemberWhat it is
private GameObject cantCreateParentPanel shown when the account can't create a server.
private GameObject createServerParentPanel shown when it can.
private VirtualInputField descriptionInputInput for the server description.
private bool isCreatingInspector button field for creating a server.
private static Logger loggerNLog logger for this class.
private ServerSelectionMenu menuThe server selection menu to refresh after creating.
private VirtualInputField nameInputInput for the server name.
private AltaEvent onServerCreateEvent fired after a server is created.
private RegionInfo[] regionsRegions loaded from the API.
private CustomScroller scrollerScroller for picking the region.
private CustomScroller visibilityTypeScrollerScroller for picking the group type (visibility).

Methods​

MemberWhat it is
async void CreateServerAsync()Calls the API to create a group and server with the chosen options, then shows and selects it in My Servers.
6 private and internal methods
MemberWhat it is
private async Task<bool> IsAllowedToCreateServer()Asks the API for the account's group creation allowance; true if any are left.
private void OnDisable()Unhooks from the logged-in event.
private void OnEnable()Runs Setup now if logged in, otherwise hides the panel and waits for login.
private void OnValidate()Editor: the Create Server button runs CreateServerAsync.
private void SetActive(bool isActive)Shows the create panel or the cannot-create panel.
private async void Setup()Checks the allowance, shows the right panel and loads the server regions into the region scroller.