예제 #1
0
        private static void UpdateGenStepScatterer(string genStepDefName, RandomizableMultiplier rm, List <Pair <GenStep_Scatterer, ScattererValues> > scatterers, StringBuilder sb)
        {
            try
            {
                float      m = rm.GetMultiplier();
                GenStepDef d = DefDatabase <GenStepDef> .GetNamed(genStepDefName, false);

                /*if (d?.genStep is GenStep_PreciousLump pl)
                 * {
                 *  PreciousLump = new Pair<GenStep_PreciousLump, FloatRange>(pl, new FloatRange(pl.totalValueRange.min, pl.totalValueRange.max));
                 *  pl.totalValueRange.min *= m;
                 *  pl.totalValueRange.max *= m;
                 *  sb.AppendLine($"- {genStepDefName}.totalValueRange = {pl.totalValueRange} -- {pl.forcedLumpSize}");
                 * }
                 * else*/
                if (d?.genStep is GenStep_Scatterer rs)
                {
                    Scatterers.Add(new Pair <GenStep_Scatterer, ScattererValues>(rs, new ScattererValues(rs.countPer10kCellsRange)));
                    rs.countPer10kCellsRange.min *= m;
                    rs.countPer10kCellsRange.max *= m;
                    sb.AppendLine($"- {genStepDefName}.countPer10kCellsRange = {rs.countPer10kCellsRange}");
                }
                else
                {
                    Log.Warning($"[Configurable Maps] unable to patch {genStepDefName}");
                }
            }
            catch
            {
                Log.Error("[Configurable Maps] failed to update scatterer " + genStepDefName);
            }
        }
예제 #2
0
 private static void UpdateMineable(RandomizableMultiplier rm, List <Pair <ThingDef, float> > minability, StringBuilder sb)
 {
     try
     {
         if (rm.ThingDef != null)
         {
             Mineability.Add(new Pair <ThingDef, float>(rm.ThingDef, rm.ThingDef.building.mineableScatterCommonality));
             rm.ThingDef.building.mineableScatterCommonality = rm.GetMultiplier();
             sb.AppendLine($"- {rm.ThingDefName}.mineableScatterCommonality = {rm.ThingDef.building.mineableScatterCommonality}");
         }
         else
         {
             Log.Warning($"$[Configurable Maps] unable to patch {rm.ThingDefName}.");
         }
     }
     catch
     {
         Log.Error($"[Configurable Maps] failed to find and patch {rm.ThingDefName}");
     }
 }
예제 #3
0
        public static void Initialize()
        {
            if (Fertility == null)
            {
                Fertility = new RandomizableMultiplier0();
            }
            Fertility.DefaultValue = 0;
            Fertility.RandomMin    = -3;
            Fertility.RandomMax    = 3;

            if (Water == null)
            {
                Water = new RandomizableMultiplier0();
            }
            Water.DefaultValue = 0;
            Water.RandomMin    = -0.75f;
            Water.RandomMax    = 0.75f;

            var ms = MineableStuff.GetMineables();

            if (Mineables == null && ms != null && ms.Count > 0)
            {
                Mineables = new List <RandomizableMultiplier>(ms.Count);
                foreach (var m in ms)
                {
                    Mineables.Add(new RandomizableMultiplier()
                    {
                        ThingDef     = m,
                        ThingDefName = m.defName,
                        DefaultValue = m.building.mineableScatterCommonality,
                    });
                }
            }
            else if (!initMineables && ms.Count > 0)
            {
                initMineables = true;
                for (int i = Mineables.Count - 1; i >= 0; --i)
                {
                    var m = Mineables[i];
                    if (m.ThingDef == null && m.ThingDefName != "")
                    {
                        m.ThingDef = DefDatabase <ThingDef> .GetNamed(m.ThingDefName, false);

                        if (m.ThingDef == null)
                        {
                            Mineables.RemoveAt(i);
                            Log.Message($"[Configurable Maps] Unable to load mineable thing def {m.ThingDefName}");
                        }
                    }
                }
                foreach (var m in ms)
                {
                    bool found = false;
                    foreach (var r in Mineables)
                    {
                        found = r.ThingDefName == m.defName;
                        if (found)
                        {
                            r.ThingDef     = m;
                            r.DefaultValue = m.building.mineableScatterCommonality;
                            break;
                        }
                    }
                    if (!found)
                    {
                        Mineables.Add(new RandomizableMultiplier()
                        {
                            ThingDef     = m,
                            ThingDefName = m.defName
                        });
                    }
                }
            }

            if (Geysers == null)
            {
                Geysers = new RandomizableMultiplier();
            }
            Geysers.DefaultValue = 1;

            if (Mountain == null)
            {
                Mountain = new RandomizableMultiplier0();
            }
            Mountain.Max          = 1.4f;
            Mountain.DefaultValue = 0;
            Mountain.RandomMin    = -0.15f;
            Mountain.RandomMax    = 1.4f;

            if (AnimalDensity == null)
            {
                AnimalDensity = new RandomizableMultiplier();
            }
            AnimalDensity.RandomMax = 6;

            if (PlantDensity == null)
            {
                PlantDensity = new RandomizableMultiplier();
            }
            PlantDensity.RandomMax = 6;

            if (Ruins == null)
            {
                Ruins = new RandomizableMultiplier();
            }
            Ruins.RandomMax = 50f;

            if (Shrines == null)
            {
                Shrines = new RandomizableMultiplier();
            }
            Shrines.RandomMax = 50;

            if (AncientPipelineSection == null)
            {
                AncientPipelineSection = new RandomizableMultiplier();
            }
            AncientPipelineSection.RandomMax = 50;

            if (AncientJunkClusters == null)
            {
                AncientJunkClusters = new RandomizableMultiplier();
            }
            AncientJunkClusters.RandomMax = 50;

            if (OreLevels == null)
            {
                OreLevels = new RandomizableMultiplier();
            }
            OreLevels.DefaultValue = 1;
            OreLevels.Min          = 0;
            OreLevels.RandomMin    = 0;
            OreLevels.RandomMax    = 6;

            int resetCount = 0;

            if (Mineables != null)
            {
                foreach (var m in Mineables)
                {
                    if (m.GetMultiplier() == 1.0f)
                    {
                        ++resetCount;
                    }
                }
                if (resetCount > 3)
                {
                    Log.Message("[Configurable Maps] Correcting default values for mineables to their default values.");
                    foreach (var m in Mineables)
                    {
                        m.SetMultiplier(m.DefaultValue);
                    }
                }
            }

            resetCount  = 0;
            resetCount += (Fertility?.GetMultiplier() == 1f) ? 1 : 0;
            resetCount += (Water?.GetMultiplier() == 1f) ? 1 : 0;
            resetCount += (Mountain?.GetMultiplier() == 1f) ? 1 : 0;
            if (resetCount >= 2)
            {
                Fertility.SetMultiplier(Fertility.DefaultValue);
                Water.SetMultiplier(Water.DefaultValue);
                Mountain.SetMultiplier(Mountain.DefaultValue);
                Log.Message("[Configurable Maps] Correcting default values for Fertility, Water, and Mountain to their default values.");
            }
        }