Ejemplo n.º 1
0
    public override void PostMake()
    {
        base.PostMake();

        powerComp = GetComp<CompPowerTrader>();
        soilDef = DefDatabase<TerrainDef>.GetNamed("Soil");
    }
Ejemplo n.º 2
0
        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;
        }
        public override void SpawnSetup(Map map, bool flag)
        {
            base.SpawnSetup(map, flag);
            TerrainDef terrainDef = map.terrainGrid.TerrainAt(base.Position);

            if (!terrainDef.defName.Contains("Bridge") && !terrainDef.defName.Contains("Floor") && !terrainDef.defName.Contains("Carpet") &&
                !terrainDef.defName.Contains("Tile") && !terrainDef.defName.Contains("Flagstone") && !terrainDef.defName.Contains("Concrete"))
            {
                this.TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                if (terrainDef == TerrainDef.Named("WaterShallow"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterShallow"));
                }
                else if (terrainDef == TerrainDef.Named("WaterOceanShallow"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterOceanShallow"));
                }
                else if (terrainDef == TerrainDef.Named("WaterMovingShallow"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterMovingShallow"));
                }
                else if (terrainDef == TerrainDef.Named("WaterMovingChestDeep"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterMovingChestDeep"));
                }
                else if (terrainDef == TerrainDef.Named("WaterDeep"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterDeep"));
                }
                else if (terrainDef == TerrainDef.Named("WaterOceanDeep"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterOceanDeep"));
                }
                else if (terrainDef == TerrainDef.Named("Marsh"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeMarsh"));
                }
                else if (terrainDef == TerrainDef.Named("Mud"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeMud"));
                }
                else if (terrainDef == TerrainDef.Named("Sand"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeSand"));
                }
                else if (terrainDef == TerrainDef.Named("MarshyTerrain"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeMarshyTerrain"));
                }
                else if (terrainDef == TerrainDef.Named("Ice"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeIce"));
                }
                else if (terrainDef.defName == "IceST" || terrainDef.defName == "IceS")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterShallow";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterShallow"));
                }
                else if (terrainDef.defName == "IceDT" || terrainDef.defName == "IceD")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterDeep";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterDeep"));
                }
                else if (terrainDef.defName == "IceSMT" || terrainDef.defName == "IceSM")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterMovingShallow";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterMovingShallow"));
                }
                else if (terrainDef.defName == "IceDMT" || terrainDef.defName == "IceDM")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterMovingChestDeep";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterMovingChestDeep"));
                }
                else if (terrainDef.defName == "IceMarshT" || terrainDef.defName == "IceMarsh")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "Marsh";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeMarsh"));
                }
                else if (terrainDef.defName.Contains("Water"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterShallow"));
                }
                else if (terrainDef.defName.Contains("WaterShallowLagoon"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("StoneBridgeWaterShallowLagoon"));
                }
                else
                {
                    var affordances = map.terrainGrid.TerrainAt(base.Position).affordances;

                    //no need to replace if affordances are met
                    foreach (var affordance in StoneBridgeSoilDef.affordances)
                    {
                        if (!affordances.Contains(affordance))
                        {
                            map.terrainGrid.SetTerrain(base.Position, StoneBridgeSoilDef);
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void GenerateMainEntranceZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);
            IntVec3 cell          = rotatedOrigin;

            // Spawn concrete floor.
            for (int xOffset = -1; xOffset <= 11; xOffset++)
            {
                for (int zOffset = -1; zOffset <= 5; zOffset++)
                {
                    cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
                }
            }

            // Generate central paved alley.
            for (int xOffset = 4; xOffset <= 6; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 10; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = -1; zOffset <= 10; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Generate south west turret.
            IntVec3 southWestOrigin = rotatedOrigin;

            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 0; zOffset < 5; zOffset++)
                {
                    cell = southWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    if ((xOffset == 0) ||
                        (zOffset == 0))
                    {
                        OG_Common.TrySpawnWallAt(cell, ref outpostData);
                        OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                    }
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(1, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(2, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(3, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(4, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(4, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, southWestOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Generate south east turret.
            IntVec3 southEastOrigin = rotatedOrigin;

            for (int xOffset = 6; xOffset < 11; xOffset++)
            {
                for (int zOffset = 0; zOffset < 5; zOffset++)
                {
                    cell = southEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    if ((xOffset == 10) ||
                        (zOffset == 0))
                    {
                        OG_Common.TrySpawnWallAt(cell, ref outpostData);
                        OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                    }
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(6, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(6, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(7, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(8, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(9, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, southEastOrigin + new IntVec3(7, 0, 2).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Generate central door and power conduit.
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnFireproofPowerConduitAt(rotatedOrigin + new IntVec3(5, 0, 0).RotatedBy(rotation), ref outpostData);

            // Generate ironed roof.
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 4; zOffset++)
                {
                    Find.RoofGrid.SetRoof(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), OG_Util.IronedRoofDef);
                }
            }
        }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
0
 public static bool IsWaterStandable(this TerrainDef def)
 {
     return(def.IsWater() && def.passability == Traversability.Standable);
 }
Ejemplo n.º 7
0
        public static void GenerateSecondaryEntranceZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            // Generate central paved alley.
            for (int xOffset = 4; xOffset <= 6; xOffset++)
            {
                for (int zOffset = 0; zOffset < Genstep_GenerateOutpost.zoneSideSize; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = 0; zOffset < Genstep_GenerateOutpost.zoneSideSize; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Generate north west turret.
            IntVec3 northWestOrigin = rotatedOrigin + new IntVec3(1, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 4; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(0, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(2, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, northWestOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Generate north east turret.
            IntVec3 norththEastOrigin = rotatedOrigin + new IntVec3(6, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 4; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(norththEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(0, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(2, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, norththEastOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Spawn south west sandbags and floor.
            IntVec3 southWestOrigin = rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 3; xOffset++)
            {
                for (int zOffset = 0; zOffset < 3; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(southWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(0, 0, 0).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);

            // Spawn south east sandbags and floor.
            IntVec3 southEastOrigin = rotatedOrigin + new IntVec3(6, 0, 1).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 3; xOffset++)
            {
                for (int zOffset = 0; zOffset < 3; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(southEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(2, 0, 0).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
        }
Ejemplo n.º 8
0
 public static bool IsRiver(this TerrainDef def)
 {
     return(def.defName.Contains("WaterMoving"));
 }
Ejemplo n.º 9
0
 public static bool IsMud(this TerrainDef def)
 {
     return(def.defName.Contains("Mud"));
 }
Ejemplo n.º 10
0
 // Token: 0x06000007 RID: 7
 protected abstract bool IsTerrainThisBridge(TerrainDef terrain);
Ejemplo n.º 11
0
 static void GetStuffedTerrainDefPosfix(TerrainDef __result)
 {
     DefDatabase <BuildableDef> .Add(__result);
 }
Ejemplo n.º 12
0
 public Encase(IntVec3 pos, TerrainDef ter)
 {
     position = pos;
     terrain  = ter;
 }
Ejemplo n.º 13
0
        public bool CanDropAt(IntVec3 c, Map map)
        {
            TerrainDef terrainDef = map.terrainGrid.TerrainAt(c);

            return(terrainDef.acceptFilth && (!this.def.filth.terrainSourced || terrainDef.acceptTerrainSourceFilth));
        }
Ejemplo n.º 14
0
        public override void SpawnSetup(Map map, bool flag)
        {
            base.SpawnSetup(map, flag);
            TerrainDef terrainDef = map.terrainGrid.TerrainAt(base.Position);

            if (!terrainDef.defName.Contains("Bridge") && !terrainDef.defName.Contains("Floor") && !terrainDef.defName.Contains("Carpet") &&
                !terrainDef.defName.Contains("Tile") && !terrainDef.defName.Contains("Flagstone") && !terrainDef.defName.Contains("Concrete"))
            {
                this.TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                if (terrainDef == TerrainDef.Named("WaterShallow"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterShallow"));
                }
                else if (terrainDef == TerrainDef.Named("WaterOceanShallow"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterOceanShallow"));
                }
                else if (terrainDef == TerrainDef.Named("WaterMovingShallow"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterMovingShallow"));
                }
                else if (terrainDef == TerrainDef.Named("WaterMovingChestDeep"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterMovingChestDeep"));
                }
                else if (terrainDef == TerrainDef.Named("WaterDeep"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterDeep"));
                }
                else if (terrainDef == TerrainDef.Named("WaterOceanDeep"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterOceanDeep"));
                }
                else if (terrainDef == TerrainDef.Named("Marsh"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeMarsh"));
                }
                else if (terrainDef == TerrainDef.Named("Mud"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeMud"));
                }
                else if (terrainDef == TerrainDef.Named("Sand"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeSand"));
                }
                else if (terrainDef == TerrainDef.Named("MarshyTerrain"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeMarshyTerrain"));
                }
                else if (terrainDef == TerrainDef.Named("Ice"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeIce"));
                }
                else if (terrainDef.defName == "IceST" || terrainDef.defName == "IceS")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterShallow";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterShallow"));
                }
                else if (terrainDef.defName == "IceDT" || terrainDef.defName == "IceD")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterDeep";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterDeep"));
                }
                else if (terrainDef.defName == "IceSMT" || terrainDef.defName == "IceSM")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterMovingShallow";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterMovingShallow"));
                }
                else if (terrainDef.defName == "IceDMT" || terrainDef.defName == "IceDM")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "WaterMovingChestDeep";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterMovingChestDeep"));
                }
                else if (terrainDef.defName == "IceMarshT" || terrainDef.defName == "IceMarsh")
                {
                    this.TerrainTypeAtBaseCellDefAsString = "Marsh";
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeMarsh"));
                }
                else if (terrainDef.defName.Contains("Water"))
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeWaterShallow"));
                }
                else
                {
                    map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named("BridgeLand"));
                }
            }
        }
Ejemplo n.º 15
0
 public static bool Flammable(this TerrainDef terrain)
 {
     return(terrain.GetStatValueAbstract(StatDefOf.Flammability, null) > 0.01f);
 }
Ejemplo n.º 16
0
        private Action PrepDrawRoad(Map map, TerrainDef rockDef, IntVec3 start, IntVec3 end, RoadDef roadDef, RoadPathingDef pathingDef)
        {
            IntVec3 centerpoint;

            return(PrepDrawRoad(map, rockDef, start, end, roadDef, pathingDef, out centerpoint));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            const float baseFishingDuration    = 1600f;
            const float catchSuccessRateOnPier = 0.90f;
            const float skillGainPerTick       = 0.15f;

            int fishingDuration = (int)baseFishingDuration;
            Building_FishingPier fishingPier = this.TargetThingA as Building_FishingPier;
            int thrownCornCount   = 0;
            int nextCornThrowTick = 0;

            this.FailOnBurningImmobile(fishingPierIndex);

            // Drawing.
            this.rotateToFace = TargetIndex.B;
            this.pawn.CurJob.SetTarget(TargetIndex.C, fishingPier.riverCell);
            TargetIndex riverCellIndex = TargetIndex.C;

            // Compute fishing duration.
            float fishingSkillLevel = 0f;

            fishingSkillLevel = this.pawn.skills.AverageOfRelevantSkillsFor(WorkTypeDefOf.Hunting);
            float fishingSkillDurationFactor = fishingSkillLevel / 20f;

            fishingDuration = (int)(baseFishingDuration * (1.5f - fishingSkillDurationFactor));

            yield return(Toils_Goto.GotoThing(fishingPierIndex, fishingPier.riverCell).FailOn(FishingForbiddenOrPierDestroyedOrNoFish));

            Toil attractfishesToil = new Toil()
            {
                tickAction = () =>
                {
                    if (fishingPier.allowUsingGrain == false)
                    {
                        this.ReadyForNextToil();
                        return;
                    }
                    if (Find.TickManager.TicksGame >= nextCornThrowTick)
                    {
                        nextCornThrowTick = Find.TickManager.TicksGame + 3 * GenTicks.TicksPerRealSecond;
                        // Look for corn in inventory.
                        Thing corn = null;
                        foreach (Thing thing in this.pawn.inventory.innerContainer)
                        {
                            if (thing.def == Util_FishIndustry.RawCornDef)
                            {
                                corn = thing;
                                break;
                            }
                        }
                        if ((corn == null) ||
                            (thrownCornCount >= grainCountToAttractFishes))
                        {
                            fishingDuration -= Mathf.CeilToInt((float)fishingDuration * 0.75f * ((float)thrownCornCount / (float)grainCountToAttractFishes));
                            this.ReadyForNextToil();
                            return;
                        }
                        // Throw corn grains.
                        thrownCornCount++;
                        this.pawn.inventory.innerContainer.Take(corn, 1);
                        for (int cornGrainIndex = 0; cornGrainIndex < 5; cornGrainIndex++)
                        {
                            if (!this.pawn.Position.ShouldSpawnMotesAt(this.pawn.Map) || this.pawn.Map.moteCounter.Saturated)
                            {
                                break;
                            }
                            float   speed          = Rand.Range(1.5f, 3f);
                            Vector3 targetPosition = this.pawn.Position.ToVector3Shifted() + new Vector3(0f, 0f, 2f).RotatedBy(fishingPier.Rotation.AsAngle) + Vector3Utility.RandomHorizontalOffset(1.5f);
                            targetPosition.y = this.pawn.DrawPos.y;
                            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_Stone, null);
                            moteThrown.Scale         = 0.2f;
                            moteThrown.rotationRate  = (float)Rand.Range(-300, 300);
                            moteThrown.exactPosition = this.pawn.DrawPos;
                            moteThrown.SetVelocity((targetPosition - moteThrown.exactPosition).AngleFlat(), speed);
                            moteThrown.airTimeLeft = (float)Mathf.RoundToInt((moteThrown.exactPosition - targetPosition).MagnitudeHorizontal() / speed);
                            GenSpawn.Spawn(moteThrown, this.pawn.Position, this.pawn.Map);
                            MoteMaker.MakeWaterSplash(targetPosition, this.pawn.Map, 1.8f, 0.5f);
                        }
                    }
                },
                defaultDuration     = fishingDuration,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            yield return(attractfishesToil.FailOn(FishingForbiddenOrPierDestroyedOrNoFish));

            Toil fishToil = new Toil()
            {
                initAction = () =>
                {
                    ThingDef moteDef = null;
                    if (fishingPier.Rotation == Rot4.North)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodNorthDef;
                    }
                    else if (fishingPier.Rotation == Rot4.East)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodEastDef;
                    }
                    else if (fishingPier.Rotation == Rot4.South)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodSouthDef;
                    }
                    else
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodWestDef;
                    }
                    this.fishingRodMote = (Mote)ThingMaker.MakeThing(moteDef, null);
                    this.fishingRodMote.exactPosition = fishingPier.fishingSpotCell.ToVector3Shifted();
                    this.fishingRodMote.Scale         = 1f;
                    GenSpawn.Spawn(this.fishingRodMote, fishingPier.fishingSpotCell, this.Map);
                },
                tickAction = () =>
                {
                    this.pawn.skills.Learn(SkillDefOf.Shooting, skillGainPerTick);

                    if (this.fishingRodMote != null)
                    {
                        this.fishingRodMote.Maintain();
                    }
                },
                defaultDuration     = fishingDuration,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            yield return(fishToil.WithProgressBarToilDelay(riverCellIndex).FailOn(FishingForbiddenOrPierDestroyedOrNoFish));

            Toil catchFishToil = new Toil()
            {
                initAction = () =>
                {
                    Thing fishingCatch = null;

                    bool catchIsSuccessful = (Rand.Value <= catchSuccessRateOnPier);
                    if (catchIsSuccessful == false)
                    {
                        MoteMaker.ThrowMetaIcon(this.pawn.Position, this.Map, ThingDefOf.Mote_IncapIcon);
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                        return;
                    }

                    float catchSelectorValue = Rand.Value;

                    if (catchSelectorValue < 0.02)
                    {
                        float bonusCatchValue = Rand.Value;
                        if (bonusCatchValue < 0.01f)
                        {
                            // Really small chance to find a sunken treasure!!!
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position, this.Map);
                            fishingCatch.stackCount = Rand.RangeInclusive(58, 289);
                            Thing treasureSilver = GenSpawn.Spawn(ThingDefOf.Silver, fishingPier.middleCell, this.Map);
                            treasureSilver.stackCount = Rand.RangeInclusive(237, 2154);
                            Find.LetterStack.ReceiveLetter("FishIndustry.LetterLabelSunkenTreasure".Translate(), "FishIndustry.SunkenTreasure".Translate(this.pawn.Name.ToStringShort.CapitalizeFirst()),
                                                           LetterDefOf.PositiveEvent, this.pawn);
                        }
                        else if (bonusCatchValue < 0.02f)
                        {
                            // Really small chance to find a complete power armor set + sniper or charge rifle.
                            Thing powerArmor = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmor"), this.pawn.Position, this.Map);
                            fishingCatch = powerArmor; // Used to carry the power armor.
                            Thing powerArmorHelmet = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmorHelmet"), this.pawn.Position, this.Map);
                            Thing rifle            = null;
                            if (Rand.Value < 0.5f)
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_ChargeRifle"), this.pawn.Position, this.Map);
                            }
                            else
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_SniperRifle"), this.pawn.Position, this.Map);
                            }
                            CompQuality qualityComp = powerArmor.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = powerArmorHelmet.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = rifle.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }

                            Faction faction    = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile);
                            Pawn    deadMarine = PawnGenerator.GeneratePawn(PawnKindDefOf.AncientSoldier, faction);
                            HealthUtility.DamageUntilDead(deadMarine);
                            Corpse       corpse  = deadMarine.ParentHolder as Corpse;
                            CompRottable rotComp = corpse.TryGetComp <CompRottable>();
                            if (rotComp != null)
                            {
                                rotComp.RotProgress = 20f * GenDate.TicksPerDay; // 20 days so the corpse is dessicated.
                            }
                            GenSpawn.Spawn(corpse, fishingPier.bankCell, this.Map);
                            string eventText = "FishIndustry.LetterDescDeadMarine".Translate(this.pawn.Name.ToStringShort.CapitalizeFirst());
                            Find.LetterStack.ReceiveLetter("FishIndustry.LetterLabelDeadMarine".Translate(), eventText, LetterDefOf.PositiveEvent, this.pawn);
                        }
                        else
                        {
                            // Find a small amount of gold.
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position, this.Map);
                            fishingCatch.stackCount = Rand.RangeInclusive(1, 7);
                        }
                    }
                    else if (catchSelectorValue < 0.04)
                    {
                        // Find oysters.
                        fishingCatch            = GenSpawn.Spawn(Util_FishIndustry.OysterDef, this.pawn.Position, this.Map);
                        fishingCatch.stackCount = Rand.RangeInclusive(2, 9);
                    }
                    else
                    {
                        // Catch a fish.
                        IntVec3 fishSpot        = fishingPier.aquaticCells.RandomElement();
                        bool    fishSpotIsOcean = (this.Map.terrainGrid.TerrainAt(fishSpot) == TerrainDefOf.WaterOceanShallow) ||
                                                  (this.Map.terrainGrid.TerrainAt(fishSpot) == TerrainDefOf.WaterOceanDeep);
                        bool fishSpotIsMarshy = (this.Map.terrainGrid.TerrainAt(fishSpot) == TerrainDef.Named("Marsh"));

                        PawnKindDef caugthFishDef = null;
                        if (fishSpotIsOcean)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList(this.Map.Biome)
                                             where fishSpecies.livesInOcean
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else if (fishSpotIsMarshy)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList(this.Map.Biome)
                                             where fishSpecies.livesInMarsh
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList(this.Map.Biome)
                                             where fishSpecies.livesInRiver
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        Pawn caughtFish = PawnGenerator.GeneratePawn(caugthFishDef);
                        ExecutionUtility.DoExecutionByCut(this.pawn, caughtFish);
                        Corpse corpse = caughtFish.ParentHolder as Corpse;
                        GenSpawn.Spawn(corpse, this.pawn.Position, this.Map);
                        fishingCatch = corpse;
                        fishingCatch.SetForbidden(false);
                        if (caughtFish.BodySize >= 0.1f)
                        {
                            fishingPier.fishStock--;
                        }
                    }
                    IntVec3 storageCell;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(fishingCatch, this.pawn, this.Map, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true))
                    {
                        this.pawn.Reserve(fishingCatch, this.job);
                        this.pawn.Reserve(storageCell, this.job);
                        this.pawn.CurJob.SetTarget(TargetIndex.B, storageCell);
                        this.pawn.CurJob.SetTarget(TargetIndex.A, fishingCatch);
                        this.pawn.CurJob.count    = 9999;
                        this.pawn.CurJob.haulMode = HaulMode.ToCellStorage;
                    }
                    else
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    }
                }
            };

            yield return(catchFishToil);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));
        }
Ejemplo n.º 18
0
        public void Transfer(CoverageMap coverageMap)
        {
            //Planting blueprint
            float totalCost           = 0;
            int   transferredTerrains = 0;
            int   transferredTiles    = 0;
            int   totalTerrains       = 0;
            int   totalItems          = 0;

            //update rect to actual placement rect using width and height
            rp.rect = new CellRect(mapOriginX, mapOriginZ, blueprint.width, blueprint.height);

            Debug.Extra(Debug.BlueprintTransfer, "Clearing map...");

            for (int z = 0; z < blueprint.height; z++)
            {
                for (int x = 0; x < blueprint.width; x++)
                {
                    try {
                        IntVec3 mapLocation = new IntVec3(x + mapOriginX, 0, z + mapOriginZ);
                        //Check if thepoint is in allowed bounds of the map
                        if (!mapLocation.InBounds(map) || mapLocation.InNoBuildEdgeArea(map))
                        {
                            continue; //ignore invalid cells
                        }

                        if (options.overwritesEverything || Rand.Chance(0.6f))
                        {
                            if (blueprint.terrainMap[x, z] != null ||
                                blueprint.itemsMap[x, z].Count > 0 ||
                                blueprint.wallMap[x, z] > 1)
                            {
                                ClearCell(mapLocation, map, true);
                            }
                        }
                    } catch (Exception e) {
                        Debug.Warning(Debug.BlueprintTransfer, "Failed to clean cell at {0}, {1} because of {2}", x, z, e);
                    }
                }
            }

            Debug.Extra(Debug.BlueprintTransfer, "Transferring map objects");
            for (int z = 0; z < blueprint.height; z++)
            {
                for (int x = 0; x < blueprint.width; x++)
                {
                    IntVec3 mapLocation = new IntVec3(x + mapOriginX, 0, z + mapOriginZ);
                    if (coverageMap != null)
                    {
                        if (coverageMap.isMarked(mapLocation.x, mapLocation.z) == true) //cell was used earlier
                        {
                            continue;                                                   //skip already covered tiles
                        }
                        else
                        {
                            if (blueprint.wallMap[x, z] > 1 || blueprint.wallMap[x, z] == -1)
                            {
                                coverageMap.Mark(mapLocation.x, mapLocation.z);                                                               //mark cell as used
                            }
                        }
                    }


                    //Check if thepoint is in allowed bounds of the map
                    if (!mapLocation.InBounds(map) || mapLocation.InNoBuildEdgeArea(map))
                    {
                        continue; //ignore invalid cells
                    }

                    try {
                        //Construct terrain if some specific terrain stored in the blueprint
                        if (blueprint.terrainMap[x, z] != null)
                        {
                            totalTerrains++;
                            TerrainDef blueprintTerrain = TerrainDef.Named(blueprint.terrainMap[x, z].defName);
                            if (!map.terrainGrid.TerrainAt(mapLocation).IsWater)
                            {
                                map.terrainGrid.SetTerrain(mapLocation, blueprintTerrain);
                                totalCost += blueprint.terrainMap[x, z].cost;
                                transferredTerrains++;
                            }
                        }


                        //construct roof evetywhere if we doing complete transfer (ignoring outside: room with index 1).
                        if (blueprint.roofMap[x, z] == true && options.overwritesEverything && blueprint.wallMap[x, z] != 1)
                        {
                            map.roofGrid.SetRoof(mapLocation, RoofDefOf.RoofConstructed);
                        }


                        Debug.Extra(Debug.BlueprintTransfer, "Transferred terrain and roof at cell ({0}, {1})", x, z);
                    } catch (Exception e) {
                        Debug.Warning(Debug.BlueprintTransfer, "Failed to transfer terrain {0} at {1}, {2} because of {3}", blueprint.terrainMap[x, z].defName, x, z, e);
                    }

                    //Add items
                    if (blueprint.itemsMap[x, z] != null && blueprint.itemsMap[x, z].Count > 0 /* && cellUsed[mapLocation.x, mapLocation.z] == false*/)
                    {
                        totalItems += blueprint.itemsMap[x, z].Count;


                        foreach (ItemTile itemTile in blueprint.itemsMap[x, z])
                        {
                            Debug.Extra(Debug.BlueprintTransfer, "Creating thing {2} at cell ({0}, {1})", x, z, itemTile.defName);
                            Thing thing = MakeThingFromItemTile(itemTile);
                            if (thing != null)
                            {
                                try {
                                    Rot4 rotation = new Rot4(itemTile.rot);
                                    //check if there is anything we have to despawn in order to spawn our new item
                                    //we have to do this, because many dubs bad hygiene items enter endless cycle when removed during mapgen.
                                    foreach (IntVec3 occupiedCell in GenAdj.CellsOccupiedBy(mapLocation, rotation, thing.def.Size))
                                    {
                                        foreach (Thing existingItem in map.thingGrid.ThingsAt(occupiedCell).ToList())
                                        {
                                            if (GenSpawn.SpawningWipes(thing.def, existingItem.def))
                                            {
                                                if (thing.def.thingClass.ToString().Contains("DubsBadHygiene"))
                                                {
                                                    throw new Exception("Can't spawn item because it will destroy Dubs Bad Hygiene Item and it will lead to app freeze.");
                                                }
                                                existingItem.Destroy(DestroyMode.Vanish);
                                            }
                                        }
                                    }



                                    GenSpawn.Spawn(thing, mapLocation, map, rotation);
                                    Debug.Extra(Debug.BlueprintTransfer, "Spawned");
                                    try {
                                        switch (thing.def.tickerType)
                                        {
                                        case TickerType.Never:
                                            break;

                                        case TickerType.Normal:
                                            thing.Tick();
                                            break;

                                        case TickerType.Long:
                                            thing.TickLong();
                                            break;

                                        case TickerType.Rare:
                                            thing.TickRare();
                                            break;
                                        }
                                        //Debug.Message("Ticked");
                                    } catch (Exception e) {
                                        Debug.Log(Debug.BlueprintTransfer, "Exception while tried to perform tick for {0} of cost {1}, retrhrowing...", thing.def.defName, itemTile.cost);
                                        thing.Destroy();
                                        throw e;
                                    }

                                    //Debug.Message("Setting up props");
                                    //Breakdown breakdownables: it't yet impossible to silently breakdown an item which is not spawned.
                                    CompBreakdownable b = thing.TryGetComp <CompBreakdownable>();
                                    if (b != null && options.enableDeterioration)
                                    {
                                        if (Rand.Chance(0.8f))
                                        {
                                            b.DoBreakdown();
                                        }
                                    }

                                    //reduce HP for haulable things in water
                                    if (thing.def.EverHaulable)
                                    {
                                        TerrainDef t = map.terrainGrid.TerrainAt(mapLocation);
                                        if (t != null && t.IsWater)
                                        {
                                            thing.HitPoints = (thing.HitPoints - 10) / Rand.Range(5, 20) + Rand.Range(1, 10); //things in marsh or river are really in bad condition
                                        }
                                    }
                                    Debug.Extra(Debug.BlueprintTransfer, "Item completed");

                                    transferredTiles++;
                                    totalCost += itemTile.cost;
                                } catch (Exception e) {
                                    Debug.Warning(Debug.BlueprintTransfer, "Failed to spawn item {0} of cost {1} because of exception {2}", thing, itemTile.cost, e.Message);
                                    //ignore
                                }
                            }
                        }
                    }
                }
            }

            Debug.Log(Debug.BlueprintTransfer, "Finished transferring");
            if (options.shouldKeepDefencesAndPower)
            {
                RestoreDefencesAndPower();
            }
            options.uncoveredCost = totalCost;
            Debug.Log(Debug.BlueprintTransfer, "Transferred blueprint of size {0}x{1}, age {2}, total cost of approximately {3}. Items: {4}/{5}, terrains: {6}/{7}", blueprint.width, blueprint.height, -blueprint.dateShift, totalCost, transferredTiles, totalItems, transferredTerrains, totalTerrains);
        }
Ejemplo n.º 19
0
        public void doMapSpawns()
        {
            if (map.Biome.defName.Contains("AB_"))
            {
                foreach (SpecialSpawnsDef element in DefDatabase <SpecialSpawnsDef> .AllDefs.Where(element => element.allowedBiome == map.Biome.defName))
                {
                    IEnumerable <IntVec3> tmpTerrain = map.AllCells.InRandomOrder();


                    int extraGeneration = 0;
                    foreach (string biome in element.biomesWithExtraGeneration)
                    {
                        if (map.Biome.defName == biome)
                        {
                            extraGeneration = element.extraGeneration;
                        }
                    }

                    bool canSpawn = true;
                    if (spawnCounter == 0)
                    {
                        spawnCounter = Rand.RangeInclusive(element.numberToSpawn.min, element.numberToSpawn.max) + extraGeneration;
                        //Log.Message(spawnCounter.ToString());
                    }
                    foreach (IntVec3 c in tmpTerrain)
                    {
                        TerrainDef terrain = c.GetTerrain(map);


                        bool flagAllowed = true;
                        foreach (string allowed in element.terrainValidationAllowed)
                        {
                            if (terrain.defName == allowed)
                            {
                                break;
                            }
                            else
                            {
                                flagAllowed = false;
                            }
                        }
                        bool flagDisallowed = true;
                        foreach (string notAllowed in element.terrainValidationDisallowed)
                        {
                            if (terrain.HasTag(notAllowed))
                            {
                                flagDisallowed = false;
                                break;
                            }
                        }
                        bool flagWater = true;
                        if (!element.allowOnWater && terrain.IsWater)
                        {
                            flagWater = false;
                        }
                        bool flagCenter = true;
                        if (element.findCellsOutsideColony)
                        {
                            if (!OutOfCenter(c, map, 60))
                            {
                                flagCenter = false;
                            }
                        }
                        canSpawn = flagAllowed & flagDisallowed & flagWater & flagCenter;
                        if (canSpawn)
                        {
                            // Log.Message("Sucesful c was " + c.ToString());
                            Thing    thing        = (Thing)ThingMaker.MakeThing(element.thingDef, null);
                            CellRect occupiedRect = GenAdj.OccupiedRect(c, thing.Rotation, thing.def.Size);
                            if (occupiedRect.InBounds(map))
                            {
                                // Log.Message("Prior to " + element.defName + " .Spawncounter was " + spawnCounter);
                                GenSpawn.Spawn(thing, c, map);
                                spawnCounter--;
                                // Log.Message("Spawning " + element.defName + " .Spawncounter was " + spawnCounter);
                            }
                        }
                        if (canSpawn && spawnCounter <= 0)
                        {
                            //Log.Message("Spawn counter is " + spawnCounter + " So I'm getting out");
                            spawnCounter = 0;
                            break;
                        }
                    }
                }
            }



            this.verifyFirstTime = false;
        }
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
        {
            TerrainDef terrainDef = map.terrainGrid.TerrainAt(loc);

            if (terrainDef.defName.Contains("Bridge"))
            {
                return(new AcceptanceReport("RAB.NoFloorOnBridge".Translate()));
            }
            List <Thing> things = map.thingGrid.ThingsListAtFast(loc);

            for (int k = 0; k < things.Count; k++)
            {
                if (things[k] != thingToIgnore)
                {
                    if (things[k].def.defName.Contains("RBB_") || things[k].def.defName.Contains("Wall"))
                    {
                        return(new AcceptanceReport("RAB.NoFloorOnBridge".Translate()));
                    }
                }
            }
            if (terrainDef.defName.Equals("MarshyTerrain") || terrainDef.defName.Equals("Mud"))
            {
                return(true);
            }
            string waterNear = "no";

            for (int i = -1; i < 2; i++)
            {
                for (int j = -1; j < 2; j++)
                {
                    int     x            = loc.x + i;
                    int     z            = loc.z + j;
                    IntVec3 newSpot      = new IntVec3(x, 0, z);
                    string  terrainCheck = map.terrainGrid.TerrainAt(newSpot).defName;
                    if (terrainCheck.Contains("Water") || terrainCheck.Equals("Marsh") || terrainCheck.Contains("BridgeMarsh") || terrainCheck.Contains("Mud") || terrainCheck.Contains("MarshyTerrain"))
                    {
                        waterNear = "yes";
                        break;
                    }
                }
            }
            if (waterNear == "no")
            {
                for (int i = -2; i < 3; i++)
                {
                    for (int j = -2; j < 3; j++)
                    {
                        int     x            = loc.x + i;
                        int     z            = loc.z + j;
                        IntVec3 newSpot      = new IntVec3(x, 0, z);
                        string  terrainCheck = map.terrainGrid.TerrainAt(newSpot).defName;
                        if (terrainCheck.Contains("Water") || terrainCheck.Equals("Marsh") || terrainCheck.Contains("BridgeMarsh") || terrainCheck.Contains("Mud") || terrainCheck.Contains("MarshyTerrain"))
                        {
                            waterNear = "yes";
                            break;
                        }
                    }
                }
            }
            if (waterNear == "no")
            {
                for (int i = -3; i < 4; i++)
                {
                    for (int j = -3; j < 4; j++)
                    {
                        int     x            = loc.x + i;
                        int     z            = loc.z + j;
                        IntVec3 newSpot      = new IntVec3(x, 0, z);
                        string  terrainCheck = map.terrainGrid.TerrainAt(newSpot).defName;
                        if (terrainCheck.Contains("Water") || terrainCheck.Equals("Marsh") || terrainCheck.Contains("BridgeMarsh") || terrainCheck.Contains("Mud") || terrainCheck.Contains("MarshyTerrain"))
                        {
                            waterNear = "yes";
                            break;
                        }
                    }
                }
            }
            if (waterNear == "yes")
            {
                return(true);
            }
            return(new AcceptanceReport("RAB.Boardwalk".Translate()));
        }
Ejemplo n.º 21
0
 public static bool IsSea(this TerrainDef def)
 {
     return(def.defName.Contains("WaterOcean"));
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Check if a new fishing pier can be built at this location.
        /// - the fishing pier bank cell must be on a bank.
        /// - the rest of the fishing pier and the fishing spot must be on water.
        /// - must not be too near from another fishing pier.
        /// </summary>
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            IntVec3    checkedPosition       = new IntVec3();
            TerrainDef checkedCellTerrainDef = null;

            // Check fishing pier bank cell is "solid" terrain.
            checkedPosition       = loc + new IntVec3(0, 0, -2).RotatedBy(rot);
            checkedCellTerrainDef = Find.TerrainGrid.TerrainAt(checkedPosition);
            if ((checkedCellTerrainDef == TerrainDef.Named("WaterShallow")) ||
                (checkedCellTerrainDef == TerrainDef.Named("WaterDeep")) ||
                (checkedCellTerrainDef == TerrainDef.Named("Marsh")))
            {
                return(new AcceptanceReport("Fishing pier must be placed on a bank."));
            }
            // Check the rest of fishing pier is on water.
            for (int yOffset = -1; yOffset <= 0; yOffset++)
            {
                checkedPosition       = loc + new IntVec3(0, 0, yOffset).RotatedBy(rot);
                checkedCellTerrainDef = Find.TerrainGrid.TerrainAt(checkedPosition);
                if ((checkedCellTerrainDef != TerrainDef.Named("WaterShallow")) &&
                    (checkedCellTerrainDef != TerrainDef.Named("WaterDeep")) &&
                    (checkedCellTerrainDef != TerrainDef.Named("Marsh")))
                {
                    return(new AcceptanceReport("Fishing pier must be placed on water."));
                }
            }
            // Check the fishing spot is on water.
            for (int xOffset = -1; xOffset <= 1; xOffset++)
            {
                for (int yOffset = 1; yOffset <= 3; yOffset++)
                {
                    checkedPosition       = loc + new IntVec3(xOffset, 0, yOffset).RotatedBy(rot);
                    checkedCellTerrainDef = Find.TerrainGrid.TerrainAt(checkedPosition);
                    if ((checkedCellTerrainDef != TerrainDef.Named("WaterShallow")) &&
                        (checkedCellTerrainDef != TerrainDef.Named("WaterDeep")) &&
                        (checkedCellTerrainDef != TerrainDef.Named("Marsh")))
                    {
                        return(new AcceptanceReport("Fishing spot must be placed on water."));
                    }
                }
            }

            // Check if another fishing pier is not too close (mind the test on "fishing pier" def and "fishing pier spawner" blueprint and frame defs.
            List <Thing> fishingPierList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierDef);
            List <Thing> fishingPierSpawnerBlueprintList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierSpawnerDef.blueprintDef);
            List <Thing> fishingPierSpawnerFrameList     = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierSpawnerDef.frameDef);

            if (fishingPierList != null)
            {
                IEnumerable <Thing> fishingPierInTheArea = fishingPierList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers));
                if (fishingPierInTheArea.Count() > 0)
                {
                    return(new AcceptanceReport("An other fishing pier is too close."));
                }
            }
            if (fishingPierSpawnerBlueprintList != null)
            {
                IEnumerable <Thing> fishingPierBlueprintInTheArea = fishingPierSpawnerBlueprintList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers));
                if (fishingPierBlueprintInTheArea.Count() > 0)
                {
                    return(new AcceptanceReport("An other fishing pier blueprint is too close."));
                }
            }
            if (fishingPierSpawnerFrameList != null)
            {
                IEnumerable <Thing> fishingPierFrameInTheArea = fishingPierSpawnerFrameList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers));
                if (fishingPierFrameInTheArea.Count() > 0)
                {
                    return(new AcceptanceReport("An other fishing pier frame is too close."));
                }
            }

            return(true);
        }
