using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using HarmonyLib;
namespace undead_universal_patch;
[BepInPlugin("dev.proxnet.recroom.universalpatch.noneac.mono", "Undead Universal Patch", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
public static readonly ManualLogSource Log = BepInEx.Logging.Logger.CreateLogSource("UUPatch");
Harmony _hi = new("dev.proxnet.recroom.universalpatch.noneac.mono");
private void OnDestroy()
{
Log.LogInfo("Destroying.");
_hi.UnpatchSelf();
}
private void Awake()
{
// CONFIGURATION
GameserverConfig.UseGameserverHost = Config.Bind("Gameserver", "UseGameserverHost", GameserverConfigDefaults.UseGameserverHost,
"Whether to rewrite outbound HTTP requests with our host or not.");
GameserverConfig.SecureProtocol = Config.Bind("Gameserver", "SecureProtocol", GameserverConfigDefaults.SecureProtocol,
"Whether to use 'http' or 'https' for our gameserver host." +
"\nUsed by legacy MoTD patch as well as the gameserver patch.");
GameserverConfig.Host = Config.Bind("Gameserver", "Host", GameserverConfigDefaults.Host,
"The host to use for our gameserver." +
"\nExamples include 'server.example.com', 'test.example.com:3939', and '127.0.2.5:19502'." +
"\nUsed by legacy MoTD patch as well as the gameserver patch.");
GameserverConfig.UseSocketHost = Config.Bind("Gameserver", "UseSocketHost", GameserverConfigDefaults.UseSocketHost,
"Flag that controls the usage of SocketHost and SecureSocketProtocol." +
"\nWhen enabled, the WebSocket URL will be modified to use the SocketHost and" +
"\nthe appropriate protocol ('wss' or 'ws')." +
"\nWhen disabled, the WebSocket URL will use the same host and secure status as the web server." +
"\nPaths are completely unchanged.");
GameserverConfig.SecureSocketProtocol = Config.Bind("Gameserver", "SecureSocketProtocol", GameserverConfigDefaults.SecureSocketProtocol,
"The secure protocol status to use ('wss' or 'ws').");
GameserverConfig.SocketHost = Config.Bind("Gameserver", "SocketHost", GameserverConfigDefaults.SocketHost,
"The WebSocket host to use.");
GenericConfig.DisableAmplitude = Config.Bind("Generic", "DisableAmplitude", GenericConfigDefaults.DisableAmplitude,
"Many builds use Amplitude to log analytics." +
"\nYou can prevent the game from sending analytics with this bool.");
GenericConfig.DisableGoogleAnalytics = Config.Bind("Generic", "DisableGoogleAnalytics", GenericConfigDefaults.DisableGoogleAnalytics,
"Some legacy builds use Google Analytics rather than Amplitude." +
"\nYou can prevent the game from sending analytics with this bool." +
"\nThe WWW rewrite patch must validate for this to work.");
/*GenericConfig.UnhideEditorRooms = Config.Bind("Generic", "UnhideEditorRooms", GenericConfigDefaults.UnhideEditorRooms,
"Some rooms may have the flag 'IsEditorOnly' set, which prevents you from switching to that room." +
"\nUse this flag to always set this value to 'false', allowing you to switch to any internal activity.");*/
GenericConfig.IsNameserver = Config.Bind("Generic", "IsNameserver", GenericConfigDefaults.IsNameserver, "" +
"Enable if you use a nameserver. This will disable URL rewriting for all WebSocket, WWW, and UWR patches.");
GenericConfig.LogAllRequests = Config.Bind("Generic", "LogAllRequests", GenericConfigDefaults.LogAllRequests,
"Log all HTTP requests sent by the game. Applies to all HTTP patches," +
"\nincluding WWWPatch, UWRPatch, and BestHTTPPatch.");
PhotonConfig.PatchPhotonIds = Config.Bind("Photon", "PatchPhotonIds", PhotonConfigDefaults.PatchPhotonIds,
"Enable/disable changing the target IDs in PhotonServerSettings." +
"\nCustom server settings are not yet supported.");
PhotonConfig.AppID = Config.Bind("Photon", "AppID", PhotonConfigDefaults.AppID,
"The new target (PUN) App ID from the Photon dashboard.");
PhotonConfig.VoiceAppID = Config.Bind("Photon", "VoiceAppID", PhotonConfigDefaults.VoiceAppID,
"The new target Voice App ID from the Photon dashboard.");
PhotonConfig.PatchEvent = Config.Bind("Photon", "PatchEvent", PhotonConfigDefaults.PatchEvent,
"The event on which to patch Photon. You may need to patch Photon" +
"\nat different times, depending on your build's PhotonServerSettings implementation." +
"\nIf your log throws errors about custom authentication related to Photon, and you know" +
"\nthat your Photon IDs are specified above (and the patch is enabled)," +
"\nor you get Photon patch errors, then change this to one of these values:" +
"\n'Awake': When this plugin loads." +
"\n'SocketConnect': When the WebSocket connects." +
"\n'Load': When PhotonNetwork loads PhotonServerSettings. (recommended, default)" +
"\n'Nameserver': When the game contacts the nameserver. (also recommended)");
NameserverConfig.UseNameserverHost = Config.Bind("Nameserver", "UseNameserverHost", NameserverConfigDefaults.UseNameserverHost,
"Whether to rewrite outbound HTTP requests to 'ns.rec.net' to our host or not." +
"\nYou must enable GenericConfig.IsNameserver as well.");
NameserverConfig.SecureProtocol = Config.Bind("Nameserver", "SecureProtocol", NameserverConfigDefaults.SecureProtocol,
"Whether to use 'http' or 'https' for our nameserver host.");
NameserverConfig.Host = Config.Bind("Nameserver", "Host", NameserverConfigDefaults.Host,
"The host to use for our nameserver." +
"\nYou can specify a custom path for the request with NameserverConfig.Path." +
"\nExamples of a host include 'server.example.com', 'test.example.com:3939', and '127.0.2.5:19502'.");
NameserverConfig.Path = Config.Bind("Nameserver", "Path", NameserverConfigDefaults.Path,
"The path to use for the nameserver request." +
"\nExamples include '/ns/2019', '/ns', '/nameserver'. Query cannot be specified here.");
// END CONFIGURATION
Log.LogInfo("Finding appropriate patches ...");
// Run all applicable patches
_hi.PatchAll();
Log.LogInfo("PATCH LIST START ===========");
foreach (var method in _hi.GetPatchedMethods()) Log.LogInfo($"- {method.ToString()}");
Log.LogInfo("PATCH LIST END ===========");
//GenericUtils.PrintAllNamespaces();
if (PhotonConfig.PatchEvent.Value == "Awake" && PhotonConfig.PatchPhotonIds.Value) Patches.Photon.Patch();
}
}