Ejemplo n.º 1
0
        private void SmoothGenerated(Map map)
        {
            MapGenFloatGrid caves     = MapGenerator.Caves;
            List <IntVec3>  caveCells = new List <IntVec3>();

            foreach (IntVec3 cell in map.AllCells)
            {
                if (caves[cell] > 0f)
                {
                    caveCells.Add(cell);
                }
            }
            GenMorphology.Close(caveCells, 3, map);
            foreach (IntVec3 cell in map.AllCells)
            {
                if (cell.CloseToEdge(map, 3)) // Skip changing caves near the edge
                {
                    continue;
                }
                if (caveCells.Contains(cell)) // Cave spot on cell (cave should be there)
                {
                    if (caves[cell] <= 0f)    // No existing cave
                    {
                        caves[cell] = 1f;     // Add new cave spot
                    }
                }
                else // No cave spot on cell (cave should not be there)
                {
                    if (caves[cell] > 0f) // Old existing cave
                    {
                        caves[cell] = 0f; // Remove cave spot
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void Generate(Map map, GenStepParams parms)
        {
            if (!Find.Storyteller.difficulty.allowCaveHives)
            {
                return;
            }
            if (BetterInfestationsMod.settings == null)
            {
                return;
            }
            if (!BetterInfestationsMod.settings.allowHiveMapGen)
            {
                return;
            }
            MapGenFloatGrid caves     = MapGenerator.Caves;
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            float           num       = 0.7f;
            int             num2      = 0;

            rockCells.Clear();
            foreach (IntVec3 current in map.AllCells)
            {
                if (elevation[current] > num)
                {
                    rockCells.Add(current);
                }
                if (caves[current] > 0f)
                {
                    num2++;
                }
            }
            List <IntVec3> list = (from c in map.AllCells
                                   where map.thingGrid.ThingsAt(c).Any((Thing thing) => thing.Faction != null)
                                   select c).ToList();

            GenMorphology.Dilate(list, 50, map, null);
            HashSet <IntVec3> hashSet = new HashSet <IntVec3>(list);
            int num3 = GenMath.RoundRandom(num2 / 1000f);

            if (num3 > BetterInfestationsMod.settings.maxMapGenHives)
            {
                num3 = BetterInfestationsMod.settings.maxMapGenHives;
            }
            GenMorphology.Erode(rockCells, 10, map, null);
            possibleSpawnCells.Clear();
            for (int i = 0; i < rockCells.Count; i++)
            {
                if (caves[rockCells[i]] > 0f && !hashSet.Contains(rockCells[i]))
                {
                    possibleSpawnCells.Add(rockCells[i]);
                }
            }
            spawnedQueens.Clear();
            for (int j = 0; j < num3; j++)
            {
                TrySpawnHive(map);
            }
            spawnedQueens.Clear();
        }
Ejemplo n.º 3
0
        public override void Generate(Map map)
        {
            if (!Find.Storyteller.difficulty.allowCaveHives)
            {
                return;
            }
            CompProperties_TemperatureDamaged compProperties = ThingDefOf.Hive.GetCompProperties <CompProperties_TemperatureDamaged>();

            if (!compProperties.safeTemperatureRange.Includes(map.mapTemperature.OutdoorTemp))
            {
                return;
            }
            MapGenFloatGrid caves     = MapGenerator.Caves;
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            float           num       = 0.7f;
            int             num2      = 0;

            this.rockCells.Clear();
            foreach (IntVec3 current in map.AllCells)
            {
                if (elevation[current] > num)
                {
                    this.rockCells.Add(current);
                }
                if (caves[current] > 0f)
                {
                    num2++;
                }
            }
            int num3 = GenMath.RoundRandom((float)num2 / 1000f);

            GenMorphology.Erode(this.rockCells, 10, map, null);
            this.possibleSpawnCells.Clear();
            for (int i = 0; i < this.rockCells.Count; i++)
            {
                if (caves[this.rockCells[i]] > 0f)
                {
                    this.possibleSpawnCells.Add(this.rockCells[i]);
                }
            }
            this.spawnedHives.Clear();
            for (int j = 0; j < num3; j++)
            {
                this.TrySpawnHive(map);
            }
            this.spawnedHives.Clear();
        }
        // Token: 0x06001189 RID: 4489 RVA: 0x00084CF0 File Offset: 0x000830F0
        public override void Generate(Map map, GenStepParams parms)
        {
            if (!Find.Storyteller.difficulty.allowCaveHives || !SettingsHelper.latest.AllowXenomorphFaction)
            {
                return;
            }
            MapGenFloatGrid caves     = MapGenerator.Caves;
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            float           num       = 0.7f;
            int             num2      = 0;

            this.rockCells.Clear();
            foreach (IntVec3 intVec in map.AllCells)
            {
                if (elevation[intVec] > num)
                {
                    this.rockCells.Add(intVec);
                }
                if (caves[intVec] > 0f)
                {
                    num2++;
                }
            }
            List <IntVec3> list = (from c in map.AllCells
                                   where map.thingGrid.ThingsAt(c).Any((Thing thing) => thing.Faction != null)
                                   select c).ToList <IntVec3>();

            GenMorphology.Dilate(list, 50, map, null);
            HashSet <IntVec3> hashSet = new HashSet <IntVec3>(list);
            int num3 = GenMath.RoundRandom((float)num2 / 1000f);

            GenMorphology.Erode(this.rockCells, 10, map, null);
            this.possibleSpawnCells.Clear();
            for (int i = 0; i < this.rockCells.Count; i++)
            {
                if (caves[this.rockCells[i]] > 0f && !hashSet.Contains(this.rockCells[i]))
                {
                    this.possibleSpawnCells.Add(this.rockCells[i]);
                }
            }
            this.spawnedHives.Clear();
            for (int j = 0; j < num3; j++)
            {
                this.TrySpawnHive(map);
            }
            this.spawnedHives.Clear();
        }
 public override void Generate(Map map, GenStepParams parms)
 {
     if (Find.Storyteller.difficulty.allowCaveHives)
     {
         CompProperties_TemperatureDamaged compProperties = ThingDefOf.Hive.GetCompProperties <CompProperties_TemperatureDamaged>();
         if (compProperties.safeTemperatureRange.Includes(map.mapTemperature.OutdoorTemp))
         {
             MapGenFloatGrid caves     = MapGenerator.Caves;
             MapGenFloatGrid elevation = MapGenerator.Elevation;
             float           num       = 0.7f;
             int             num2      = 0;
             this.rockCells.Clear();
             foreach (IntVec3 intVec in map.AllCells)
             {
                 if (elevation[intVec] > num)
                 {
                     this.rockCells.Add(intVec);
                 }
                 if (caves[intVec] > 0f)
                 {
                     num2++;
                 }
             }
             List <IntVec3> list = (from c in map.AllCells
                                    where map.thingGrid.ThingsAt(c).Any((Thing thing) => thing.Faction != null)
                                    select c).ToList <IntVec3>();
             GenMorphology.Dilate(list, 50, map, null);
             HashSet <IntVec3> hashSet = new HashSet <IntVec3>(list);
             int num3 = GenMath.RoundRandom((float)num2 / 1000f);
             GenMorphology.Erode(this.rockCells, 10, map, null);
             this.possibleSpawnCells.Clear();
             for (int i = 0; i < this.rockCells.Count; i++)
             {
                 if (caves[this.rockCells[i]] > 0f && !hashSet.Contains(this.rockCells[i]))
                 {
                     this.possibleSpawnCells.Add(this.rockCells[i]);
                 }
             }
             this.spawnedHives.Clear();
             for (int j = 0; j < num3; j++)
             {
                 this.TrySpawnHive(map);
             }
             this.spawnedHives.Clear();
         }
     }
 }
Ejemplo n.º 6
0
        public override void Generate(Map map, GenStepParams parms)
        {
            if (!Find.Storyteller.difficulty.allowCaveHives)
            {
                return;
            }
            MapGenFloatGrid caves     = MapGenerator.Caves;
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            float           num       = 0.7f;
            int             num2      = 0;

            rockCells.Clear();
            foreach (IntVec3 allCell in map.AllCells)
            {
                if (elevation[allCell] > num)
                {
                    rockCells.Add(allCell);
                }
                if (caves[allCell] > 0f)
                {
                    num2++;
                }
            }
            List <IntVec3> list = map.AllCells.Where((IntVec3 c) => map.thingGrid.ThingsAt(c).Any((Thing thing) => thing.Faction != null)).ToList();

            GenMorphology.Dilate(list, 50, map);
            HashSet <IntVec3> hashSet = new HashSet <IntVec3>(list);
            int num3 = GenMath.RoundRandom((float)num2 / 1000f);

            GenMorphology.Erode(rockCells, 10, map);
            possibleSpawnCells.Clear();
            for (int i = 0; i < rockCells.Count; i++)
            {
                if (caves[rockCells[i]] > 0f && !hashSet.Contains(rockCells[i]))
                {
                    possibleSpawnCells.Add(rockCells[i]);
                }
            }
            spawnedHives.Clear();
            for (int j = 0; j < num3; j++)
            {
                TrySpawnHive(map);
            }
            spawnedHives.Clear();
        }
Ejemplo n.º 7
0
        public static void SetStableDeepRoof(Map map)
        {
            List <IntVec3> unroofedCells = new List <IntVec3>();

            foreach (IntVec3 cell in map.AllCells)
            {
                if (!map.roofGrid.Roofed(cell))
                {
                    unroofedCells.Add(cell);
                }
            }
            GenMorphology.Dilate(unroofedCells, deepRoofDistance, map);
            foreach (IntVec3 cell in map.AllCells)
            {
                if (!unroofedCells.Contains(cell))
                {
                    map.roofGrid.SetRoof(cell, RoofDefOf.RoofRockUncollapsable);
                }
            }
            map.roofGrid.RoofGridUpdate();
        }
 private void Trim(List <IntVec3> group, Map map)
 {
     GenMorphology.Open(group, 6, map);
 }
Ejemplo n.º 9
0
 private void Trim(List <IntVec3> group, Map map)
 {
     // Remove spiky rock areas and open small bridges
     // This is like transforming the rock into a spiky dough and letting it flow into a blob with lesser surface area
     GenMorphology.Open(group, 6, map);
 }
Ejemplo n.º 10
0
        static bool Prefix(GenStep_CaveHives __instance, Map map, GenStepParams parms)
        {
            Func <Thing, bool> func = null;

            if (!Find.Storyteller.difficulty.allowCaveHives)
            {
                return(false);
            }

            MapGenFloatGrid caves     = MapGenerator.Caves;
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            float           single    = 0.7f;
            int             num       = 0;

            rockCells.Clear();

            foreach (IntVec3 allCell in map.AllCells)
            {
                if (elevation[allCell] > single)
                {
                    rockCells.Add(allCell);
                }
                if (caves[allCell] <= 0f)
                {
                    continue;
                }
                num++;
            }

            List <IntVec3> list = map.AllCells.Where <IntVec3>((IntVec3 c) =>
            {
                IEnumerable <Thing> things = map.thingGrid.ThingsAt(c);
                if (func == null)
                {
                    func = (Thing thing) => thing.Faction != null;
                }
                return(things.Any <Thing>(func));
            }).ToList <IntVec3>();

            GenMorphology.Dilate(list, 50, map, null);
            HashSet <IntVec3> intVec3s = new HashSet <IntVec3>(list);
            int num1 = GenMath.RoundRandom((float)num / 1000f);

            GenMorphology.Erode(rockCells, 10, map, null);
            possibleSpawnCells.Clear();

            for (int i = 0; i < rockCells.Count; i++)
            {
                if (caves[rockCells[i]] > 0f && !intVec3s.Contains(rockCells[i]))
                {
                    possibleSpawnCells.Add(rockCells[i]);
                }
            }

            spawnedHives.Clear();

            for (int j = 0; j < num1; j++)
            {
                TrySpawnHive(map);
            }

            spawnedHives.Clear();

            return(false);
        }