Ejemplo n.º 23
0
 public static bool IsLakeOrPond(this TerrainDef def)
 {
     return(!def.IsSea() && !def.IsRiver() && def.defName.Contains("Water"));
 }
        public static IEnumerable <TerrainDef> ImpliedTerrainDefs()
        {
            int i = 0;

            foreach (ThingDef rock in from def in DefDatabase <ThingDef> .AllDefs
                     where def.building != null && def.building.isNaturalRock && !def.building.isResourceRock
                     select def)
            {
                TerrainDef rough  = new TerrainDef();
                TerrainDef hewn   = new TerrainDef();
                TerrainDef smooth = new TerrainDef();
                rough.texturePath = "Terrain/Surfaces/RoughStone";
                rough.edgeType    = TerrainDef.TerrainEdgeType.FadeRough;
                rough.pathCost    = 1;
                StatUtility.SetStatValueInList(ref rough.statBases, StatDefOf.Beauty, -1f);
                rough.scatterType = "Rocky";
                rough.affordances = new List <TerrainAffordance>();
                rough.affordances.Add(TerrainAffordance.Light);
                rough.affordances.Add(TerrainAffordance.Heavy);
                rough.affordances.Add(TerrainAffordance.SmoothableStone);
                rough.fertility        = 0f;
                rough.renderPrecedence = 190 + i;
                rough.defName          = rock.defName + "_Rough";
                rough.label            = "RoughStoneTerrainLabel".Translate(new object[]
                {
                    rock.label
                });
                rough.description = "RoughStoneTerrainDesc".Translate(new object[]
                {
                    rock.label
                });
                rough.color         = rock.graphicData.color;
                rock.naturalTerrain = rough;
                hewn.texturePath    = "Terrain/Surfaces/RoughHewnRock";
                hewn.edgeType       = TerrainDef.TerrainEdgeType.FadeRough;
                hewn.pathCost       = 1;
                StatUtility.SetStatValueInList(ref hewn.statBases, StatDefOf.Beauty, -1f);
                hewn.scatterType = "Rocky";
                hewn.affordances = new List <TerrainAffordance>();
                hewn.affordances.Add(TerrainAffordance.Light);
                hewn.affordances.Add(TerrainAffordance.Heavy);
                hewn.affordances.Add(TerrainAffordance.SmoothableStone);
                hewn.fertility        = 0f;
                hewn.renderPrecedence = 50 + i;
                hewn.defName          = rock.defName + "_RoughHewn";
                hewn.label            = "RoughHewnStoneTerrainLabel".Translate(new object[]
                {
                    rock.label
                });
                hewn.description = "RoughHewnStoneTerrainDesc".Translate(new object[]
                {
                    rock.label
                });
                hewn.color         = rock.graphicData.color;
                rock.leaveTerrain  = hewn;
                smooth.texturePath = "Terrain/Surfaces/SmoothStone";
                smooth.edgeType    = TerrainDef.TerrainEdgeType.FadeRough;
                smooth.pathCost    = 0;
                StatUtility.SetStatValueInList(ref smooth.statBases, StatDefOf.Beauty, 2f);
                smooth.scatterType = "Rocky";
                smooth.affordances = new List <TerrainAffordance>();
                smooth.affordances.Add(TerrainAffordance.Light);
                smooth.affordances.Add(TerrainAffordance.Heavy);
                smooth.affordances.Add(TerrainAffordance.SmoothHard);
                smooth.fertility = 0f;
                smooth.acceptTerrainSourceFilth = true;
                smooth.renderPrecedence         = 140 + i;
                smooth.defName = rock.defName + "_Smooth";
                smooth.label   = "SmoothStoneTerrainLabel".Translate(new object[]
                {
                    rock.label
                });
                smooth.description = "SmoothStoneTerrainDesc".Translate(new object[]
                {
                    rock.label
                });
                smooth.color          = rock.graphicData.color;
                rough.smoothedTerrain = smooth;
                hewn.smoothedTerrain  = smooth;
                yield return(rough);
            }
        }
