forked from zombieb/undead-universal-patch-il2cpp
156 lines
10 KiB
C#
156 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
|
using Mapster;
|
|
using undead_universal_patch_il2cpp.Core.Config;
|
|
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet.CheatManager;
|
|
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet.CustomEmotes;
|
|
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet.CustomPhoton;
|
|
using undead_universal_patch_il2cpp.Core.Content.UndeadGameManager;
|
|
using undead_universal_patch_il2cpp.Patches.Video;
|
|
using UnityEngine;
|
|
|
|
namespace undead_universal_patch_il2cpp.Core;
|
|
|
|
public class Initialization
|
|
{
|
|
public static void Initialize()
|
|
{
|
|
AddMapsterGlobalTypeConfigs();
|
|
FetchConfigurations();
|
|
AttachGameObjects();
|
|
|
|
try
|
|
{
|
|
UniversalPatchPlugin.Instance.HarmonyInstance.PatchAll();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
UniversalPatchPlugin.Log.LogError($"--------> PATCH ERROR! Please report this in the gitea repo!\n{ex}");
|
|
}
|
|
|
|
if (GenericConfig.PatchDebug.Value)
|
|
{
|
|
UniversalPatchPlugin.Log.LogInfo("PATCH LIST START =========================");
|
|
foreach (var method in UniversalPatchPlugin.Instance.HarmonyInstance.GetPatchedMethods())
|
|
{
|
|
var paramStr = string.Join(" ", [.. method.GetParameters().Select(param => param.ParameterType.FullName)]);
|
|
UniversalPatchPlugin.Log.LogInfo($"- {method.DeclaringType.FullName} {method.Name}({paramStr})");
|
|
}
|
|
UniversalPatchPlugin.Log.LogInfo("PATCH LIST END =========================");
|
|
}
|
|
|
|
try
|
|
{
|
|
CacheChangePatchConfigs();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
UniversalPatchPlugin.Log.LogError($"Could not load change patches: {ex}");
|
|
}
|
|
}
|
|
|
|
private static void CacheChangePatchConfigs()
|
|
{
|
|
VideoTamperPatch.config.Get();
|
|
}
|
|
|
|
private static void AttachGameObjects()
|
|
{
|
|
UniversalPatchPlugin.Log.LogInfo("Attaching game objects");
|
|
|
|
if (ServerPatchesConfig.CustomEmotes.Value) UniversalPatchPlugin.Instance.AddComponent<CustomEmotes>();
|
|
UniversalPatchPlugin.Instance.AddComponent<CustomPhoton>();
|
|
if (ServerPatchesConfig.CustomKnownDlls.Value) UniversalPatchPlugin.Instance.AddComponent<CustomCheatManager>();
|
|
}
|
|
|
|
private static void FetchConfigurations()
|
|
{
|
|
GenericConfig.PatchDebug = UniversalPatchPlugin.Instance.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 = UniversalPatchPlugin.Instance.Config.Bind("Generic", "LogAllRequests", GenericConfigDefaults.LogAllRequests,
|
|
"Log all BestHTTP requests sent by the game.");
|
|
GenericConfig.VerboseRequestLogs = UniversalPatchPlugin.Instance.Config.Bind("Generic", "VerboseRequestLogs", GenericConfigDefaults.VerboseRequestLogs,
|
|
"Add additional request information to BestHTTPProxy logs. Requires LogAllRequest to be enabled.");
|
|
PatchConfig.CertificatePatch = UniversalPatchPlugin.Instance.Config.Bind("Generic", "CertificatePatch", PatchConfigDefaults.CertificatePatch,
|
|
"The game expects a certain certificate from rec.net when making HTTPS requests. Enable this to allow any valid certificate.");
|
|
PatchConfig.HilePatch = UniversalPatchPlugin.Instance.Config.Bind("Generic", "HilePatch", PatchConfigDefaults.HilePatch,
|
|
"The game will close after a short period of time if BepInEx is found. Enable to stop this from happening." +
|
|
"\nThis will also enable the AGRoomRuntimeConfig patch. See the README for more info.");
|
|
PatchConfig.SignalRHandshakeFix = UniversalPatchPlugin.Instance.Config.Bind("Generic", "SignalRHandshakeFix", PatchConfigDefaults.SignalRHandshakeFix,
|
|
"Replace apostrophes with quotes in the initial SignalR handshake.");
|
|
PatchConfig.ImageSignaturePatch = UniversalPatchPlugin.Instance.Config.Bind("Generic", "ImageSignaturePatch", PatchConfigDefaults.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)");
|
|
PatchConfig.RegistrationPatch = UniversalPatchPlugin.Instance.Config.Bind("Generic", "RegistrationPatch", PatchConfigDefaults.RegistrationPatch,
|
|
"Always disable the registration prompt.");
|
|
PatchConfig.AFKPatch = UniversalPatchPlugin.Instance.Config.Bind("Generic", "AFKPatch", PatchConfigDefaults.AFKPatch,
|
|
"Always present patch. Never get kicked to dorm for being AFK.");
|
|
|
|
ServerPatchesConfig.CustomEmotes = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomEmotes", ServerPatchesConfigDefaults.CustomEmotes,
|
|
"Modify the game's emote text with a configuration from the server.");
|
|
ServerPatchesConfig.CustomPhoton = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomPhoton", ServerPatchesConfigDefaults.CustomPhoton,
|
|
"Patch Photon ServerSettings values with a configuration from the server." +
|
|
"\nWhen the server fails to provide a valid configuration, values from the local config will be used." +
|
|
"\nPhoton.PatchPhotonIds must be enabled for this fallback to work.");
|
|
ServerPatchesConfig.CustomMarquee = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomMarquee", ServerPatchesConfigDefaults.CustomMarquee,
|
|
"Set custom text on the ^reccenter theater marquee.");
|
|
ServerPatchesConfig.CustomKnownDlls = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomKnownDlls", ServerPatchesConfigDefaults.CustomKnownDlls,
|
|
"Add items to the list of known DLLs.");
|
|
|
|
GameManagerConfig.AnyGameFreeSpawn = UniversalPatchPlugin.Instance.Config.Bind("GameManagerConfig", "AnyGameFreeSpawn", GameManagerConfigDefaults.AnyGameFreeSpawn,
|
|
$"Spawn in any valid player spawnpoint in specified games. See README.md");
|
|
GameManagerConfig.StaticGameConfig = UniversalPatchPlugin.Instance.Config.Bind("GameManagerConfig", "StaticGameConfig", GameManagerConfigDefaults.StaticGameConfig,
|
|
$"Set new configurations for built-in games. See README.md");
|
|
|
|
PhotonConfig.PatchPhotonIds = UniversalPatchPlugin.Instance.Config.Bind("Photon", "PatchPhotonIds", PhotonConfigDefaults.PatchPhotonIds,
|
|
"Patch Photon configuration.");
|
|
PhotonConfig.PunLogging = UniversalPatchPlugin.Instance.Config.Bind("Photon", "PunLogging", PhotonConfigDefaults.PunLogging,
|
|
"Enable all PUN/Voice logging (useful for server debugging)");
|
|
PhotonConfig.SelfHosted = UniversalPatchPlugin.Instance.Config.Bind("Photon", "IsSelfHosted", PhotonConfigDefaults.SelfHosted,
|
|
"When enabled, use a self-hosted ('OnPremises' or 'PhotonSocketServer') Photon server." +
|
|
"\nWhen disabled, AppID and VoiceAppID are sent to Photon Cloud and a cloud masterserver is used.");
|
|
PhotonConfig.AppID = UniversalPatchPlugin.Instance.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 Photon application (usually 'Master' without quotes)");
|
|
PhotonConfig.VoiceAppID = UniversalPatchPlugin.Instance.Config.Bind("Photon", "VoiceAppID", PhotonConfigDefaults.VoiceAppID,
|
|
"The new target Voice App ID from the Photon dashboard." +
|
|
"\nWhen self-hosting, this should be the same as AppID.");
|
|
PhotonConfig.ServerAddress = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ServerAddress", PhotonConfigDefaults.ServerAddress,
|
|
"Address of the Photon Master server (ignored if using cloud)");
|
|
PhotonConfig.ServerPort = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ServerPort", PhotonConfigDefaults.ServerPort,
|
|
"Photon Master server port (ignored if using cloud)." +
|
|
"\nYou can set this port to the matching protocol port from the server, e.g. 5055 for UDP, 9091 for WebSockets");
|
|
PhotonConfig.ConnectionProtocol = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ConnectionProtocol", PhotonConfigDefaults.ConnectionProtocol,
|
|
"Connection protocol to use when connecting to the Photon servers (ignored if using cloud)." +
|
|
"\n0: UDP, 1: TCP;" +
|
|
"\nWebSockets are not supported by Photon in this build. TCP is experimental and may cause instability/crashes.");
|
|
|
|
NameserverConfig.Rewrite = UniversalPatchPlugin.Instance.Config.Bind("Nameserver", "Rewrite", NameserverConfigDefaults.Rewrite,
|
|
"Enable/disable rewriting the URL for nameserver requests.");
|
|
NameserverConfig.NewUrl = UniversalPatchPlugin.Instance.Config.Bind("Nameserver", "NewUrl", NameserverConfigDefaults.NewUrl,
|
|
"The new full URL to use when sending a nameserver request.");
|
|
}
|
|
|
|
private static void AddMapsterGlobalTypeConfigs()
|
|
{
|
|
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()));
|
|
|
|
TypeAdapterConfig.GlobalSettings
|
|
.ForType<EmoteConfigDTO, RecRoom.AGUI.Expresso.ContextualEmotesConfig.ExpressoEmote>()
|
|
.Map(dest => dest.emoteUniqueName, source => source.UniqueName)
|
|
.Map(dest => dest.emoteText, source => source.NewText)
|
|
.Map(dest => dest.emoteRoomChatText, source => source.RoomChatText)
|
|
.Map(dest => dest.facialExpression, source => source.FacialExpression)
|
|
.Map(dest => dest.forceEmoteBubble, source => source.ForceEmoteBubble)
|
|
.Map(dest => dest.onlyBroadcastToTeam, source => source.OnlyBroadcastToTeam);
|
|
}
|
|
} |