Internals rewritten. PHoton config can now be fetched from the server, and if it fails, fallback to the local configuration.

This commit is contained in:
2025-08-16 21:04:26 -04:00
parent 8ca37170e4
commit 087d9a900e
20 changed files with 393 additions and 234 deletions

View File

@@ -0,0 +1,41 @@
using System.Reflection;
using HarmonyLib;
using undead_universal_patch_il2cpp.Core;
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
namespace undead_universal_patch_il2cpp.Patches.Internals;
[HarmonyPatch]
public class AuthenticationEventPatch
{
static PatchTypesResult patchResult = Util.PreparePatchTypes(
"RecNet AccessToken event patch",
"RecNet.Login",
"SetAccessToken"
);
static readonly PropertyInfo hasAccessTokenProperty = patchResult.Type?.GetProperty("HasAccessToken");
static bool Prepare() => Util.PostRequireTypes(patchResult, [
hasAccessTokenProperty
]).Success;
static MethodBase TargetMethod() => patchResult.Method;
private static bool RanPostActions { get; set; } = false;
static void Postfix(ref string accessToken)
{
UniversalPatchPlugin.Log.LogInfo("Intercepted AccessToken");
RecNetInteractions.AccessToken = accessToken;
if (!RanPostActions)
{
bool value = (bool)hasAccessTokenProperty.GetValue(patchResult.Type);
if (value) UniversalPatchPlugin.Log.LogInfo("Running post-authentication actions");
foreach (var action in RecNetInteractions.postAuthenticationActions)
action();
}
else RanPostActions = true;
}
}

View File

@@ -0,0 +1,32 @@
using System.Reflection;
using BestHTTP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using RecRoom.Async;
using undead_universal_patch_il2cpp.Core;
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
namespace undead_universal_patch_il2cpp.Patches.Internals;
[HarmonyPatch]
public class GetMyAccountEventPatch
{
static PatchTypesResult patchResult = Util.PreparePatchTypes(
"RecNet GetLocalAccount event patch",
"RecNet.Accounts",
"GetLocalAccount"
);
static bool Prepare() => patchResult.Success;
static MethodBase TargetMethod() => patchResult.Method;
static void Postfix(ref IPromise<RecNet.SelfAccount> __result)
{
__result.Then(DelegateSupport.ConvertDelegate<Il2CppSystem.Action>(() =>
{
UniversalPatchPlugin.Log.LogInfo("Running post-GetLocalAccount actions");
foreach (var action in RecNetInteractions.postLocalAccountActions) action();
}));
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using HarmonyLib;
using Il2CppInterop.Runtime;
using RecRoom.Async;
using undead_universal_patch_il2cpp.Core;
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
namespace undead_universal_patch_il2cpp.Patches.Internals;
[HarmonyPatch]
public class NameserverConnectEventPatch
{
static PatchTypesResult patchResult = Util.PreparePatchTypes(
"Nameserver connect event patch",
"RecNet.Core",
"ConnectToRecNet"
);
static bool Prepare() => patchResult.Success;
static MethodBase TargetMethod() => patchResult.Method;
static void Postfix(ref IPromise __result)
{
__result.Finally(DelegateSupport.ConvertDelegate<Il2CppSystem.Action>(() =>
{
if (RecNetInteractions.HasNameserverConnected())
{
UniversalPatchPlugin.Log.LogInfo("Running post-nameserver actions");
foreach (var action in RecNetInteractions.postNameServerActions) action();
}
else Util.ConditionalDebug("The nameserver request did not resolve successfully, skipping post-nameserver actions.");
}));
}
}