forked from zombieb/undead-universal-patch-il2cpp
116 lines
6.9 KiB
C#
116 lines
6.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BepInEx;
|
|
using BepInEx.Logging;
|
|
using BepInEx.Unity.IL2CPP;
|
|
using HarmonyLib;
|
|
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
|
using Mapster;
|
|
using undead_universal_patch_il2cpp.Core;
|
|
using undead_universal_patch_il2cpp.Core.AssetChanges;
|
|
using undead_universal_patch_il2cpp.Core.UndeadGameManager;
|
|
|
|
namespace undead_universal_patch_il2cpp;
|
|
|
|
[BepInPlugin("dev.proxnet.recroom.universalpatch.noneac.il2cpp", "Undead Universal Patch", "1.4.1")]
|
|
public class Plugin : BasePlugin
|
|
{
|
|
public static new readonly ManualLogSource Log = Logger.CreateLogSource("UUPatch");
|
|
|
|
static Harmony _hi = new("dev.proxnet.recroom.universalpatch.noneac.il2cpp");
|
|
|
|
public override bool Unload()
|
|
{
|
|
Log.LogInfo("Destroying.");
|
|
_hi.UnpatchSelf();
|
|
return true;
|
|
}
|
|
|
|
public override void Load()
|
|
{
|
|
Util.LocalInstanceGuid = Guid.NewGuid().ToString();
|
|
|
|
Log.LogInfo("It's time to Room some Rec and chew bubble gum..... and I'm all out of gum");
|
|
|
|
GenericConfig.PatchDebug = Config.Bind("Generic", "PatchDebug", GenericConfigDefaults.PatchDebug,
|
|
"Enable logging messages sent by patches for debugging. Usually not needed. Enable when submitting issues or bug reports.");
|
|
GenericConfig.LogAllRequests = Config.Bind("Generic", "LogAllRequests", GenericConfigDefaults.LogAllRequests,
|
|
"Log all BestHTTP requests sent by the game.");
|
|
GenericConfig.CertificatePatch = Config.Bind("Generic", "CertificatePatch", GenericConfigDefaults.CertificatePatch,
|
|
"The game expects a certain certificate from rec.net when making HTTPS requests. Enable this to allow any valid certificate.");
|
|
GenericConfig.HilePatch = Config.Bind("Generic", "HilePatch", GenericConfigDefaults.HilePatch,
|
|
"The game will close after a short period of time if BepInEx is found. Enable to stop this from happening." +
|
|
"This will also enable the AGRoomRuntimeConfig patch. See the README for more info.");
|
|
GenericConfig.SignalRHandshakeFix = Config.Bind("Generic", "SignalRHandshakeFix", GenericConfigDefaults.SignalRHandshakeFix,
|
|
"Replace apostrophes with quotes in the initial SignalR handshake.");
|
|
GenericConfig.ImageSignaturePatch = Config.Bind("Generic", "ImageSignaturePatch", GenericConfigDefaults.ImageSignaturePatch,
|
|
"When enabled, all image signatures will be valid." +
|
|
"\nWorks only if the server appends a properly formatted signature header (signature does not need to be valid)");
|
|
GenericConfig.RegistrationPatch = Config.Bind("Generic", "RegistrationPatch", GenericConfigDefaults.RegistrationPatch,
|
|
"Always disable the registration prompt.");
|
|
GenericConfig.AFKPatch = Config.Bind("Generic", "AFKPatch", GenericConfigDefaults.AFKPatch,
|
|
"Always present patch. Never get kicked to dorm.");
|
|
|
|
AssetChangesConfig.AGRoomChanges = Config.Bind("AssetChangesConfig", "AGRoomChanges", AssetChangesConfigDefaults.AGRoomChanges,
|
|
$"Use patches from '{AGRoomChanges.config.path}' to change the properties of internal AGRooms. See README.md");
|
|
GameManagerConfig.AnyGameFreeSpawn = Config.Bind("GameManagerConfig", "AnyGameFreeSpawn", GameManagerConfigDefaults.AnyGameFreeSpawn,
|
|
$"Use patches from '{GameFreeSpawns.config.path}' to spawn in any valid player spawnpoint in specified games. See README.md");
|
|
GameManagerConfig.StaticGameConfig = Config.Bind("GameManagerConfig", "StaticGameConfig", GameManagerConfigDefaults.StaticGameConfig,
|
|
$"Use patches from '{GameConfigurator.config.path}' to set new configurations for built-in games. See README.md");
|
|
|
|
PhotonConfig.PatchPhotonIds = Config.Bind("Photon", "PatchPhotonIds", PhotonConfigDefaults.PatchPhotonIds,
|
|
"Patch Photon configuration.");
|
|
PhotonConfig.PunLogging = Config.Bind("Photon", "PunLogging", PhotonConfigDefaults.PunLogging,
|
|
"Enable all logging sent by Photon/PUN/Voice (useful for server debugging)");
|
|
PhotonConfig.SelfHosted = Config.Bind("Photon", "IsSelfHosted", PhotonConfigDefaults.SelfHosted,
|
|
"When enabled, use a self-hosted 'OnPremises' PhotonSocketServer. (EXPERIMENTAL)" +
|
|
"\nWhen disabled, AppID and VoiceAppID are sent to Photon Cloud and a cloud masterserver is used.");
|
|
PhotonConfig.AppID = Config.Bind("Photon", "AppID", PhotonConfigDefaults.AppID,
|
|
"The new target (PUN) App ID from the Photon dashboard." +
|
|
"\nWhen self-hosting, this should be the name of your application (either 'Master' or 'Game')");
|
|
PhotonConfig.VoiceAppID = Config.Bind("Photon", "VoiceAppID", PhotonConfigDefaults.VoiceAppID,
|
|
"The new target Voice App ID from the Photon dashboard." +
|
|
"\nWhen self-hosting, this value is ignored, since Photon voice in Rec Room is based on PUN.");
|
|
PhotonConfig.ServerAddress = Config.Bind("Photon", "ServerAddress", PhotonConfigDefaults.ServerAddress,
|
|
"Address of the Photon master server (ignored if not using self-hosted)");
|
|
PhotonConfig.ServerPort = Config.Bind("Photon", "ServerPort", PhotonConfigDefaults.ServerPort,
|
|
"Photon master server UDP port (ignored if not using self-hosted)");
|
|
|
|
NameserverConfig.Rewrite = Config.Bind("Nameserver", "Rewrite", NameserverConfigDefaults.Rewrite,
|
|
"Enable/disable rewriting the URL for nameserver requests.");
|
|
NameserverConfig.NewUrl = Config.Bind("Nameserver", "NewUrl", NameserverConfigDefaults.NewUrl,
|
|
"The new full URL to use when sending a nameserver request.");
|
|
|
|
_hi.PatchAll();
|
|
|
|
Log.LogInfo("PATCH LIST START =========================");
|
|
foreach (var method in _hi.GetPatchedMethods()) Log.LogInfo($"- {method.ToString()}");
|
|
Log.LogInfo("PATCH LIST END =========================");
|
|
|
|
Log.LogInfo("Undead Universal IL2CPP Patch for Rec Room by @zombieb; loaded.");
|
|
|
|
try
|
|
{
|
|
CacheChangePatchConfigs();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.LogError($"Could not load change patches: {ex}");
|
|
}
|
|
|
|
TypeAdapterConfig.GlobalSettings
|
|
.ForType<List<TeamConfigurationDTO>, Il2CppStructArray<TeamConfiguration>>()
|
|
.MapWith(src => new Il2CppStructArray<TeamConfiguration>(src.Select(x => x.Adapt<TeamConfiguration>()).ToArray()));
|
|
TypeAdapterConfig.GlobalSettings
|
|
.ForType<List<StatConfigurationDTO>, Il2CppReferenceArray<StatConfiguration>>()
|
|
.MapWith(src => new Il2CppReferenceArray<StatConfiguration>(src.Select(x => x.Adapt<StatConfiguration>()).ToArray()));
|
|
}
|
|
|
|
private static void CacheChangePatchConfigs()
|
|
{
|
|
if (AssetChangesConfig.AGRoomChanges.Value) AGRoomChanges.config.Get();
|
|
if (GameManagerConfig.AnyGameFreeSpawn.Value) GameFreeSpawns.config.Get();
|
|
if (GameManagerConfig.StaticGameConfig.Value) GameConfigurator.config.Get();
|
|
}
|
|
} |