Ejemplo n.º 1
0
        public override void OnReleased()
        {
            base.OnReleased();
            if (OptionsWrapper <Options> .Options.ingameTrainMetroConverter)
            {
                Patch.Revert(_harmony);
            }

            if (!OptionsWrapper <Options> .Options.ghostMode)
            {
                _updater = null;
                if (Container == null)
                {
                    return;
                }
                UnityEngine.Object.Destroy(Container);
                Container = null;
                Redirector <RoadsGroupPanelDetour> .Revert();

                Redirector <DepotAIDetour> .Revert();

                Redirector <MetroTrainAI> .Revert();

                Redirector <PassengerTrainAIDetour> .Revert();
            }
        }
Ejemplo n.º 2
0
        public override void OnCreated(ILoading loading)
        {
            base.OnCreated(loading);
            _updater = null;
            LateBuildUpQueue.Clear();
            InstallAssets();
            if (Container == null)
            {
                Container         = new GameObject("MetroOverhaul").AddComponent <Initializer>();
                Container.AppMode = loading.currentMode;
            }
            if (loading.currentMode == AppMode.AssetEditor)
            {
                Redirector <RoadsGroupPanelDetour> .Deploy();
            }
            if (loading.currentMode == AppMode.Game)
            {
                Redirector <DepotAIDetour> .Deploy();

                if (OptionsWrapper <Options> .Options.improvedMetroTrainAi)
                {
                    Redirector <MetroTrainAIDetour> .Deploy();
                }
                if (OptionsWrapper <Options> .Options.improvedPassengerTrainAi)
                {
                    Redirector <PassengerTrainAIDetour> .Deploy();
                }
            }
        }
Ejemplo n.º 3
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);
            bool isVanilla = OptionsWrapper <Options> .Options.ghostMode;

            if (!isVanilla)
            {
                _cachedMode = mode;
                while (LateBuildUpQueue.Count > 0)
                {
                    try
                    {
                        LateBuildUpQueue.Dequeue().Invoke();
                    }
                    catch (Exception e)
                    {
                        UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Enable asset in Content Manager!", e.Message, false);
                    }
                }
                if (_updater == null)
                {
                    _updater = new AssetsUpdater();
                    _updater.UpdateExistingAssets(mode);
                }
            }
            AssetsUpdater.UpdateBuildingsMetroPaths(mode, isVanilla);
            if (!isVanilla)
            {
                if (OptionsWrapper <Options> .Options.metroUi)
                {
                    UIView.GetAView().AddUIComponent(typeof(MetroStationCustomizerUI));
                    UIView.GetAView().AddUIComponent(typeof(MetroTrackCustomizerUI));
                    UIView.GetAView().AddUIComponent(typeof(MetroAboveGroundStationCustomizerUI));
                }

                if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame || mode == LoadMode.NewGameFromScenario)
                {
                    SimulationManager.instance.AddAction(DespawnVanillaMetro);
                    var gameObject = new GameObject("MetroOverhaulUISetup");
                    gameObject.AddComponent <UpgradeSetup>();

                    var transportInfo = PrefabCollection <TransportInfo> .FindLoaded("Metro");

                    transportInfo.m_netLayer               = ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels;
                    transportInfo.m_stationLayer           = ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels;
                    transportInfo.m_secondaryLayer         = 9;
                    transportInfo.m_secondaryLineMaterial  = transportInfo.m_lineMaterial;
                    transportInfo.m_secondaryLineMaterial2 = transportInfo.m_lineMaterial2;
                }
            }
        }