Refactor lobby status (#10550)

This commit is contained in:
wrexbe
2022-08-14 12:54:49 -07:00
committed by GitHub
parent c535214aa2
commit c4d135e253
15 changed files with 126 additions and 108 deletions

View File

@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -215,6 +216,26 @@ namespace Content.Server.Preferences.Managers
return _cachedPlayerPrefs.ContainsKey(session.UserId);
}
/// <summary>
/// Tries to get the preferences from the cache
/// </summary>
/// <param name="userId">User Id to get preferences for</param>
/// <param name="playerPreferences">The user preferences if true, otherwise null</param>
/// <returns>If preferences are not null</returns>
public bool TryGetCachedPreferences(NetUserId userId,
[NotNullWhen(true)] out PlayerPreferences? playerPreferences)
{
if (_cachedPlayerPrefs.TryGetValue(userId, out var prefs))
{
playerPreferences = prefs.Prefs;
return prefs.Prefs != null;
}
playerPreferences = null;
return false;
}
/// <summary>
/// Retrieves preferences for the given username from storage.
/// Creates and saves default preferences if they are not found, then returns them.