Ejemplo n.º 25
0
 public static bool IsIce(this TerrainDef def)
 {
     return(def.defName == "Ice");
 }
        private bool ShouldDrawPropsBelow(IntVec3 c, TerrainGrid terrGrid)
        {
            TerrainDef terrainDef = terrGrid.TerrainAt(c);

            if (terrainDef == null || terrainDef != TerrainDef.Named("AB_AsphaltBridge"))
            {
                return(false);
            }
            IntVec3 c2 = c;

            c2.z--;
            Map map = base.Map;

            if (!c2.InBounds(map))
            {
                return(false);
            }
            TerrainDef terrainDef2 = terrGrid.TerrainAt(c2);

            return(terrainDef2 != TerrainDef.Named("AB_AsphaltBridge") && (terrainDef2.passability == Traversability.Impassable || c2.SupportsStructureType(map, TerrainDef.Named("AB_AsphaltBridge").terrainAffordanceNeeded)));
        }
Ejemplo n.º 27
0
 public static bool CanGetWater(this TerrainDef def)
 {
     return(def.IsRiver() || def.IsLakeOrPond() || def.IsMarsh() || def.IsSea());
 }
Ejemplo n.º 28
0
        public int CalculatedCostAt(IntVec3 c, bool perceivedStatic, IntVec3 prevCell)
        {
            int        num        = 0;
            TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(c);

            if (terrainDef == null || terrainDef.passability == Traversability.Impassable)
            {
                num = 10000;
            }
            else
            {
                num += terrainDef.pathCost;
            }
            int num2 = SnowUtility.MovementTicksAddOn(this.map.snowGrid.GetCategory(c));

            num += num2;
            List <Thing> list = this.map.thingGrid.ThingsListAt(c);

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing = list[i];
                if (thing.def.passability == Traversability.Impassable)
                {
                    return(10000);
                }
                if (!PathGrid.IsPathCostIgnoreRepeater(thing.def) || !prevCell.IsValid || !this.ContainsPathCostIgnoreRepeater(prevCell))
                {
                    num += thing.def.pathCost;
                }
                if (prevCell.IsValid && thing is Building_Door)
                {
                    Building edifice = prevCell.GetEdifice(this.map);
                    if (edifice != null && edifice is Building_Door)
                    {
                        num += 45;
                    }
                }
            }
            if (perceivedStatic)
            {
                for (int j = 0; j < 9; j++)
                {
                    IntVec3 b  = GenAdj.AdjacentCellsAndInside[j];
                    IntVec3 c2 = c + b;
                    if (c2.InBounds(this.map))
                    {
                        Fire fire = null;
                        list = this.map.thingGrid.ThingsListAtFast(c2);
                        for (int k = 0; k < list.Count; k++)
                        {
                            fire = (list[k] as Fire);
                            if (fire != null)
                            {
                                break;
                            }
                        }
                        if (fire != null && fire.parent == null)
                        {
                            if (b.x == 0 && b.z == 0)
                            {
                                num += 1000;
                            }
                            else
                            {
                                num += 150;
                            }
                        }
                    }
                }
            }
            return(num);
        }
