/// <summary>
        /// Called by the game when the mod is enabled.
        /// </summary>
        public void OnEnabled()
        {
            // Apply Harmony patches via Cities Harmony.
            // Called here instead of OnCreated to allow the auto-downloader to do its work prior to launch.
            HarmonyHelper.DoOnHarmonyReady(() => Patcher.PatchAll());

            // Load settings file.
            SettingsUtils.LoadSettings();

            // Populate (legacy) Datastore from configuration file.
            // Make sure this happens before loading the new configuration file, which will overwrite any settings here.
            // This establishes the correct priority (new over legacy).
            XMLUtilsWG.ReadFromXML();

            // Attaching options panel event hook - check to see if UIView is ready.
            if (UIView.GetAView() != null)
            {
                // It's ready - attach the hook now.
                OptionsPanel.OptionsEventHook();
            }
            else
            {
                // Otherwise, queue the hook for when the intro's finished loading.
                LoadingManager.instance.m_introLoaded += OptionsPanel.OptionsEventHook;
            }
        }
Example #2
0
        /// <summary>
        /// Called by the game when the mod is enabled.
        /// </summary>
        public void OnEnabled()
        {
            // Apply Harmony patches via Cities Harmony.
            // Called here instead of OnCreated to allow the auto-downloader to do its work prior to launch.
            HarmonyHelper.DoOnHarmonyReady(() => Patcher.PatchAll());

            // Load the settings file.
            ZoningModSettingsFile.LoadSettings();
        }
 public void OnEnabled()
 {
     HarmonyHelper.DoOnHarmonyReady(() => Patcher.PatchAll());
     Enabled = true;
     if (Loading != null && Loading.loadingComplete)
     {
         SubstituteTextureManager.RegenerateCache();
     }
 }
Example #4
0
        //static LoadOrderMod() => Log.Debug("Static Ctor "   + Environment.StackTrace);
        //public LoadOrderMod() => Log.Debug("Instance Ctor " + Environment.StackTrace);

        public void OnEnabled()
        {
            try {
                Log.Called();
                Util.LoadOrderUtil.ApplyGameLoggingImprovements();

                var args = Environment.GetCommandLineArgs();
                Log.Info("command line args are: " + string.Join(" ", args));

                Log.ShowGap = true;
#if DEBUG
                Log.Buffered = true;
#else
                Log.Buffered = true;
#endif

                //Log.Debug("Testing StackTrace:\n" + new StackTrace(true).ToString(), copyToGameLog: true);
                //KianCommons.UI.TextureUtil.EmbededResources = false;
                //HelpersExtensions.VERBOSE = false;
                //foreach(var p in ColossalFramework.Plugins.PluginManager.instance.GetPluginsInfo()) {
                //    string savedKey = p.name + p.modPath.GetHashCode().ToString() + ".enabled";
                //    Log.Debug($"plugin info: savedKey={savedKey} cachedName={p.name} modPath={p.modPath}");
                //}
                CheckPatchLoader();

                HarmonyHelper.DoOnHarmonyReady(() => {
                    //HarmonyLib.Harmony.DEBUG = true;
                    HarmonyUtil.InstallHarmony(HARMONY_ID, null, null); // continue on error.
                });
                SceneManager.sceneLoaded        += OnSceneLoaded;
                SceneManager.activeSceneChanged += OnActiveSceneChanged;

                LoadingManager.instance.m_introLoaded += LoadOrderUtil.TurnOffSteamPanels;
                LoadingManager.instance.m_introLoaded += CheckPatchLoader;

                LoadOrderUtil.TurnOffSteamPanels();

                bool introLoaded = ContentManagerUtil.IsIntroLoaded;
                if (introLoaded)
                {
                    CacheUtil.CacheData();
                }
                else
                {
                    LoadingManager.instance.m_introLoaded += CacheUtil.CacheData;
                }


                if (!Settings.ConfigUtil.Config.IgnoranceIsBliss)
                {
                    CheckSubsUtil.RegisterEvents();
                }
                Log.Flush();
            } catch (Exception ex) {
                Log.Exception(ex);
            }
        }
