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.Ecom;
using EpicRerouter.QsbSide;
using System;
using static EntitlementsManager;
namespace EpicRerouter.ProcessSide
@ -16,15 +16,11 @@ namespace EpicRerouter.ProcessSide
private static OwnershipStatus _epicDlcOwnershipStatus;
private static bool _epicResultReceived;
public static void Init()
{
public static void Init() =>
EpicPlatformManager.OnAuthSuccess += EOSQueryOwnership;
}
public static void Uninit()
{
public static void Uninit() =>
EpicPlatformManager.OnAuthSuccess -= EOSQueryOwnership;
}
public static AsyncOwnershipStatus GetOwnershipStatus()
{
@ -33,17 +29,13 @@ namespace EpicRerouter.ProcessSide
return AsyncOwnershipStatus.NotReady;
}
if (_epicDlcOwnershipStatus != OwnershipStatus.Owned)
{
return AsyncOwnershipStatus.NotOwned;
}
return AsyncOwnershipStatus.Owned;
return _epicDlcOwnershipStatus == OwnershipStatus.Owned ?
AsyncOwnershipStatus.Owned : AsyncOwnershipStatus.NotOwned;
}
private static void EOSQueryOwnership()
{
Interop.Log("[EOS] querying DLC ownership");
Console.WriteLine("[EOS] querying DLC ownership");
_ecomInterface = EpicPlatformManager.PlatformInterface.GetEcomInterface();
var queryOwnershipOptions = new QueryOwnershipOptions
{
@ -59,7 +51,7 @@ namespace EpicRerouter.ProcessSide
{
_epicDlcOwnershipStatus = data.ItemOwnership[0].OwnershipStatus;
_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.Auth;
using Epic.OnlineServices.Platform;
using EpicRerouter.QsbSide;
using System;
namespace EpicRerouter.ProcessSide
@ -34,7 +33,7 @@ namespace EpicRerouter.ProcessSide
{
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();
}
public static void Tick()
{
public static void Tick() =>
PlatformInterface.Tick();
}
public static void Uninit()
{
@ -78,12 +75,12 @@ namespace EpicRerouter.ProcessSide
DeploymentId = _eosDeploymentID
};
PlatformInterface = PlatformInterface.Create(options);
Interop.Log("[EOS] Platform interface has been created");
Console.WriteLine("[EOS] Platform interface has been created");
}
private static void Auth()
{
Interop.Log("[EOS] Authenticating...");
Console.WriteLine("[EOS] Authenticating...");
var loginOptions = new LoginOptions
{
Credentials = new Credentials
@ -96,7 +93,7 @@ namespace EpicRerouter.ProcessSide
};
if (PlatformInterface == null)
{
Interop.Log("[EOS] Platform interface is null!");
Console.Error.WriteLine("[EOS] Platform interface is null!");
return;
}
@ -122,18 +119,21 @@ namespace EpicRerouter.ProcessSide
if (loginCallbackInfo.ResultCode == Result.Success)
{
LocalUserId = loginCallbackInfo.LocalUserId;
Interop.Log($"[EOS SDK] login success! user ID: {LocalUserId}");
Console.WriteLine($"[EOS SDK] login success! user ID: {LocalUserId}");
OnAuthSuccess.Invoke();
return;
}
Interop.Log("[EOS SDK] Login failed");
Console.Error.WriteLine("[EOS SDK] Login failed");
}
private class EOSInitializeException : Exception
{
public readonly Result Result;
public EOSInitializeException(string msg, Result initResult) : base(msg) => Result = initResult;
public EOSInitializeException(string msg, Result initResult) :
base(msg) =>
Result = initResult;
}
}
}