Example #1
0
        public void ResetAllSettings()
        {
            Log.Message("NightVision: Defaulting Settings");

            CustomCapsEnabled = false;

            MultiplierCaps = new FloatRange(
                Constants.DEFAULT_MIN_CAP,
                Constants.DEFAULT_MAX_CAP
                );

            NVEnabledForCE = true;
            NVGameComponent.FlareRaidIsEnabled          = true;
            LightModifiersBase.PSLightModifiers.Offsets = LightModifiersBase.PSLightModifiers.DefaultOffsets.ToArray();

            LightModifiersBase.NVLightModifiers.Offsets = LightModifiersBase.NVLightModifiers.DefaultOffsets.ToArray();

            Settings.CombatStore.LoadDefaultSettings();

            Log.Message("NightVision.Storage.ResetAllSettings: Clearing Dictionaries");
            RaceLightMods              = null;
            HediffLightMods            = null;
            NVApparel                  = null;
            AllEyeCoveringHeadgearDefs = null;
            AllEyeHediffs              = null;
            AllSightAffectingHediffs   = null;
            Log.Message("NightVision.Storage.ResetAllSettings: Rebuilding Dictionaries");
            var initialiser = new Initialiser();

            initialiser.FindDefsToAddNightVisionTo();

            Settings.Cache.Reset();
            FieldClearer.ResetSettingsDependentFields();
        }
Example #2
0
        /// <summary>
        ///     Sets new settings
        ///     Clears all cached stuff
        ///     Runs when opening the settings menu and when closing it
        /// </summary>
        public void DoPreWriteTasks()
        {
            // this check is required because this method is run on opening the menu
            if (CacheInited)
            {
                FieldClearer.ResetSettingsDependentFields();

                var settingsStore = Settings.Store;

                if (settingsStore.CustomCapsEnabled)
                {
                    if (MinCache.HasValue)
                    {
                        settingsStore.SetMinMultiplierCap(MinCache.Value);
                    }

                    if (MaxCache.HasValue)
                    {
                        settingsStore.SetMaxMultiplierCap(MaxCache.Value);
                    }
                }

                SetLightModifier(LightModifiersBase.NVLightModifiers, NVZeroCache, NVFullCache);
                SetLightModifier(LightModifiersBase.PSLightModifiers, PSZeroCache, PSFullCache);

                Classifier.ZeroLightTurningPoints = null;
                Classifier.FullLightTurningPoint  = null;

                MinCache    = null;
                MaxCache    = null;
                NVZeroCache = null;
                NVFullCache = null;
                PSZeroCache = null;
                PSFullCache = null;
            }

            CacheInited = false;
            _allHediffsCache?.Clear();
            _headgearCache?.Clear();

            SettingsHelpers.TipStringHolder.Clear();
            Mod.Settings.ClearDrawVariables();


            if (Current.ProgramState == ProgramState.Playing)
            {
                SetDirtyAllComps();
            }
        }