Ejemplo n.º 1
0
        /// <summary>
        /// This is a heavily simplified version of the vanilla GenStep_Terrain
        /// Most of the original isn't needed, and there are several changes to the parts that are left
        /// </summary>
        /// <param name="map"></param>
        /// <param name="parms"></param>
        public override void Generate(Map map, GenStepParams parms)
        {
            //check if it's our biome. If not, skip
            if (map.Biome.defName != "RockMoonBiome")
            {
                return;
            }

            mapRadiusSize = map.Size.x / 2;

            List <IntVec3>  list        = new List <IntVec3>();
            MapGenFloatGrid elevation   = MapGenerator.Elevation;
            MapGenFloatGrid fertility   = MapGenerator.Fertility;
            MapGenFloatGrid caves       = MapGenerator.Caves;
            TerrainGrid     terrainGrid = map.terrainGrid;

            foreach (IntVec3 current in map.AllCells)
            {
                Building   edifice = current.GetEdifice(map);
                TerrainDef terrainDef;
                terrainDef = this.TerrainFrom(current, fertility[current]);

                terrainGrid.SetTerrain(current, terrainDef);
            }
            RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map);
            BeachMaker.Cleanup();
            foreach (TerrainPatchMaker current2 in map.Biome.terrainPatchMakers)
            {
                current2.Cleanup();
            }
        }
Ejemplo n.º 2
0
        public override void Generate(Map map, GenStepParams parms)
        {
            BeachMaker.Init(map);
            RiverMaker      riverMaker  = GenerateRiver(map);
            List <IntVec3>  list        = new List <IntVec3>();
            MapGenFloatGrid elevation   = MapGenerator.Elevation;
            MapGenFloatGrid fertility   = MapGenerator.Fertility;
            MapGenFloatGrid caves       = MapGenerator.Caves;
            TerrainGrid     terrainGrid = map.terrainGrid;

            foreach (IntVec3 allCell in map.AllCells)
            {
                Building   edifice    = allCell.GetEdifice(map);
                TerrainDef terrainDef = null;
                terrainDef = (((edifice == null || edifice.def.Fillage != FillCategory.Full) && !(caves[allCell] > 0f)) ? TerrainFrom(allCell, map, elevation[allCell], fertility[allCell], riverMaker, preferSolid: false) : TerrainFrom(allCell, map, elevation[allCell], fertility[allCell], riverMaker, preferSolid: true));
                if (terrainDef.IsRiver && edifice != null)
                {
                    list.Add(edifice.Position);
                    edifice.Destroy();
                }
                terrainGrid.SetTerrain(allCell, terrainDef);
            }
            riverMaker?.ValidatePassage(map);
            RemoveIslands(map);
            RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map);
            BeachMaker.Cleanup();
            foreach (TerrainPatchMaker terrainPatchMaker in map.Biome.terrainPatchMakers)
            {
                terrainPatchMaker.Cleanup();
            }
        }
Ejemplo n.º 3
0
        private void CalculateRoofsAboutToCollapse(CellRect rect)
        {
            Map map = BaseGen.globalSettings.map;

            roofsAboutToCollapse.Clear();
            visited.Clear();
            CellRect.CellRectIterator iterator = rect.GetIterator();
            while (!iterator.Done())
            {
                IntVec3 current = iterator.Current;
                if (current.Roofed(map) && !RoofCollapseCellsFinder.ConnectsToRoofHolder(current, map, visited))
                {
                    map.floodFiller.FloodFill(current, (IntVec3 x) => x.Roofed(map), delegate(IntVec3 x)
                    {
                        roofsAboutToCollapse.Add(x);
                    });
                }
                iterator.MoveNext();
            }
            CellRect.CellRectIterator iterator2 = rect.GetIterator();
            while (!iterator2.Done())
            {
                IntVec3 current2 = iterator2.Current;
                if (current2.Roofed(map) && !roofsAboutToCollapse.Contains(current2) && !RoofCollapseUtility.WithinRangeOfRoofHolder(current2, map))
                {
                    roofsAboutToCollapse.Add(current2);
                }
                iterator2.MoveNext();
            }
        }
Ejemplo n.º 4
0
 protected override void DoEffect()
 {
     JobDriver_RemoveRoof.removedRoofs.Clear();
     base.Map.roofGrid.SetRoof(base.Cell, null);
     JobDriver_RemoveRoof.removedRoofs.Add(base.Cell);
     RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(JobDriver_RemoveRoof.removedRoofs, base.Map, true);
     JobDriver_RemoveRoof.removedRoofs.Clear();
 }
