using System.Collections.Immutable; using System.Threading.Tasks; using Barotrauma.Networking; namespace Barotrauma; public static partial class EosInterface { public static class IdQueries { private static Implementation? LoadedImplementation => Core.LoadedImplementation; public static bool IsLoggedIntoEosConnect => GetLoggedInPuids() is { Length: > 0 }; /// /// Gets all of the s the player has logged in with. /// For most players, this is expected to return one ID. /// It may return two IDs if a Steam user has chosen to link their account to an Epic Account. /// public static ImmutableArray GetLoggedInPuids() => LoadedImplementation.IsInitialized() ? LoadedImplementation.GetLoggedInPuids() : ImmutableArray.Empty; /// /// Gets all of the s the player has logged in with. /// This is expected to return at most one ID. ///

/// This should return exactly one ID for any Epic Games Store player. ///
/// Steam players may choose to link their account to only one Epic Games account. ///
public static ImmutableArray GetLoggedInEpicIds() => LoadedImplementation.IsInitialized() ? LoadedImplementation.GetLoggedInEpicIds() : ImmutableArray.Empty; public enum GetSelfExternalIdError { EosNotInitialized, Inaccessible, Timeout, InvalidUser, ParseError, UnhandledErrorCondition } public static async Task, GetSelfExternalIdError>> GetSelfExternalAccountIds( ProductUserId puid) => LoadedImplementation.IsInitialized() ? await LoadedImplementation.GetSelfExternalAccountIds(puid) : Result.Failure(GetSelfExternalIdError.EosNotInitialized); } internal abstract partial class Implementation { public abstract ImmutableArray GetLoggedInPuids(); public abstract ImmutableArray GetLoggedInEpicIds(); public abstract Task, IdQueries.GetSelfExternalIdError>> GetSelfExternalAccountIds(ProductUserId puid); } }