public override bool TryExecute(IncidentParms parms)
        {
            Map     map          = (Map)parms.target;
            int     num          = 0;
            int     countToSpawn = this.CountToSpawn;
            IntVec3 cell         = IntVec3.Invalid;
            float   angle        = Rand.Range(0f, 360f);

            for (int i = 0; i < countToSpawn; i++)
            {
                Predicate <IntVec3> validator = delegate(IntVec3 c)
                {
                    if (c.Fogged(map))
                    {
                        return(false);
                    }
                    foreach (IntVec3 current in GenAdj.CellsOccupiedBy(c, Rot4.North, this.def.shipPart.size))
                    {
                        if (!current.Standable(map))
                        {
                            bool result = false;
                            return(result);
                        }
                        if (map.roofGrid.Roofed(current))
                        {
                            bool result = false;
                            return(result);
                        }
                    }
                    return(map.reachability.CanReachColony(c));
                };
                IntVec3 intVec;
                if (!CellFinderLoose.TryFindRandomNotEdgeCellWith(14, validator, map, out intVec))
                {
                    break;
                }
                GenExplosion.DoExplosion(intVec, map, 3f, DamageDefOf.Flame, null, null, null, null, null, 0f, 1, false, null, 0f, 1);
                Building_CrashedShipPart building_CrashedShipPart = (Building_CrashedShipPart)GenSpawn.Spawn(this.def.shipPart, intVec, map);
                building_CrashedShipPart.SetFaction(Faction.OfMechanoids, null);
                building_CrashedShipPart.pointsLeft = parms.points * 0.9f;
                if (building_CrashedShipPart.pointsLeft < 300f)
                {
                    building_CrashedShipPart.pointsLeft = 300f;
                }
                IncidentWorker_ShipPartCrash.SpawnShrapnel(ThingDefOf.ChunkSlagSteel, IncidentWorker_ShipPartCrash.ShrapnelMetal.RandomInRange, intVec, map, angle);
                IncidentWorker_ShipPartCrash.SpawnShrapnel(ThingDefOf.SlagRubble, IncidentWorker_ShipPartCrash.ShrapnelRubble.RandomInRange, intVec, map, angle);
                num++;
                cell = intVec;
            }
            if (num > 0)
            {
                if (map == Find.VisibleMap)
                {
                    Find.CameraDriver.shaker.DoShake(1f);
                }
                base.SendStandardLetter(new TargetInfo(cell, map, false), new string[0]);
            }
            return(num > 0);
        }
		public override bool TryExecute(IncidentParms parms)
		{
			bool baseReturn = base.TryExecute(parms);
			Map map = (Map)parms.target;

			IncidentWorker_ShipPartCrash.SpawnShrapnel(ThingDefOf.SlagRubble, IncidentWorker_ShipPartCrash.ShrapnelRubble.RandomInRange, intVec, map, angle);

			return baseReturn;
		}
 public static void SpawnShrapnel(ThingDef def, int quantity, IntVec3 center, Map map, float angle)
 {
     for (int i = 0; i < quantity; i++)
     {
         IntVec3 intVec = IncidentWorker_ShipPartCrash.GenerateShrapnelLocation(center, angle);
         if (intVec.InBounds(map))
         {
             if (!intVec.Impassable(map) && !intVec.Filled(map))
             {
                 RoofDef roofDef = map.roofGrid.RoofAt(intVec);
                 if (roofDef == null)
                 {
                     if ((from thing in intVec.GetThingList(map)
                          where thing.def == def
                          select thing).Count <Thing>() <= 0)
                     {
                         GenSpawn.Spawn(def, intVec, map);
                     }
                 }
             }
         }
     }
 }