Пример #1
0
        /// <summary>
        /// Called when a game level is loaded. If applicable, activates the Snooper mod
        /// for the loaded level.
        /// </summary>
        ///
        /// <param name="mode">The <see cref="LoadMode"/> a game level is loaded in.</param>
        public override void OnLevelLoaded(LoadMode mode)
        {
            switch (mode)
            {
            case LoadMode.LoadGame:
            case LoadMode.NewGame:
            case LoadMode.LoadScenario:
            case LoadMode.NewGameFromScenario:
                break;

            default:
                return;
            }

            IPatch[] patches =
            {
                WorldInfoPanelPatches.UpdateBindings,
                HumanAIPatches.StartMoving1,
                HumanAIPatches.StartMoving2,
                CargoTruckAIPatches.SetTarget,
            };

            patcher = new MethodPatcher(HarmonyId, patches);

            HashSet <IPatch> patchedMethods = patcher.Apply();

            if (patchedMethods.Count != patches.Length)
            {
                Debug.LogError("The 'Snooper' mod failed to perform method redirections");
                patcher.Revert();
                return;
            }

            WorldInfoPanelPatches.CitizenInfoPanel        = CustomCitizenInfoPanel.Enable();
            WorldInfoPanelPatches.TouristInfoPanel        = CustomTouristInfoPanel.Enable();
            WorldInfoPanelPatches.CitizenVehicleInfoPanel = CustomCitizenVehicleInfoPanel.Enable();
            WorldInfoPanelPatches.ServiceVehicleInfoPanel = CustomCityServiceVehicleInfoPanel.Enable();
        }
Пример #2
0
        /// <summary>Enables the vehicle info panel customization. Can return null on failure.</summary>
        /// <returns>An instance of the <see cref="CustomCitizenVehicleInfoPanel"/> class that can be used for disabling
        /// the customization, or null when the customization fails.</returns>
        public static CustomCitizenVehicleInfoPanel Enable()
        {
            var result = new CustomCitizenVehicleInfoPanel(GameInfoPanelName);

            return(result.Initialize() ? result : null);
        }