Example #5
0
        public void OnEnabled()
        {
            Log.InfoFormat(
                "TM:PE enabled. Version {0}, Build {1} {2} for game version {3}.{4}.{5}-f{6}",
                VersionString,
                Assembly.GetExecutingAssembly().GetName().Version,
                BRANCH,
                GAME_VERSION_A,
                GAME_VERSION_B,
                GAME_VERSION_C,
                GAME_VERSION_BUILD);
            Log.InfoFormat(
                "Enabled TM:PE has GUID {0}",
                Assembly.GetExecutingAssembly().ManifestModule.ModuleVersionId);

            // check for incompatible mods
            if (UIView.GetAView() != null)
            {
                // when TM:PE is enabled in content manager
                CheckForIncompatibleMods();
            }
            else
            {
                // or when game first loads if TM:PE was already enabled
                LoadingManager.instance.m_introLoaded += CheckForIncompatibleMods;
            }

            // Log Mono version
            Type monoRt = Type.GetType("Mono.Runtime");

            if (monoRt != null)
            {
                MethodInfo displayName = monoRt.GetMethod(
                    "GetDisplayName",
                    BindingFlags.NonPublic | BindingFlags.Static);
                if (displayName != null)
                {
                    Log.InfoFormat("Mono version: {0}", displayName.Invoke(null, null));
                }
            }

            Log._Debug("Scene is " + SceneManager.GetActiveScene().name);

            Instance        = this;
            InGameHotReload = InGame();

            HarmonyHelper.EnsureHarmonyInstalled();

#if DEBUG
            const bool installHarmonyASAP = false; // set true for fast testing
            if (installHarmonyASAP)
            {
                HarmonyHelper.DoOnHarmonyReady(delegate() { Patcher.Create().Install(); });
            }
#endif
        }
Example #6
0
 public void OnEnabled()
 {
     HarmonyHelper.DoOnHarmonyReady(Patcher.PatchAll);
     if (SteamVRDetector.IsRunning)
     {
         var context = new CSLVRContext();
         VRManager.Create <CSLVRInterpreter>(context);
         VR.Manager.SetMode <CSLMode>();
     }
 }
Example #7
0
        public void OnEnabled()
        {
            NetworkSkinManager.Ensure();

            HarmonyHelper.DoOnHarmonyReady(NetworkSkinsPatcher.Install);

            if (LoadingManager.exists && LoadingManager.instance.m_loadingComplete)
            {
                Install();
            }
        }
Example #8
0
 public static void Patch()
 {
     Logger.LogDebug($"{nameof(Patcher)}.{nameof(Patch)}");
     HarmonyHelper.DoOnHarmonyReady(() => Begin());
 }
Example #9
0
 public void OnEnabled()
 {
     HarmonyHelper.EnsureHarmonyInstalled();
     HarmonyHelper.DoOnHarmonyReady(() => HarmonyUtil.InstallHarmony(HARMONY_ID));
 }
        public void OnEnabled()
        {
            HarmonyHelper.DoOnHarmonyReady(() => Patcher.PatchAll());

            TopSwayPosition = new Vector3(0.0f, 0.0f, 0.0f);
        }
Example #11
0
 public static void Patch() => HarmonyHelper.DoOnHarmonyReady(() => Begin());
 public void OnEnabled()
 {
     ModConfig.ReadConfig();
     HarmonyHelper.DoOnHarmonyReady(() => DynamicAssetSorter.PatchAll());
 }
Example #13
0
 public void OnEnabled()
 {
     HarmonyHelper.DoOnHarmonyReady(Patcher.Patch);
 }
 public void OnEnabled()
 {
     UnityEngine.Debug.Log("CSL Commuter Destination enabled");
     HarmonyHelper.DoOnHarmonyReady(Patcher.Patch);
 }