public override void PostMake()
    {
        base.PostMake();

        powerComp = GetComp<CompPowerTrader>();
        soilDef = DefDatabase<TerrainDef>.GetNamed("Soil");
    }
        public static void GenerateLandingPadBottom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            TerrainDef c = TerrainDefOf.Concrete;
            TerrainDef mt = TerrainDef.Named("MetalTile");
            TerrainDef pt = TerrainDef.Named("PavedTile");

            TerrainDef[,] landingPadBottomPattern = new TerrainDef[11, 11]
            {
                {null, null, null, null, null, null, null, null, null, null, null},
                {null, null, c,    c,    c,    c,    c,    c,    c,    null, null},
                {null, null, c,    mt,   mt,   mt,   mt,   mt,   c,    null, null},
                {null, c,    c,    mt,   c,    c,    c,    mt,   c,    c,    null},
                {null, c,    mt,   mt,   c,    c,    c,    mt,   mt,   c,    null},
                {pt,   pt,   mt,   c,    c,    c,    c,    c,    mt,   pt,   pt},
                {null, c,    mt,   mt,   c,    c,    c,    mt,   mt,   c,    null},
                {c,    c,    mt,   c,    c,    c,    c,    c,    mt,   c,    c},
                {c,    mt,   mt,   c,    c,    c,    c,    c,    mt,   mt,   c},
                {c,    mt,   c,    c,    c,    c,    c,    c,    c,    mt,   c},
                {c,    mt,   c,    c,    c,    c,    c,    c,    c,    mt,   c}
            };

            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            // Spawn floor.
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 10; zOffset++)
                {
                    TerrainDef terrain = landingPadBottomPattern[zOffset, xOffset];
                    if (terrain != null)
                    {
                        Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), terrain);
                    }
                }
            }
            
            // Spawn landing pad beacons.
            Building_LandingPadBeacon beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(1, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon.SetFlashStartOffset(Building_LandingPadBeacon.flashDurationInTicks);
            beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(9, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon.SetFlashStartOffset(Building_LandingPadBeacon.flashDurationInTicks);
            beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon.SetFlashStartOffset(2 * Building_LandingPadBeacon.flashDurationInTicks);
            beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(9, 0, 7).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon.SetFlashStartOffset(2 * Building_LandingPadBeacon.flashDurationInTicks);
            beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(1, 0, 10).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon.SetFlashStartOffset(3 * Building_LandingPadBeacon.flashDurationInTicks);
            beacon = OG_Common.TrySpawnThingAt(OG_Util.LandingPadBeaconDef, null, rotatedOrigin + new IntVec3(9, 0, 10).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData) as Building_LandingPadBeacon;
            beacon.SetFlashStartOffset(3 * Building_LandingPadBeacon.flashDurationInTicks);

            outpostData.landingPadCenter = rotatedOrigin + new IntVec3(5, 0, 10).RotatedBy(rotation);
            outpostData.landingPadRotation = rotation;
        }
 private static void SetCellsInRadiusTerrain(IntVec3 position, float radius, TerrainDef terrain)
 {
     foreach (IntVec3 cell in GenRadial.RadialCellsAround(position, radius, true))
     {
         if (cell.InBounds() == false)
         {
             continue;
         }
         if (terrain != TerrainDefOf.WaterDeep)
         {
             // Excepted when adding deep water, do not touch to water/marsh patches.
             TerrainDef cellTerrain = Find.TerrainGrid.TerrainAt(cell);
             if ((cellTerrain == TerrainDefOf.WaterDeep)
                 || (cellTerrain == TerrainDefOf.WaterShallow)
                 || (cellTerrain == TerrainDef.Named("Marsh")))
             {
                 continue;
             }
         }
         Find.TerrainGrid.SetTerrain(cell, terrain);
     }
 }
示例#4
0
 public static void GenerateEmptyRoomAt(IntVec3 rotatedOrigin,
     int width,
     int height,
     Rot4 rotation,
     TerrainDef defaultFloorDef,
     TerrainDef interiorFloorDef,
     ref OG_OutpostData outpostData)
 {
     CellRect rect = new CellRect(rotatedOrigin.x, rotatedOrigin.z, width, height);
     if (rotation == Rot4.North)
     {
         rect = new CellRect(rotatedOrigin.x, rotatedOrigin.z, width, height);
     }
     else if (rotation == Rot4.East)
     {
         rect = new CellRect(rotatedOrigin.x, rotatedOrigin.z - width + 1, height, width);
     }
     else if (rotation == Rot4.South)
     {
         rect = new CellRect(rotatedOrigin.x - width + 1, rotatedOrigin.z - height + 1, width, height);
     }
     else
     {
         rect = new CellRect(rotatedOrigin.x - height + 1, rotatedOrigin.z, height, width);
     }
     // Generate 4 walls and power conduits.
     foreach (IntVec3 cell in rect.Cells)
     {
         if ((cell.x == rect.minX) || (cell.x == rect.maxX) || (cell.z == rect.minZ) || (cell.z == rect.maxZ))
         {
             OG_Common.TrySpawnWallAt(cell, ref outpostData);
             OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
         }
     }
     // Trigger to unfog area when a pawn enters the room.
     SpawnRectTriggerUnfogArea(rect, ref outpostData.triggerIntrusion);
     // Generate roof.
     foreach (IntVec3 cell in rect.Cells)
     {
         Find.RoofGrid.SetRoof(cell, OG_Util.IronedRoofDef);
     }
     // Generate room default floor.
     if (defaultFloorDef != null)
     {
         foreach (IntVec3 cell in rect.ExpandedBy(1).Cells)
         {
             TerrainDef terrain = Find.TerrainGrid.TerrainAt(cell);
             if (terrain != TerrainDef.Named("PavedTile")) // Don't recover already spawned paved tile.
             {
                 Find.TerrainGrid.SetTerrain(cell, defaultFloorDef);
             }
         }
     }
     // Generate room interior floor.
     if (interiorFloorDef != null)
     {
         foreach (IntVec3 cell in rect.ContractedBy(1).Cells)
         {
             Find.TerrainGrid.SetTerrain(cell, interiorFloorDef);
         }
     }
 }