This commit is contained in:
JohnCorby 2022-02-06 22:40:55 -08:00
parent b93e23dc57
commit ac5a688eea
2 changed files with 18 additions and 26 deletions

View File

@ -1,6 +1,6 @@
using Epic.OnlineServices; using Epic.OnlineServices;
using Epic.OnlineServices.Ecom; using Epic.OnlineServices.Ecom;
using EpicRerouter.QsbSide; using System;
using static EntitlementsManager; using static EntitlementsManager;
namespace EpicRerouter.ProcessSide namespace EpicRerouter.ProcessSide
@ -16,15 +16,11 @@ namespace EpicRerouter.ProcessSide
private static OwnershipStatus _epicDlcOwnershipStatus; private static OwnershipStatus _epicDlcOwnershipStatus;
private static bool _epicResultReceived; private static bool _epicResultReceived;
public static void Init() public static void Init() =>
{
EpicPlatformManager.OnAuthSuccess += EOSQueryOwnership; EpicPlatformManager.OnAuthSuccess += EOSQueryOwnership;
}
public static void Uninit() public static void Uninit() =>
{
EpicPlatformManager.OnAuthSuccess -= EOSQueryOwnership; EpicPlatformManager.OnAuthSuccess -= EOSQueryOwnership;
}
public static AsyncOwnershipStatus GetOwnershipStatus() public static AsyncOwnershipStatus GetOwnershipStatus()
{ {
@ -33,17 +29,13 @@ namespace EpicRerouter.ProcessSide
return AsyncOwnershipStatus.NotReady; return AsyncOwnershipStatus.NotReady;
} }
if (_epicDlcOwnershipStatus != OwnershipStatus.Owned) return _epicDlcOwnershipStatus == OwnershipStatus.Owned ?
{ AsyncOwnershipStatus.Owned : AsyncOwnershipStatus.NotOwned;
return AsyncOwnershipStatus.NotOwned;
}
return AsyncOwnershipStatus.Owned;
} }
private static void EOSQueryOwnership() private static void EOSQueryOwnership()
{ {
Interop.Log("[EOS] querying DLC ownership"); Console.WriteLine("[EOS] querying DLC ownership");
_ecomInterface = EpicPlatformManager.PlatformInterface.GetEcomInterface(); _ecomInterface = EpicPlatformManager.PlatformInterface.GetEcomInterface();
var queryOwnershipOptions = new QueryOwnershipOptions var queryOwnershipOptions = new QueryOwnershipOptions
{ {
@ -59,7 +51,7 @@ namespace EpicRerouter.ProcessSide
{ {
_epicDlcOwnershipStatus = data.ItemOwnership[0].OwnershipStatus; _epicDlcOwnershipStatus = data.ItemOwnership[0].OwnershipStatus;
_epicResultReceived = true; _epicResultReceived = true;
Interop.Log($"[EOS] Query DLC ownership complete: {_epicDlcOwnershipStatus}"); Console.WriteLine($"[EOS] Query DLC ownership complete: {_epicDlcOwnershipStatus}");
} }
} }
} }

View File

@ -1,7 +1,6 @@
using Epic.OnlineServices; using Epic.OnlineServices;
using Epic.OnlineServices.Auth; using Epic.OnlineServices.Auth;
using Epic.OnlineServices.Platform; using Epic.OnlineServices.Platform;
using EpicRerouter.QsbSide;
using System; using System;
namespace EpicRerouter.ProcessSide namespace EpicRerouter.ProcessSide
@ -34,7 +33,7 @@ namespace EpicRerouter.ProcessSide
{ {
if (ex.Result == Result.AlreadyConfigured) if (ex.Result == Result.AlreadyConfigured)
{ {
Console.WriteLine("[EOS] platform already configured!"); Console.Error.WriteLine("[EOS] platform already configured!");
} }
} }
} }
@ -42,10 +41,8 @@ namespace EpicRerouter.ProcessSide
Auth(); Auth();
} }
public static void Tick() public static void Tick() =>
{
PlatformInterface.Tick(); PlatformInterface.Tick();
}
public static void Uninit() public static void Uninit()
{ {
@ -78,12 +75,12 @@ namespace EpicRerouter.ProcessSide
DeploymentId = _eosDeploymentID DeploymentId = _eosDeploymentID
}; };
PlatformInterface = PlatformInterface.Create(options); PlatformInterface = PlatformInterface.Create(options);
Interop.Log("[EOS] Platform interface has been created"); Console.WriteLine("[EOS] Platform interface has been created");
} }
private static void Auth() private static void Auth()
{ {
Interop.Log("[EOS] Authenticating..."); Console.WriteLine("[EOS] Authenticating...");
var loginOptions = new LoginOptions var loginOptions = new LoginOptions
{ {
Credentials = new Credentials Credentials = new Credentials
@ -96,7 +93,7 @@ namespace EpicRerouter.ProcessSide
}; };
if (PlatformInterface == null) if (PlatformInterface == null)
{ {
Interop.Log("[EOS] Platform interface is null!"); Console.Error.WriteLine("[EOS] Platform interface is null!");
return; return;
} }
@ -122,18 +119,21 @@ namespace EpicRerouter.ProcessSide
if (loginCallbackInfo.ResultCode == Result.Success) if (loginCallbackInfo.ResultCode == Result.Success)
{ {
LocalUserId = loginCallbackInfo.LocalUserId; LocalUserId = loginCallbackInfo.LocalUserId;
Interop.Log($"[EOS SDK] login success! user ID: {LocalUserId}"); Console.WriteLine($"[EOS SDK] login success! user ID: {LocalUserId}");
OnAuthSuccess.Invoke(); OnAuthSuccess.Invoke();
return; return;
} }
Interop.Log("[EOS SDK] Login failed"); Console.Error.WriteLine("[EOS SDK] Login failed");
} }
private class EOSInitializeException : Exception private class EOSInitializeException : Exception
{ {
public readonly Result Result; public readonly Result Result;
public EOSInitializeException(string msg, Result initResult) : base(msg) => Result = initResult;
public EOSInitializeException(string msg, Result initResult) :
base(msg) =>
Result = initResult;
} }
} }
} }