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:
29
Core/Init.cs
29
Core/Init.cs
@@ -4,8 +4,10 @@ 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;
|
||||
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 UnityEngine;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Core;
|
||||
|
||||
@@ -13,8 +15,6 @@ public class Initialization
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Util.LocalInstanceGuid = Guid.NewGuid().ToString();
|
||||
|
||||
AddMapsterGlobalTypeConfigs();
|
||||
FetchConfigurations();
|
||||
AttachGameObjects();
|
||||
@@ -55,7 +55,9 @@ public class Initialization
|
||||
private static void AttachGameObjects()
|
||||
{
|
||||
UniversalPatchPlugin.Log.LogInfo("Attaching game objects");
|
||||
UniversalPatchPlugin.Instance.AddComponent<CustomEmotes>();
|
||||
|
||||
if (ServerPatchesConfig.CustomEmotes.Value) UniversalPatchPlugin.Instance.AddComponent<CustomEmotes>();
|
||||
UniversalPatchPlugin.Instance.AddComponent<CustomPhoton>();
|
||||
}
|
||||
|
||||
private static void FetchConfigurations()
|
||||
@@ -70,7 +72,7 @@ public class Initialization
|
||||
"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.");
|
||||
"\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,
|
||||
@@ -83,6 +85,10 @@ public class Initialization
|
||||
|
||||
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.");
|
||||
ServerPatchesConfig.CustomPhoton = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomPhoton", ServerPatchesConfigDefaults.CustomPhoton,
|
||||
"Patch 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.");
|
||||
|
||||
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");
|
||||
@@ -103,9 +109,14 @@ public class Initialization
|
||||
"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)");
|
||||
"Address of the Photon target 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)");
|
||||
"Photon target server port (ignored if not using self-hosted)." +
|
||||
"\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 target port (ignored if not using self-hosted)." +
|
||||
"\n0: UDP, 1: TCP;" +
|
||||
"\nWebSockets are not supported by Photon in this build.");
|
||||
|
||||
NameserverConfig.Rewrite = UniversalPatchPlugin.Instance.Config.Bind("Nameserver", "Rewrite", NameserverConfigDefaults.Rewrite,
|
||||
"Enable/disable rewriting the URL for nameserver requests.");
|
||||
@@ -118,9 +129,11 @@ public class Initialization
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user