Ejemplo n.º 29
0
        public static void GenerateEntranchedZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);
            IntVec3 cell          = rotatedOrigin;

            // Generate south west battery shelter.
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(0, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(3, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(0, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            for (int xOffset = 0; xOffset < 4; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
                    Find.RoofGrid.SetRoof(cell, OG_Util.IronedRoofDef);
                }
            }

            // Generate south east battery shelter.
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(7, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(10, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(7, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(10, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(9, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            for (int xOffset = 7; xOffset < 11; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
                    Find.RoofGrid.SetRoof(cell, OG_Util.IronedRoofDef);
                }
            }

            // Generate central paved alley.
            for (int xOffset = 4; xOffset <= 6; xOffset++)
            {
                for (int zOffset = 0; zOffset < 7; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = 0; zOffset < 7; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Generate north west force field.
            IntVec3 northWestOrigin = rotatedOrigin + new IntVec3(0, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 0; zOffset < 2; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int xOffset = 1; xOffset <= 3; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, 2).RotatedBy(rotation), TerrainDefOf.Concrete);
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            for (int zOffset = -3; zOffset <= 3; zOffset++)
            {
                if ((zOffset == 1) &&
                    OG_Util.IsModActive("MiningCo. ForceField"))
                {
                    // Do not spawn power conduit under force field as it generates a warning message.
                    continue;
                }
                OG_Common.SpawnFireproofPowerConduitAt(northWestOrigin + new IntVec3(2, 0, zOffset).RotatedBy(rotation), ref outpostData);
            }
            if (OG_Util.IsModActive("MiningCo. ForceField"))
            {
                OG_Common.TrySpawnThingAt(OG_Util.ForceFieldGeneratorDef, null, northWestOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            }

            // Generate central sandbag.
            cell = rotatedOrigin + new IntVec3(5, 0, 7).RotatedBy(rotation);
            Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);

            // Generate north east force field.
            IntVec3 northEastOrigin = rotatedOrigin + new IntVec3(6, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 0; zOffset < 2; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(northEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int xOffset = 1; xOffset <= 3; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(northEastOrigin + new IntVec3(xOffset, 0, 2).RotatedBy(rotation), TerrainDefOf.Concrete);
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(3, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            for (int zOffset = -3; zOffset <= 3; zOffset++)
            {
                if ((zOffset == 1) &&
                    OG_Util.IsModActive("MiningCo. ForceField"))
                {
                    // Do not spawn power conduit under force field as it generates a warning message.
                    continue;
                }
                OG_Common.SpawnFireproofPowerConduitAt(northEastOrigin + new IntVec3(2, 0, zOffset).RotatedBy(rotation), ref outpostData);
            }
            if (OG_Util.IsModActive("MiningCo. ForceField"))
            {
                OG_Common.TrySpawnThingAt(OG_Util.ForceFieldGeneratorDef, null, northEastOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            }
        }
Ejemplo n.º 30
0
        private void MakeBlueprintRoom(CellRect mapRect, Map map, MapGeneratorBlueprintDef blueprint, ThingDef stuffDef)
        {
            blueprint.buildingData = CleanUpBlueprintData(blueprint.buildingData);
            blueprint.floorData    = CleanUpBlueprintData(blueprint.floorData);
            blueprint.pawnData     = CleanUpBlueprintData(blueprint.pawnData);
            blueprint.itemData     = CleanUpBlueprintData(blueprint.itemData);

            if (blueprint.buildingData == null && blueprint.floorData == null)
            {
                Log.ErrorOnce(string.Format("After cleaning the BlueprintData and FloorData of blueprint {0} -> both are null, nothing will be done!", blueprint.defName), 313001);
                return;
            }

            IntVec3 spawnBaseCell = new IntVec3(mapRect.BottomLeft.x, mapRect.TopRight.y, mapRect.TopRight.z);
            IntVec3 spawnCell;

            foreach (IntVec3 cell in mapRect)
            {
                // Check all cells and abort if there is something indestructible found
                if (!CheckCell(cell, map))
                {
                    return;
                }
            }

            allSpawnedPawns = null;
            try
            {
                // Work through blueprint. Note: top-left to bottom-right
                for (int zn = 0; zn < blueprint.size.z; zn++)
                {
                    for (int x = 0; x < blueprint.size.x; x++)
                    {
                        //// map can be clipped, don't work with the clipped parts
                        //if (x > mapRect.Width - 1 || zn > mapRect.Height - 1)
                        //    continue;

                        spawnCell = spawnBaseCell + new IntVec3(x, 0, -zn);

                        int         itemPos     = x + blueprint.size.x * zn;
                        ThingDef    thingDef    = TryGetThingDefFromBuildingData(blueprint, itemPos);
                        Rot4        thingRot    = TryGetRotationFromBuildingData(blueprint, itemPos);
                        TerrainDef  terrainDef  = TryGetTerrainDefFromFloorData(blueprint, itemPos);
                        PawnKindDef pawnKindDef = TryGetPawnKindDefFromPawnData(blueprint, itemPos);
                        ThingDef    itemDef     = TryGetItemDefFromItemData(blueprint, itemPos);

                        List <Thing> list = map.thingGrid.ThingsListAt(spawnCell);
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i].def == thingDef)
                            {
                                continue;
                            }
                        }

                        //Only clear the space, if something will be made here
                        if (thingDef != null || terrainDef != null || pawnKindDef != null || itemDef != null)
                        {
                            ClearCell(spawnCell, map);
                        }

                        if ((blueprint.canHaveHoles ||
                             (MapGenerator_ModSettings.createAllNonPawnBPsWithHoles && (blueprint.pawnLegend == null || blueprint.pawnLegend.Count <= 0))) &&
                            Rand.Value < MapGenerator_ModSettings.chanceForHoles)
                        {
                            continue;
                        }

                        // If placed on water, increase the hole chance, if no pawns are to be placed!
                        if (spawnCell.GetTerrain(map).defName.ToLower().Contains("water") &&
                            (blueprint.pawnLegend == null || blueprint.pawnLegend.Count <= 0) &&
                            Rand.Value < MapGenerator_ModSettings.chanceForHolesOnWater)
                        {
                            continue;
                        }

                        TrySetCellAs(spawnCell, map, thingDef, thingRot, stuffDef, terrainDef, pawnKindDef, itemDef, blueprint);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Warning("Misc. MapGenerator -- Error with blueprint '" + blueprint.defName + "'. Placement position at " +
                            mapRect.CenterCell.ToString() + " on a map of the size " + map.Size.ToString() + "\n" +
                            ex.Message + "\n" + ex.StackTrace);
            }


            // If pawns are spawned, place ancient shrine trigger
            if (allSpawnedPawns != null && allSpawnedPawns.Count > 0)
            {
                int    nextSignalTagID = Find.UniqueIDsManager.GetNextSignalTagID();
                string signalTag       = "ancientTempleApproached-" + nextSignalTagID;
                SignalAction_Letter signalAction_Letter = (SignalAction_Letter)ThingMaker.MakeThing(ThingDefOf.SignalAction_Letter, null);
                signalAction_Letter.signalTag = signalTag;
                signalAction_Letter.letter    = LetterMaker.MakeLetter("LetterLabelAncientShrineWarning".Translate(), "AncientShrineWarning".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(mapRect.CenterCell, map, false));
                GenSpawn.Spawn(signalAction_Letter, mapRect.CenterCell, map);
                RectTrigger rectTrigger = (RectTrigger)ThingMaker.MakeThing(ThingDefOf.RectTrigger, null);
                rectTrigger.signalTag         = signalTag;
                rectTrigger.Rect              = mapRect.ExpandedBy(1).ClipInsideMap(map);
                rectTrigger.destroyIfUnfogged = true;
                GenSpawn.Spawn(rectTrigger, mapRect.CenterCell, map);
            }

            // also if pawns are spawned make the appropriate LordJob
            LordJob lordJob;

            if (allSpawnedPawns != null && allSpawnedPawns.Count > 0)
            {
                if (blueprint.factionSelection == FactionSelection.friendly)
                {
                    lordJob = new LordJob_AssistColony(allSpawnedPawns[0].Faction, allSpawnedPawns[0].Position);
                }
                else
                {
                    if (Rand.Value < 0.5f)
                    {
                        lordJob = new LordJob_DefendPoint(allSpawnedPawns[0].Position);
                    }
                    else
                    {
                        lordJob = new LordJob_AssaultColony(allSpawnedPawns[0].Faction, false, false, false, false, false);
                    }
                }
                LordMaker.MakeNewLord(allSpawnedPawns[0].Faction, lordJob, map, allSpawnedPawns);

                allSpawnedPawns = null;
            }
        }
Ejemplo n.º 31
0
        public static void GenerateBigSasZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, bool generateSecondarySas, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);
            IntVec3 cell          = rotatedOrigin;

            OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(3, 0, -1).RotatedBy(rotation), 5, 13, rotation, null, null, ref outpostData);

            // Spawn lamps.
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(4, 0, 2).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(4, 0, 8).RotatedBy(rotation), Color.white, ref outpostData);

            // Spawn floor and roof.
            for (int xOffset = 2; xOffset <= 8; xOffset++)
            {
                for (int zOffset = 0; zOffset < 11; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = 0; zOffset < 11; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Spawn doors.
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, -1).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 11).RotatedBy(rotation), ref outpostData);

            // Spawn secondary sas.
            if (generateSecondarySas)
            {
                OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(3, 0, 4).RotatedBy(rotation), 3, 6, new Rot4(rotation.AsInt + Rot4.West.AsInt), null, null, ref outpostData);

                // Spawn concrete and paved alley (don't use standard default floor as it may overlap existing medium room floor).
                for (int xOffset = -2; xOffset <= 4; xOffset++)
                {
                    for (int zOffset = 3; zOffset <= 7; zOffset++)
                    {
                        Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                    }
                }
                for (int xOffset = -2; xOffset <= 4; xOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
                }
                // Spawn doors.
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(-2, 0, 5).RotatedBy(rotation), ref outpostData);
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(3, 0, 5).RotatedBy(rotation), ref outpostData);
            }
        }
Ejemplo n.º 32
0
        // Fill the cell
        private void TrySetCellAs(IntVec3 c, Map map, ThingDef thingDef, Rot4 thingRot, ThingDef stuffDef = null, TerrainDef terrainDef = null,
                                  PawnKindDef pawnKindDef = null, ThingDef itemDef = null, MapGeneratorBlueprintDef blueprint = null)
        {
            //Note: Here is no functionality to clear the cell by design, because it is possible to place items that are larger than 1x1

            // Check the cell information
            if (c == null || !c.InBounds(map))
            {
                Log.Warning("GenStep_CreateBlueprint: Invalid Target-Cell: cell is null or out of bounds.");
                return;
            }

            // only continue to do work if here isn't anything indestructable
            List <Thing> thingList = c.GetThingList(map);

            for (int i = 0; i < thingList.Count; i++)
            {
                if (!thingList[i].def.destroyable)
                {
                    return;
                }
            }

            // 1st step - work with the Terrain
            if (terrainDef != null)
            {
                map.terrainGrid.SetTerrain(c, terrainDef);
            }
            else if (terrainDef == null && thingDef != null && stuffDef != null)
            {
                map.terrainGrid.SetTerrain(c, this.CorrespondingTileDef(stuffDef));
            }

            // 2nd step - work with the Thing (Buildings)
            if (thingDef != null)
            {
                ThingDef stuffDef1 = stuffDef;

                if (!thingDef.MadeFromStuff)
                {
                    stuffDef1 = null;
                }

                Thing newThing = ThingMaker.MakeThing(thingDef, stuffDef1);
                if (thingRot == null || thingRot == Rot4.Invalid)
                {
                    GenSpawn.Spawn(newThing, c, map);
                }
                else
                {
                    GenSpawn.Spawn(newThing, c, map, thingRot);
                }

                CompGatherSpot compGathering = newThing.TryGetComp <CompGatherSpot>();
                if (compGathering != null)
                {
                    compGathering.Active = false;
                }
            }

            // The following needs blueprint data to work
            if (blueprint == null)
            {
                return;
            }

            // 3rd step - work with the Item
            //if (itemDef != null) // && blueprint.itemSpawnChance / 100 > Rand.Value)
            if (itemDef != null && blueprint.itemSpawnChance / 100 > Rand.Value)
            {
                ThingDef stuffDef2;
                if (itemDef.IsApparel)
                {
                    if (!DefDatabase <ThingDef> .AllDefs.Where <ThingDef>(t => t.IsStuff &&
                                                                          t.stuffProps != null && t.stuffProps.categories != null && t.stuffProps.categories.Contains(StuffCategoryDefOf.Fabric))
                        .TryRandomElement(out stuffDef2))
                    {
                        stuffDef2 = DefDatabase <ThingDef> .GetNamedSilentFail("Synthread");
                    }
                }
                else
                {
                    List <string> stuffPossibles = new List <string>()
                    {
                        "Steel", "Steel", "Steel", "Steel", "Silver", "Gold", "Jade", "Plasteel"
                    };
                    stuffDef2 = DefDatabase <ThingDef> .GetNamedSilentFail(stuffPossibles.RandomElement());
                }

                if (!itemDef.MadeFromStuff)
                {
                    stuffDef2 = null;
                }

                Thing newItem = TryGetTreasure(itemDef, stuffDef2);

                newItem = GenSpawn.Spawn(newItem, c, map);
                // Don't forget to set the items to forbidden!
                if (newItem.TryGetComp <CompForbiddable>() != null)
                {
                    newItem.SetForbidden(true, false);
                }

                // If it is a hive, it needs to be deactivated
                Hive newHive = newItem as Hive;
                if (newHive != null)
                {
                    newHive.active = false;
                }
            }


            // 4th step - work with the Pawn
            if (pawnKindDef != null && blueprint.pawnSpawnChance / 100 > Rand.Value)
            {
                if (this.faction == null)
                {
                    this.faction = Find.FactionManager.FirstFactionOfDef(blueprint.factionDef);
                }

                float pointsForRaid = map.IncidentPointsRandomFactorRange.RandomInRange;

                // still null - find a valid faction.
                if (this.faction == null)
                {
                    switch (blueprint.factionSelection)
                    {
                    case FactionSelection.friendly:
                        faction = (from fac in Find.FactionManager.AllFactions
                                   where !fac.HostileTo(Faction.OfPlayer) && fac.PlayerGoodwill > 0 && !(fac == Faction.OfPlayer)
                                   select fac)
                                  .RandomElementByWeight((Faction fac) => 101 - fac.def.RaidCommonalityFromPoints(pointsForRaid));

                        if (faction == null)
                        {
                            faction = Find.FactionManager.AllFactions.RandomElementByWeight((Faction fac) => fac.def.RaidCommonalityFromPoints(pointsForRaid));
                        }

                        break;

                    case FactionSelection.hostile:
                        faction = (from fac in Find.FactionManager.AllFactions
                                   where fac.HostileTo(Faction.OfPlayer)
                                   select fac)
                                  .RandomElementByWeight((Faction fac) => 101 - fac.def.RaidCommonalityFromPoints(pointsForRaid));

                        if (faction == null)
                        {
                            faction = Faction.OfMechanoids;
                        }

                        break;

                    case FactionSelection.none:
                        faction = Find.FactionManager.AllFactions
                                  .RandomElementByWeight((Faction fac) => fac.def.RaidCommonalityFromPoints(pointsForRaid));

                        if (faction == null)
                        {
                            faction = Faction.OfMechanoids;
                        }

                        break;
                    }
                }

                Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, faction);
                pawn.mindState.Active = false;
                pawn = GenSpawn.Spawn(pawn, c, map) as Pawn;

                if (pawn != null)
                {
                    if (allSpawnedPawns == null)
                    {
                        allSpawnedPawns = new List <Pawn>();
                    }

                    allSpawnedPawns.Add(pawn);
                }
            }
        }
