Exemple #1
0
        // Token: 0x06000EA8 RID: 3752 RVA: 0x0006C254 File Offset: 0x0006A654
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map                = (Map)parms.target;
            int num                = 0;
            int countToSpawn       = this.CountToSpawn;
            List <TargetInfo> list = new List <TargetInfo>();
            float             shrapnelDirection = Rand.Range(0f, 360f);

            for (int i = 0; i < countToSpawn; i++)
            {
                IntVec3 intVec;
                if (!CellFinderLoose.TryFindSkyfallerCell(ThingDefOf.CrashedShipPartIncoming, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, true, false, null))
                {
                    break;
                }
                Building building_CrashedShipPart = (Building)ThingMaker.MakeThing(this.def.mechClusterBuilding, null);

                CompPawnSpawnerOnDamaged damaged = building_CrashedShipPart.TryGetComp <CompPawnSpawnerOnDamaged>();
                Faction faction = damaged.faction ?? Faction.OfMechanoids;
                building_CrashedShipPart.SetFaction(faction, null);
                building_CrashedShipPart.GetComp <CompPawnSpawnerOnDamaged>().pointsLeft = Mathf.Max(parms.points * 0.9f, 300f);
                Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, building_CrashedShipPart);
                skyfaller.shrapnelDirection = shrapnelDirection;
                GenSpawn.Spawn(skyfaller, intVec, map, WipeMode.Vanish);
                num++;
                list.Add(new TargetInfo(intVec, map, false));
            }
            if (num > 0)
            {
                base.SendStandardLetter(parms, list, Array.Empty <NamedArgument>());
            }
            return(num > 0);
        }
Exemple #2
0
        /*
         * // Token: 0x06000EA8 RID: 3752 RVA: 0x0006C2D0 File Offset: 0x0006A6D0
         * protected override bool TryExecuteWorker(IncidentParms parms)
         * {
         *  Map map = (Map)parms.target;
         *  int num = 0;
         *  int countToSpawn = this.CountToSpawn;
         *  List<TargetInfo> list = new List<TargetInfo>();
         *  float shrapnelDirection = Rand.Range(0f, 360f);
         *  Faction faction = null;
         *  Building building_CrashedShipPart = null;
         *  building = (Building)ThingMaker.MakeThing(this.def.mechClusterBuilding, null);
         *  if (faction == null)
         *  {
         *      faction = building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().OfFaction;
         *  }
         *  for (int i = 0; i < countToSpawn; i++)
         *  {
         *      IntVec3 intVec;
         *      if (!CellFinderLoose.TryFindSkyfallerCell(ThingDefOf.CrashedShipPartIncoming, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, true, false, null))
         *      {
         *          break;
         *      }
         *      building_CrashedShipPart.SetFaction(faction, null);
         *      building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().pointsLeft = Mathf.Max(parms.points * 0.9f, 300f);
         *
         *      ThingDef faller = building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().Props.skyFaller != null ? building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().Props.skyFaller : ThingDefOf.CrashedShipPartIncoming ;
         *      Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(faller, building_CrashedShipPart);
         *      skyfaller.shrapnelDirection = shrapnelDirection;
         *      GenSpawn.Spawn(skyfaller, intVec, map, WipeMode.Vanish);
         *      num++;
         *      list.Add(new TargetInfo(intVec, map, false));
         *  }
         *  if (num > 0)
         *  {
         *      base.SendStandardLetter(list, null, new string[0]);
         *  }
         *  return num > 0;
         *
         * }
         */
        // Token: 0x06003A73 RID: 14963 RVA: 0x001328DC File Offset: 0x00130ADC
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            List <TargetInfo> list        = new List <TargetInfo>();
            ThingDef          shipPartDef = this.def.mechClusterBuilding;
            IntVec3           intVec      = MechClusterUtility.FindDropPodLocation(map, (IntVec3 spot) => !spot.Fogged(map) && GenConstruct.CanBuildOnTerrain(shipPartDef, spot, map, Rot4.North, null, null) && GenConstruct.CanBuildOnTerrain(shipPartDef, new IntVec3(spot.x - Mathf.CeilToInt((float)shipPartDef.size.x / 2f), spot.y, spot.z), map, Rot4.North, null, null), 500, 0f);

            if (intVec == IntVec3.Invalid)
            {
                return(false);
            }
            float    points = Mathf.Max(parms.points * 0.9f, 300f);
            Thing    thing  = ThingMaker.MakeThing(shipPartDef, null);
            Building building_CrashedShipPart = (Building)thing;
            CompPawnSpawnerOnDamaged damaged  = building_CrashedShipPart.TryGetComp <CompPawnSpawnerOnDamaged>();
            Faction faction = damaged.faction ?? Faction.OfMechanoids;

            thing.SetFaction(faction, null);

            /*
             * List<Pawn> list2 = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
             * {
             *  groupKind = PawnGroupKindDefOf.Combat,
             *  tile = map.Tile,
             *  faction = faction,
             *  points = points
             * }, true).ToList<Pawn>();
             * LordMaker.MakeNewLord(faction, new LordJob_SleepThenMechanoidsDefend(new List<Thing>
             * {
             *  thing
             * }, faction, 28f, intVec, false, false), map, list2);
             * DropPodUtility.DropThingsNear(intVec, map, list2.Cast<Thing>(), 110, false, false, true, true);
             * foreach (Pawn thing2 in list2)
             * {
             *  CompCanBeDormant compCanBeDormant = thing2.TryGetComp<CompCanBeDormant>();
             *  if (compCanBeDormant != null)
             *  {
             *      compCanBeDormant.ToSleep();
             *  }
             * }
             * list.AddRange(from p in list2
             *            select new TargetInfo(p));
             */
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, thing), intVec, map, WipeMode.Vanish);
            list.Add(new TargetInfo(intVec, map, false));
            base.SendStandardLetter(parms, list, Array.Empty <NamedArgument>());
            return(true);
        }