Exemplo n.º 1
0
        public R2API()
        {
            Logger     = base.Logger;
            ModManager = new DetourModManager();
            AddHookLogging();
            CheckForIncompatibleAssemblies();
            CheckR2APIMonomodPatch();

            Environment.SetEnvironmentVariable("MONOMOD_DMD_TYPE", "Cecil");

            On.RoR2.RoR2Application.UnitySystemConsoleRedirector.Redirect += orig => { };

            var submoduleHandler = new APISubmoduleHandler(GameBuild, Logger);

            loadedSubmodules = submoduleHandler.LoadRequested();

            //Currently disabled until manifest v2
            //ModListAPI.Init();

            RoR2Application.isModded = true;

            // Temporary fix as the new quickplay button currently don't have the DisableIfGameModded Script attached to it
            On.RoR2.UI.QuickPlayButtonController.Start += (orig, self) => {
                orig(self);
                self.gameObject.SetActive(false);
            };

            On.RoR2.DisableIfGameModded.OnEnable += (orig, self) => {
                // TODO: If we can enable quick play without regrets, uncomment.
                //if (self.name == "Button, QP")
                //    return;

                self.gameObject.SetActive(false);
            };

            SteamworksClientManager.onLoaded += () => {
                var buildId =
                    SteamworksClientManager.instance.GetFieldValue <Client>("steamworksClient").BuildId;

                if (GameBuild == buildId)
                {
                    return;
                }

                Logger.LogWarning($"This version of R2API was built for build id \"{GameBuild}\", you are running \"{buildId}\".");
                Logger.LogWarning("Should any problems arise, please check for a new version before reporting issues.");
            };

            // Make sure that modded dedicated servers are recognizable from the server browser
            On.RoR2.SteamworksServerManager.UpdateHostName += (orig, self, hostname) => {
                orig(self, $"[MOD] {hostname}");
                var server = ((SteamworksServerManager)self).GetFieldValue <Server>("steamworksServer");
                server.GameTags = "mod," + server.GameTags;
            };

            SurvivorAPI.SafetyCheck();
        }
Exemplo n.º 2
0
 internal static void InitializeHooks()
 {
     SurvivorAPI.InitHooks();
 }