Ejemplo n.º 5
0
 protected override void DoEffect()
 {
     removedRoofs.Clear();
     base.Map.roofGrid.SetRoof(base.Cell, null);
     removedRoofs.Add(base.Cell);
     RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(removedRoofs, base.Map, removalMode: true);
     removedRoofs.Clear();
 }
        public override void Generate(Map map)
        {
            BeachMaker.Init(map);
            RiverMaker      riverMaker  = this.GenerateRiver(map);
            List <IntVec3>  list        = new List <IntVec3>();
            MapGenFloatGrid elevation   = MapGenerator.Elevation;
            MapGenFloatGrid fertility   = MapGenerator.Fertility;
            MapGenFloatGrid caves       = MapGenerator.Caves;
            TerrainGrid     terrainGrid = map.terrainGrid;

            foreach (IntVec3 allCell in map.AllCells)
            {
                Building   edifice    = allCell.GetEdifice(map);
                TerrainDef terrainDef = null;
                if (edifice != null && edifice.def.Fillage == FillCategory.Full)
                {
                    goto IL_0083;
                }
                if (caves[allCell] > 0.0)
                {
                    goto IL_0083;
                }
                terrainDef = this.TerrainFrom(allCell, map, elevation[allCell], fertility[allCell], riverMaker, false);
                goto IL_00c2;
IL_0083:
                terrainDef = this.TerrainFrom(allCell, map, elevation[allCell], fertility[allCell], riverMaker, true);
                goto IL_00c2;
IL_00c2:
                if ((terrainDef == TerrainDefOf.WaterMovingShallow || terrainDef == TerrainDefOf.WaterMovingDeep) && edifice != null)
                {
                    list.Add(edifice.Position);
                    edifice.Destroy(DestroyMode.Vanish);
                }
                terrainGrid.SetTerrain(allCell, terrainDef);
            }
            if (riverMaker != null)
            {
                riverMaker.ValidatePassage(map);
            }
            RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map);
            BeachMaker.Cleanup();
            foreach (TerrainPatchMaker terrainPatchMaker in map.Biome.terrainPatchMakers)
            {
                terrainPatchMaker.Cleanup();
            }
        }
Ejemplo n.º 7
0
        public override void Generate(Map map, GenStepParams parms)
        {
            BeachMaker.Init(map);
            RiverMaker      riverMaker  = this.GenerateRiver(map);
            List <IntVec3>  list        = new List <IntVec3>();
            MapGenFloatGrid elevation   = MapGenerator.Elevation;
            MapGenFloatGrid fertility   = MapGenerator.Fertility;
            MapGenFloatGrid caves       = MapGenerator.Caves;
            TerrainGrid     terrainGrid = map.terrainGrid;

            foreach (IntVec3 c in map.AllCells)
            {
                Building   edifice = c.GetEdifice(map);
                TerrainDef terrainDef;
                if ((edifice != null && edifice.def.Fillage == FillCategory.Full) || caves[c] > 0f)
                {
                    terrainDef = this.TerrainFrom(c, map, elevation[c], fertility[c], riverMaker, true);
                }
                else
                {
                    terrainDef = this.TerrainFrom(c, map, elevation[c], fertility[c], riverMaker, false);
                }
                if (terrainDef.IsRiver)
                {
                    if (edifice != null)
                    {
                        list.Add(edifice.Position);
                        edifice.Destroy(DestroyMode.Vanish);
                    }
                }
                terrainGrid.SetTerrain(c, terrainDef);
            }
            if (riverMaker != null)
            {
                riverMaker.ValidatePassage(map);
            }
            RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map);
            BeachMaker.Cleanup();
            foreach (TerrainPatchMaker terrainPatchMaker in map.Biome.terrainPatchMakers)
            {
                terrainPatchMaker.Cleanup();
            }
        }
Ejemplo n.º 8
0
 private void DestroyRoofs()
 {
     this.removedRoofsTmp.Clear();
     foreach (IntVec3 intVec in from x in GenRadial.RadialCellsAround(base.Position, this.Graphic.drawSize.magnitude * 0.75f, true)
              where x.InBounds(base.Map)
              select x)
     {
         if (!this.CellImmuneToDamage(intVec) && intVec.Roofed(base.Map))
         {
             RoofDef roof = intVec.GetRoof(base.Map);
             if (!roof.isThickRoof && !roof.isNatural)
             {
                 RoofCollapserImmediate.DropRoofInCells(intVec, base.Map, null);
                 this.removedRoofsTmp.Add(intVec);
             }
         }
     }
     if (this.removedRoofsTmp.Count > 0)
     {
         RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(this.removedRoofsTmp, base.Map, true, false);
     }
 }
