Skip to content

Commit 0d15540

Browse files
authored
Merge pull request #109 from alwaysintreble/race_mode
DataStorage: implement race mode helper
2 parents 054752a + a283287 commit 0d15540

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Archipelago.MultiClient.Net/Helpers/DataStorageWrappers.cs

+25
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ void TrackHints(Action<Hint[]> onHintsUpdated,
183183
/// <param name="team">the team id of the player to request the status for, defaults to the current player's team if left empty</param>
184184
void TrackClientStatus(Action<ArchipelagoClientState> onStatusUpdated,
185185
bool retrieveCurrentClientStatus = true, int? slot = null, int? team = null);
186+
187+
#if NET35
188+
/// <summary>
189+
/// Retrieves the server's race mode setting. 0 for disabled, 1 for enabled
190+
/// </summary>
191+
/// <param name="onRaceModeRetrieved"> the method to call with the retrieved race mode setting</param>
192+
void GetRaceModeAsync(Action<int> onRaceModeRetrieved);
193+
#else
194+
/// <summary>
195+
/// Retrieves the server's race mode setting. 0 for disabled, 1 for enabled
196+
/// </summary>
197+
/// <param name="onRaceModeRetrieved"> the method to call with the retrieved race mode setting</param>
198+
Task<int> GetRaceModeAsync();
199+
#endif
186200
}
187201

188202
public partial class DataStorageHelper : IDataStorageWrapper
@@ -197,6 +211,7 @@ DataStorageElement GetLocationNameGroupsElement(string game = null) =>
197211
this[Scope.ReadOnly, $"location_name_groups_{game ?? connectionInfoProvider.Game}"];
198212
DataStorageElement GetClientStatusElement(int? slot = null, int? team = null) =>
199213
this[Scope.ReadOnly, $"client_status_{team ?? connectionInfoProvider.Team}_{slot ?? connectionInfoProvider.Slot}"];
214+
DataStorageElement GetRaceModeElement() => this[Scope.ReadOnly, "race_mode"];
200215

201216
/// <inheritdoc />
202217
public Hint[] GetHints(int? slot = null, int? team = null) =>
@@ -302,5 +317,15 @@ public void TrackClientStatus(Action<ArchipelagoClientState> onStatusUpdated,
302317
GetClientStatusAsync(slot, team).ContinueWith(t => onStatusUpdated(t.Result));
303318
#endif
304319
}
320+
321+
#if NET35
322+
/// <inheritdoc />
323+
public void GetRaceModeAsync(Action<int> onRaceModeRetrieved) =>
324+
GetRaceModeElement().GetAsync(t => onRaceModeRetrieved(t.ToObject<int?>() ?? 0));
325+
#else
326+
/// <inheritdoc />
327+
public Task<int> GetRaceModeAsync() => GetRaceModeElement().GetAsync<int?>()
328+
.ContinueWith(t => t.Result ?? 0);
329+
#endif
305330
}
306331
}

0 commit comments

Comments
 (0)