Skip to main content

SettingsQuickAccessMenu

A class in Root.Township, Alta.QuickAccessActions.

Quick access menu action that opens a settings board in front of the local player: either client settings, or the server's settings for players with permission. Client side.

Constructors​

MemberWhat it is
SettingsQuickAccessMenu()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

11 private and internal fields
MemberWhat it is
private IQuickAccessSettingsBoard activeBoardThe board currently shown, if any.
private PooledObjectDefinition boardDefinitionPooled board object that shows the settings.
private float boardDistanceFromHeadHow far in front of the player the board appears.
private float boardHeightHeight of the board above the player's feet.
private bool hasPermissionWhether the local player may use this menu; server settings need server permissions.
private bool isActiveWhether the board is open. Backing field for IsActive.
private bool isIgnoredSet when initialized without a player, which hides the action.
private bool isServerSettingsEdits the server's settings instead of the player's own. Backing field for IsServerSettings.
private static Logger loggerClass logger.
private PooledObjectDefinition[] settingsDefinitionsPooled UI element to use for each setting type. Backing field for SettingsDefinitions.
private SettingsFieldAccess[] settingsToDisplayThe settings listed on the board. Backing field for SettingsToDisplay.

Properties​

MemberWhat it is
override bool IsActive { get; }True while the board is open.
override bool IsIgnored { get; }True when hidden from the menu: no permission, no ServerSettingsSync, or the server menu unavailable for non-devs.
bool IsServerSettings { get; }True if this edits the server's settings instead of the player's own.
override bool IsValid { get; }False while the player is downed.
ServerSettings ServerSettings { get; private set; }Server settings fetched for the open board. They are sent back to the server when the board closes.
PooledObjectDefinition[] SettingsDefinitions { get; }Pooled UI prefab for each SettingType.
SettingsFieldAccess[] SettingsToDisplay { get; }The settings fields shown on the board.

Methods​

MemberWhat it is
override async void InitializeForPlayer(Player player, bool isDev)Works out if the local player may use it. Server settings need a permissions check against the joined server, except in a local test.
override void Run(Controller controller)Toggles the board. For server settings it first requests them from the server.
5 private and internal methods
MemberWhat it is
private void Activate()Spawns the settings board in front of the player, sets it up and closes it if the player dies.
private void DeregisterBoard()Closes the board; for server settings, sends the edited settings back to the server.
private void PlayerDied(DamageData obj)Closes the board when the local player is killed.
private void PositionBoardForPlayer(Transform boardTransform)Places the board at boardHeight above the player's feet, boardDistanceFromHead in front, facing them.
private async void ValidateAccessAndGetServerSettings()Asks the server for its settings and opens the board if the menu is still open when they arrive.

Used in​

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