Ejemplo n.º 33
0
        protected override bool TryCastShot()
        {
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      eff  = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_EarthSprites.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EarthSprites_eff");
            MagicPowerSkill      ver  = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_EarthSprites.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EarthSprites_ver");

            effVal = eff.level;
            verVal = ver.level;

            if (!(comp.maxMP < .6f - (.07f * verVal)))
            {
                if (this.currentTarget.IsValid && this.currentTarget.CenterVector3.InBounds(base.CasterPawn.Map))
                {
                    Building   isBuilding = null;
                    TerrainDef terrain    = null;
                    isBuilding = this.currentTarget.Cell.GetFirstBuilding(this.CasterPawn.Map);
                    terrain    = this.currentTarget.Cell.GetTerrain(this.CasterPawn.Map);
                    //Log.Message("terrain type is " + terrain.defName);
                    if (isBuilding != null)
                    {
                        var mineable = isBuilding as Mineable;
                        if (mineable != null)
                        {
                            Area spriteArea = TM_Calc.GetSpriteArea();
                            if (spriteArea != null && spriteArea.ActiveCells != null && spriteArea.ActiveCells.Contains(this.currentTarget.Cell))
                            {
                                comp.earthSpritesInArea = true;
                            }
                            comp.earthSprites          = this.currentTarget.Cell;
                            comp.earthSpriteType       = 1;
                            comp.earthSpriteMap        = this.CasterPawn.Map;
                            comp.nextEarthSpriteAction = Find.TickManager.TicksGame + 300;
                        }
                        else
                        {
                            Messages.Message("TM_InvalidTarget".Translate(
                                                 this.CasterPawn.LabelShort,
                                                 "Earth Sprites"
                                                 ), MessageTypeDefOf.RejectInput);
                        }
                    }
                    else if (terrain != null && (terrain.defName == "MarshyTerrain" || terrain.defName == "Mud" || terrain.defName == "Marsh" || terrain.defName == "WaterShallow" || terrain.defName == "Ice" ||
                                                 terrain.defName == "Sand" || terrain.defName == "Gravel" || terrain.defName == "Soil" || terrain.defName == "MossyTerrain" || terrain.defName == "SoftSand"))
                    {
                        Area spriteArea = TM_Calc.GetSpriteArea();
                        if (spriteArea != null && spriteArea.ActiveCells != null && spriteArea.ActiveCells.Contains(this.currentTarget.Cell))
                        {
                            comp.earthSpritesInArea = true;
                        }
                        comp.earthSprites          = this.currentTarget.Cell;
                        comp.earthSpriteType       = 2;
                        comp.earthSpriteMap        = this.CasterPawn.Map;
                        comp.nextEarthSpriteAction = Find.TickManager.TicksGame + 20000;
                    }
                    else if (terrain != null && !terrain.defName.Contains("water") && !terrain.defName.Contains("Water"))
                    {
                        ShatterTerrain(this.currentTarget.Cell, terrain);
                    }
                    else
                    {
                        Messages.Message("TM_InvalidTarget".Translate(
                                             this.CasterPawn.LabelShort,
                                             "Earth Sprites"
                                             ), MessageTypeDefOf.RejectInput);
                    }
                }
                else
                {
                    Messages.Message("TM_InvalidTarget".Translate(
                                         this.CasterPawn.LabelShort,
                                         "Earth Sprites"
                                         ), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Messages.Message("TM_NotEnoughMaxMana".Translate(
                                     this.CasterPawn.LabelShort,
                                     "Earth Sprites"
                                     ), MessageTypeDefOf.RejectInput);
            }

            this.burstShotsLeft = 0;
            return(false);
        }
Ejemplo n.º 34
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);
         }
     }
 }