From a283287906bf6f415ec2bed4edc33414a97db8d2 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Thu, 21 Nov 2024 02:19:43 -0600 Subject: [PATCH] DataStorage: implement race mode helper --- .../Helpers/DataStorageWrappers.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Archipelago.MultiClient.Net/Helpers/DataStorageWrappers.cs b/Archipelago.MultiClient.Net/Helpers/DataStorageWrappers.cs index 42547d8..668035c 100644 --- a/Archipelago.MultiClient.Net/Helpers/DataStorageWrappers.cs +++ b/Archipelago.MultiClient.Net/Helpers/DataStorageWrappers.cs @@ -183,6 +183,20 @@ void TrackHints(Action onHintsUpdated, /// the team id of the player to request the status for, defaults to the current player's team if left empty void TrackClientStatus(Action onStatusUpdated, bool retrieveCurrentClientStatus = true, int? slot = null, int? team = null); + +#if NET35 + /// + /// Retrieves the server's race mode setting. 0 for disabled, 1 for enabled + /// + /// the method to call with the retrieved race mode setting + void GetRaceModeAsync(Action onRaceModeRetrieved); +#else + /// + /// Retrieves the server's race mode setting. 0 for disabled, 1 for enabled + /// + /// the method to call with the retrieved race mode setting + Task GetRaceModeAsync(); +#endif } public partial class DataStorageHelper : IDataStorageWrapper @@ -197,6 +211,7 @@ DataStorageElement GetLocationNameGroupsElement(string game = null) => this[Scope.ReadOnly, $"location_name_groups_{game ?? connectionInfoProvider.Game}"]; DataStorageElement GetClientStatusElement(int? slot = null, int? team = null) => this[Scope.ReadOnly, $"client_status_{team ?? connectionInfoProvider.Team}_{slot ?? connectionInfoProvider.Slot}"]; + DataStorageElement GetRaceModeElement() => this[Scope.ReadOnly, "race_mode"]; /// public Hint[] GetHints(int? slot = null, int? team = null) => @@ -302,5 +317,15 @@ public void TrackClientStatus(Action onStatusUpdated, GetClientStatusAsync(slot, team).ContinueWith(t => onStatusUpdated(t.Result)); #endif } + +#if NET35 + /// + public void GetRaceModeAsync(Action onRaceModeRetrieved) => + GetRaceModeElement().GetAsync(t => onRaceModeRetrieved(t.ToObject() ?? 0)); +#else + /// + public Task GetRaceModeAsync() => GetRaceModeElement().GetAsync() + .ContinueWith(t => t.Result ?? 0); +#endif } }