Ejemplo n.º 1
0
        // supposed to be called before any other mod's code
        public static void init()
        {
            if (inited || !(inited = true))
            {
                return;
            }

            UnityHelper.createPersistentGameObject <ShutdownListener>($"{id}.ShutdownListener");

            // may be overkill to make it for all mods and from the start
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            try { File.Delete(Paths.modRootPath + tmpFileName); }
            catch (UnauthorizedAccessException) {}

            var manifest = SimpleJSON.Parse(File.ReadAllText(Paths.modRootPath + "mod.json"));

            _name = manifest["DisplayName"];
            bool needCheckVer = manifest["UpdateCheck"].AsBool;

#if DISABLE_VERSION_CHECK_IN_DEVBUILD
            if (needCheckVer && Consts.isDevBuild)
            {
                "Version check is disabled for dev build!".logDbg();
                needCheckVer = false;
            }
#endif
            if (needCheckVer)
            {
                Version currentVersion = new (manifest["Version"]);
                var     latestVersion  = VersionChecker.getLatestVersion(manifest["VersionURL"]);                                                    $"Latest version is {latestVersion}".logDbg();

                if (latestVersion > currentVersion)
                {
                    addCriticalMessage(updateMessage.format(currentVersion, latestVersion), color: "yellow");
                }
            }

            "Mod inited".logDbg();
        }
Ejemplo n.º 2
0
 public static GameObject createGameObject <T>(string name = "ConsoleCommands") where T : PersistentConsoleCommands
 {
     return(UnityHelper.createPersistentGameObject <T>(name));
 }