forked from zombieb/undead-universal-patch-il2cpp
INTERNAL REWRITE! server configs
This commit is contained in:
133
Core/Init.cs
Normal file
133
Core/Init.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using Mapster;
|
||||
using undead_universal_patch_il2cpp.Core.Config;
|
||||
using undead_universal_patch_il2cpp.Core.CustomRecNet.CustomEmotes;
|
||||
using undead_universal_patch_il2cpp.Core.UndeadGameManager;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Core;
|
||||
|
||||
public class Initialization
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Util.LocalInstanceGuid = Guid.NewGuid().ToString();
|
||||
|
||||
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())
|
||||
UniversalPatchPlugin.Log.LogInfo($"- {method.ToString()}");
|
||||
UniversalPatchPlugin.Log.LogInfo("PATCH LIST END =========================");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CacheChangePatchConfigs();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogError($"Could not load change patches: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void CacheChangePatchConfigs()
|
||||
{
|
||||
if (GameManagerConfig.AnyGameFreeSpawn.Value) GameFreeSpawns.config.Get();
|
||||
if (GameManagerConfig.StaticGameConfig.Value) GameConfigurator.config.Get();
|
||||
}
|
||||
|
||||
private static void AttachGameObjects()
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogInfo("Attaching game objects");
|
||||
UniversalPatchPlugin.Instance.AddComponent<CustomEmotes>();
|
||||
}
|
||||
|
||||
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." +
|
||||
"This 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.");
|
||||
|
||||
ServerPatchesConfig.CustomEmotes = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomEmotes", ServerPatchesConfigDefaults.CustomEmotes,
|
||||
"Modify the game's emote text with a configuration from the server. Requires a custom server.");
|
||||
|
||||
GameManagerConfig.AnyGameFreeSpawn = UniversalPatchPlugin.Instance.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 = UniversalPatchPlugin.Instance.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 = UniversalPatchPlugin.Instance.Config.Bind("Photon", "PatchPhotonIds", PhotonConfigDefaults.PatchPhotonIds,
|
||||
"Patch Photon configuration.");
|
||||
PhotonConfig.PunLogging = UniversalPatchPlugin.Instance.Config.Bind("Photon", "PunLogging", PhotonConfigDefaults.PunLogging,
|
||||
"Enable all logging sent by Photon/PUN/Voice (useful for server debugging)");
|
||||
PhotonConfig.SelfHosted = UniversalPatchPlugin.Instance.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 = 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 application (either 'Master' or 'Game')");
|
||||
PhotonConfig.VoiceAppID = UniversalPatchPlugin.Instance.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 = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ServerAddress", PhotonConfigDefaults.ServerAddress,
|
||||
"Address of the Photon master server (ignored if not using self-hosted)");
|
||||
PhotonConfig.ServerPort = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ServerPort", PhotonConfigDefaults.ServerPort,
|
||||
"Photon master server UDP port (ignored if not using self-hosted)");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user