Ejemplo n.º 9
0
        public override void Generate(Map map, GenStepParams parms)
        {
            BeachMaker.Init(map);
            //RiverMaker riverMaker = this.GenerateRiver(map);
            List <IntVec3>  list        = new List <IntVec3>();
            MapGenFloatGrid elevation   = MapGenerator.Elevation;
            MapGenFloatGrid fertility   = MapGenerator.Fertility;
            MapGenFloatGrid caves       = MapGenerator.Caves;
            TerrainGrid     terrainGrid = map.terrainGrid;

            foreach (IntVec3 c in map.AllCells)
            {
                terrainGrid.SetTerrain(c, ZLevelsDefOf.ZL_OutsideTerrain);
            }

            RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map);
            BeachMaker.Cleanup();
            foreach (TerrainPatchMaker terrainPatchMaker in map.Biome.terrainPatchMakers)
            {
                terrainPatchMaker.Cleanup();
            }
        }
        private void CalculateRoofsAboutToCollapse(CellRect rect)
        {
            Map map = BaseGen.globalSettings.map;

            SymbolResolver_EnsureCanHoldRoof.roofsAboutToCollapse.Clear();
            SymbolResolver_EnsureCanHoldRoof.visited.Clear();
            CellRect.CellRectIterator iterator = rect.GetIterator();
            while (!iterator.Done())
            {
                IntVec3 current = iterator.Current;
                if (current.Roofed(map))
                {
                    if (!RoofCollapseCellsFinder.ConnectsToRoofHolder(current, map, SymbolResolver_EnsureCanHoldRoof.visited))
                    {
                        map.floodFiller.FloodFill(current, (IntVec3 x) => x.Roofed(map), delegate(IntVec3 x)
                        {
                            SymbolResolver_EnsureCanHoldRoof.roofsAboutToCollapse.Add(x);
                        }, 2147483647, false, null);
                    }
                }
                iterator.MoveNext();
            }
            CellRect.CellRectIterator iterator2 = rect.GetIterator();
            while (!iterator2.Done())
            {
                IntVec3 current2 = iterator2.Current;
                if (current2.Roofed(map))
                {
                    if (!SymbolResolver_EnsureCanHoldRoof.roofsAboutToCollapse.Contains(current2))
                    {
                        if (!RoofCollapseUtility.WithinRangeOfRoofHolder(current2, map, false))
                        {
                            SymbolResolver_EnsureCanHoldRoof.roofsAboutToCollapse.Add(current2);
                        }
                    }
                }
                iterator2.MoveNext();
            }
        }
Ejemplo n.º 11
0
 private void DestroyRoofs()
 {
     removedRoofsTmp.Clear();
     foreach (IntVec3 item in from x in GenRadial.RadialCellsAround(base.Position, 4.2f, useCenter: true)
              where x.InBounds(base.Map)
              select x)
     {
         if (!CellImmuneToDamage(item) && item.Roofed(base.Map))
         {
             RoofDef roof = item.GetRoof(base.Map);
             if (!roof.isThickRoof && !roof.isNatural)
             {
                 RoofCollapserImmediate.DropRoofInCells(item, base.Map);
                 removedRoofsTmp.Add(item);
             }
         }
     }
     if (removedRoofsTmp.Count > 0)
     {
         RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(removedRoofsTmp, base.Map, removalMode: true);
     }
 }
Ejemplo n.º 12
0
        private void CalculateRoofsAboutToCollapse(CellRect rect)
        {
            Map map = BaseGen.globalSettings.map;

            roofsAboutToCollapse.Clear();
            visited.Clear();
            foreach (IntVec3 item in rect)
            {
                if (item.Roofed(map) && !RoofCollapseCellsFinder.ConnectsToRoofHolder(item, map, visited))
                {
                    map.floodFiller.FloodFill(item, (IntVec3 x) => x.Roofed(map), delegate(IntVec3 x)
                    {
                        roofsAboutToCollapse.Add(x);
                    });
                }
            }
            foreach (IntVec3 item2 in rect)
            {
                if (item2.Roofed(map) && !roofsAboutToCollapse.Contains(item2) && !RoofCollapseUtility.WithinRangeOfRoofHolder(item2, map))
                {
                    roofsAboutToCollapse.Add(item2);
                }
            }
        }
