public static void Prefix()
 {
     try
     {
         DefsUtil.Update();
     }
     catch
     {
         Log.Error("[Configurable Maps] failed to apply map settings.");
     }
 }
        public static void Prefix(MapParent parent, MapGeneratorDef mapGenerator, IEnumerable <GenStepWithParams> extraGenStepDefs)
        {
            const float MAX_MTN_VALUE = 0.7f;

            buMtnValue   = null;
            buWaterValue = null;

            if (shouldOverrideSettings(parent, mapGenerator, extraGenStepDefs))
            {
                buMtnValue   = MapSettings.Mountain;
                buWaterValue = MapSettings.Water;

                float value = buMtnValue.GetMultiplier();
                if (value > MAX_MTN_VALUE)
                {
                    Log.Warning($"[Configurable Maps] For quest maps, capping mountain density to {MAX_MTN_VALUE}");
                    MapSettings.Mountain = new RandomizableMultiplier0();
                    MapSettings.Mountain.SetIsRandom(false);
                    MapSettings.Mountain.SetMultiplier(MAX_MTN_VALUE);
                }

                value = buWaterValue.GetMultiplier();
                if (value > MAX_MTN_VALUE)
                {
                    Log.Warning($"[Configurable Maps] For quest maps, capping water density to {MAX_MTN_VALUE}");
                    MapSettings.Water = new RandomizableMultiplier0();
                    MapSettings.Water.SetIsRandom(false);
                    MapSettings.Water.SetMultiplier(MAX_MTN_VALUE);
                }

                //DefsUtil.Enable = false;
                //Log.Message("[Configurable Maps] this tile has a quest on it. Disabling map modifications.");
                //DefsUtil.EnableMountainSettings = false;
                //Log.Message("[Configurable Maps] fertility, water, and mountain settings will be disabled for this map since it has a quest on it.");
            }

            try
            {
                DefsUtil.Update();
            }
            catch
            {
                Log.Error("[Configurable Maps] failed to apply map settings.");
            }

            GenStep_RockChunks_GrowLowRockFormationFrom.ChunkLevel = MapSettings.ChunkLevel;
            if (MapSettings.ChunkLevel == ChunkLevelEnum.Random)
            {
                GenStep_RockChunks_GrowLowRockFormationFrom.ChunkLevel = (ChunkLevelEnum)Rand.RangeInclusive(0, Enum.GetNames(typeof(ChunkLevelEnum)).Length - 1);
            }
        }
        public static void Postfix()
        {
            //DefsUtil.EnableMountainSettings = true;
            //DefsUtil.Enable = true;
            if (buMtnValue != null)
            {
                MapSettings.Mountain = buMtnValue;
                buMtnValue           = null;
            }
            if (buWaterValue != null)
            {
                MapSettings.Water = buWaterValue;
                buWaterValue      = null;
            }

            DefsUtil.Restore();
        }
Example #4
0
        public override void ExposeData()
        {
            if (WorldSettings == null)
            {
                WorldSettings = new WorldSettings();
            }
            if (MapSettings == null)
            {
                MapSettings = new MapSettings();
            }

            base.ExposeData();
            Scribe_Deep.Look(ref WorldSettings, "WorldSettings");
            Scribe_Deep.Look(ref MapSettings, "MapSettings");

            if (Scribe.mode == LoadSaveMode.Saving)
            {
                CurrentSettings.ApplySettings(cgFieldValues);
            }

            DefsUtil.Restore();
        }