// Token: 0x0600650C RID: 25868 RVA: 0x00233C80 File Offset: 0x00231E80
        public override void Resolve(ResolveParams rp)
        {
            Faction = rp.faction;
            HiveFactionExtension hiveFaction = Faction.def.GetModExtension <HiveFactionExtension>();

            cells.Clear();
            Map     map        = BaseGen.globalSettings.map;
            IntVec3 CenterCell = rp.rect.CenterCell;
            float   dist       = rp.rect.TopRight.DistanceTo(rp.rect.BottomLeft);

            //	Log.Message(Faction+" hive radius "+ dist);
            cells = map.AllCells.Where(x => x.DistanceTo(CenterCell) <= dist).ToList();
            RoofGrid       roofGrid = BaseGen.globalSettings.map.roofGrid;
            RoofDef        def      = rp.roofDef ?? RoofDefOf.RoofRockThick;
            List <IntVec3> cellst   = cells.Where(x => x.DistanceTo(CenterCell) < dist - 10).ToList();
            List <IntVec3> celle    = cells.Where(x => x.DistanceTo(CenterCell) > dist - 5 && x.DistanceTo(CenterCell) < dist).ToList();

            for (int i = 0; i < dist / 5; i++)
            {
                IntVec3 ce = celle.RandomElement();
                Rand.PushState();
                float size = Rand.Range(5, 10);
                Rand.PopState();
                cells.RemoveAll(x => ce.DistanceTo(x) < size);
            }
            foreach (IntVec3 c in cells)
            {
                roofGrid.SetRoof(c, def);
                map.terrainGrid.SetTerrain(c, TerrainDefOf.Gravel);
                this.TrySpawnWall(c, rp);
            }
        }
        public static void MakeTriangularRoom(Map map, ResolveParams rp)
        {
            if (rp.wallStuff == null)
            {
                Faction faction = Find.FactionManager.RandomNonHostileFaction(false, false, true, TechLevel.Spacer);

                rp.wallStuff = BaseGenUtility.RandomCheapWallStuff(faction, false);
            }
            if (rp.floorDef == null)
            {
                rp.floorDef = BaseGenUtility.CorrespondingTerrainDef(rp.wallStuff, true);
            }
            if (rp.floorDef == null)
            {
                rp.floorDef = BaseGenUtility.RandomBasicFloorDef(Faction.OfMechanoids, false);
            }
            ResolveParams resolveParams = rp;

            resolveParams.rect = new CellRect(rp.rect.minX, rp.rect.minZ, 1, rp.rect.Height);
            BaseGen.symbolStack.Push("edgeWalls", resolveParams, null);
            for (int i = 0; i <= rp.rect.Width; i++)
            {
                int num  = rp.rect.minX + i;
                int num2 = (int)Math.Floor((double)(0.5f * (float)i));
                int num3 = (int)Math.Ceiling((double)(0.5f * (float)i));
                for (int j = rp.rect.minZ + num2; j < rp.rect.minZ + rp.rect.Width - num2; j++)
                {
                    foreach (Thing thing in map.thingGrid.ThingsAt(new IntVec3(num, 1, j)))
                    {
                        thing.TakeDamage(new DamageInfo(DamageDefOf.Blunt, 10000, -1f, -1f, null, null, null, 0));
                    }
                    MapGenUtility.TryToSetFloorTile(new IntVec3(num, 1, j), map, rp.floorDef);
                    if (j == rp.rect.minZ + num2 || j == rp.rect.minZ + num3 || j == rp.rect.minZ + rp.rect.Width - (num2 + 1) || j == rp.rect.minZ + rp.rect.Width - (num3 + 1))
                    {
                        ResolveParams resolveParams2 = rp;
                        resolveParams2.rect = new CellRect(num, j, 1, 1);
                        BaseGen.symbolStack.Push("edgeWalls", resolveParams2, null);
                    }
                }
            }
            map.MapUpdate();
            RoofGrid roofGrid = BaseGen.globalSettings.map.roofGrid;
            RoofDef  def      = rp.roofDef ?? RoofDefOf.RoofConstructed;

            for (int k = 0; k <= rp.rect.Width; k++)
            {
                int newX = rp.rect.minX + k;
                int num4 = (int)Math.Floor((double)(0.5f * (float)k));
                for (int l = rp.rect.minZ + num4; l < rp.rect.minZ + rp.rect.Width - num4; l++)
                {
                    IntVec3 c = new IntVec3(newX, 1, l);
                    if (!roofGrid.Roofed(c))
                    {
                        roofGrid.SetRoof(c, def);
                    }
                }
            }
        }