Ejemplo n.º 13
0
        public override void Generate(Map map, GenStepParams parms)
        {
            List <IntVec3>  list        = new List <IntVec3>();
            MapGenFloatGrid elevation   = MapGenerator.Elevation;
            MapGenFloatGrid fertility   = MapGenerator.Fertility;
            MapGenFloatGrid caves       = MapGenerator.Caves;
            TerrainGrid     terrainGrid = map.terrainGrid;

            biome1 = chooseABiome();
            foreach (IntVec3 current in map.AllCells)
            {
                Building   edifice = current.GetEdifice(map);
                TerrainDef terrainDef;
                if ((edifice != null && edifice.def.Fillage == FillCategory.Full) || caves[current] > 0f)
                {
                    terrainDef = this.TerrainFrom(current, map, elevation[current], fertility[current], true);
                }
                else
                {
                    terrainDef = this.TerrainFrom(current, map, elevation[current], fertility[current], false);
                }
                if ((terrainDef == TerrainDefOf.WaterMovingShallow || terrainDef == TerrainDefOf.WaterMovingChestDeep) && edifice != null)
                {
                    list.Add(edifice.Position);
                    edifice.Destroy(DestroyMode.Vanish);
                }
                terrainGrid.SetTerrain(current, terrainDef);
            }

            RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map);
            //BeachMaker.Cleanup();
            foreach (TerrainPatchMaker current2 in biome1.terrainPatchMakers)
            {
                current2.Cleanup();
            }


            //Basic terrain gen ends here



            if (map.TileInfo.WaterCovered)
            {
                return;
            }
            map.regionAndRoomUpdater.Enabled = false;
            float num = 0.7f;
            List <GenStep_TerrainFarcasterDeltaServitus.RoofThreshold> list2 = new List <GenStep_TerrainFarcasterDeltaServitus.RoofThreshold>();

            list2.Add(new GenStep_TerrainFarcasterDeltaServitus.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThick,
                minGridVal = num * 1.14f
            });
            list2.Add(new GenStep_TerrainFarcasterDeltaServitus.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThin,
                minGridVal = num * 1.04f
            });
            //MapGenFloatGrid elevation3 = MapGenerator.Elevation;
            //MapGenFloatGrid caves2 = MapGenerator.Caves;
            foreach (IntVec3 current in map.AllCells)
            {
                float num2 = elevation[current];
                if (num2 > num)
                {
                    if (caves[current] <= 0f)
                    {
                        ThingDef def = RockDefAt(current);
                        if (map.Center.DistanceTo(current) > 5f)
                        {
                            GenSpawn.Spawn(def, current, map);
                        }
                    }
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (num2 > list2[i].minGridVal)
                        {
                            map.roofGrid.SetRoof(current, list2[i].roofDef);
                            break;
                        }
                    }
                }
            }
            BoolGrid       visited  = new BoolGrid(map);
            List <IntVec3> toRemove = new List <IntVec3>();

            foreach (IntVec3 current2 in map.AllCells)
            {
                if (!visited[current2])
                {
                    if (this.IsNaturalRoofAt(current2, map))
                    {
                        toRemove.Clear();
                        map.floodFiller.FloodFill(current2, (IntVec3 x) => this.IsNaturalRoofAt(x, map), delegate(IntVec3 x)
                        {
                            visited[x] = true;
                            toRemove.Add(x);
                        }, 2147483647, false, null);
                        if (toRemove.Count < 20)
                        {
                            for (int j = 0; j < toRemove.Count; j++)
                            {
                                map.roofGrid.SetRoof(toRemove[j], null);
                            }
                        }
                    }
                }
            }
            GenStep_ScatterLumpsMineable genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineable();
            float num3 = 10f;

            switch (Find.WorldGrid[map.Tile].hilliness)
            {
            case Hilliness.Flat:
                num3 = 4f;
                break;

            case Hilliness.SmallHills:
                num3 = 8f;
                break;

            case Hilliness.LargeHills:
                num3 = 11f;
                break;

            case Hilliness.Mountainous:
                num3 = 15f;
                break;

            case Hilliness.Impassable:
                num3 = 16f;
                break;
            }
            genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num3, num3);
            genStep_ScatterLumpsMineable.Generate(map, parms);
            map.regionAndRoomUpdater.Enabled = true;


            //Rock gen ends here



            // Plant gen ends here

            int num7 = 0;

            while (!map.wildAnimalSpawner.AnimalEcosystemFull)
            {
                num7++;
                if (num7 >= 10)
                {
                    //Log.Error("Too many iterations.");
                    break;
                }
                IntVec3 loc = RCellFinder.RandomAnimalSpawnCell_MapGen(map);
                if (!SpawnRandomWildAnimalAt(map, loc))
                {
                    break;
                }
            }

            if (map.TileInfo.WaterCovered)
            {
                return;
            }
            this.freqFactorNoise = new Perlin(0.014999999664723873, 2.0, 0.5, 6, Rand.Range(0, 999999), QualityMode.Medium);
            this.freqFactorNoise = new ScaleBias(1.0, 1.0, this.freqFactorNoise);
            NoiseDebugUI.StoreNoiseRender(this.freqFactorNoise, "rock_chunks_freq_factor");
            MapGenFloatGrid elevation2 = MapGenerator.Elevation;

            foreach (IntVec3 current in map.AllCells)
            {
                float num2 = 0.006f * this.freqFactorNoise.GetValue(current);
                if (elevation2[current] < 0.55f && Rand.Value < num2)
                {
                    this.GrowLowRockFormationFrom(current, map);
                }
            }
            this.freqFactorNoise = null;
        }