Пример #3
0
 public override void Resolve(ResolveParams rp)
 {
     if (!rp.noRoof.HasValue || !rp.noRoof.Value)
     {
         RoofGrid roofGrid = BaseGen.globalSettings.map.roofGrid;
         RoofDef  def      = rp.roofDef ?? RoofDefOf.RoofConstructed;
         foreach (IntVec3 item in rp.rect)
         {
             if (!roofGrid.Roofed(item))
             {
                 roofGrid.SetRoof(item, def);
             }
         }
     }
 }
 public override void Resolve(ResolveParams rp)
 {
     if (rp.noRoof == null || !rp.noRoof.Value)
     {
         RoofGrid roofGrid = BaseGen.globalSettings.map.roofGrid;
         RoofDef  def      = rp.roofDef ?? RoofDefOf.RoofConstructed;
         CellRect.CellRectIterator iterator = rp.rect.GetIterator();
         while (!iterator.Done())
         {
             IntVec3 c = iterator.Current;
             if (!roofGrid.Roofed(c))
             {
                 roofGrid.SetRoof(c, def);
             }
             iterator.MoveNext();
         }
     }
 }
        public override void Generate(Map map, GenStepParams parms)
        {
            MapParent_PocketDimension mapParent = map.Parent as MapParent_PocketDimension;
            List <IntVec3>            list      = new List <IntVec3>();
            TerrainGrid terrainGrid             = map.terrainGrid;
            RoofGrid    roofGrid = map.roofGrid;

            string   terrainDefName = "CM_PocketDimensionFloor";
            ThingDef boxStuffDef    = null;

            // Build terrain defname
            Building_PocketDimensionBox box = PocketDimensionUtility.GetBox(mapParent.dimensionSeed);

            if (box != null && box.Stuff != null)
            {
                boxStuffDef = box.Stuff;
                if (boxStuffDef.stuffProps.categories.Contains(StuffCategoryDefOf.Metallic))
                {
                    terrainDefName += "Metal";
                }
                else if (boxStuffDef.stuffProps.categories.Contains(StuffCategoryDefOf.Stony))
                {
                    terrainDefName += "Stone";
                }
                else if (boxStuffDef.stuffProps.categories.Contains(StuffCategoryDefOf.Woody))
                {
                    terrainDefName += "Wood";
                }

                terrainDefName += "_" + boxStuffDef.defName;
            }

            // If that terrain was not found, use default metal terrain
            TerrainDef terrainDef = DefDatabase <TerrainDef> .GetNamedSilentFail(terrainDefName);

            if (terrainDef == null)
            {
                terrainDef = PocketDimensionDefOf.CM_PocketDimensionFloorMetal;
            }

            foreach (IntVec3 current in map.AllCells)
            {
                terrainGrid.SetTerrain(current, terrainDef);

                if (current.OnEdge(map))
                {
                    Thing wall = ThingMaker.MakeThing(PocketDimensionDefOf.CM_PocketDimensionWall, boxStuffDef);
                    wall.SetFaction(Faction.OfPlayer);
                    GenSpawn.Spawn(wall, current, map);
                }

                roofGrid.SetRoof(current, PocketDimensionDefOf.CM_PocketDimensionRoof);
            }
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 allCell in map.AllCells)
            {
                elevation[allCell] = 0.0f;
            }
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 allCell2 in map.AllCells)
            {
                fertility[allCell2] = 0.0f;
            }
        }