Ejemplo n.º 1
0
        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_CrashedShipPart building_CrashedShipPart = (Building_CrashedShipPart)ThingMaker.MakeThing(this.def.shipPart, null);
                building_CrashedShipPart.SetFaction(Faction.OfMechanoids, null);
                building_CrashedShipPart.GetComp <CompSpawnerMechanoidsOnDamaged>().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(list, null, new string[0]);
            }
            return(num > 0);
        }
Ejemplo n.º 2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map                = (Map)parms.target;
            int num                = 0;
            int countToSpawn       = CountToSpawn;
            List <TargetInfo> list = new List <TargetInfo>();
            float             shrapnelDirection = Rand.Range(0f, 360f);

            for (int i = 0; i < countToSpawn; i++)
            {
                IntVec3 cell = default(IntVec3);
                if (!CellFinderLoose.TryFindSkyfallerCell(ThingDefOf.CrashedShipPartIncoming, map, out cell, 14, default(IntVec3), -1, allowRoofedCells: false, allowCellsWithItems: true, allowCellsWithBuildings: true, colonyReachable: true))
                {
                    break;
                }
                Building_CrashedShipPart building_CrashedShipPart = (Building_CrashedShipPart)ThingMaker.MakeThing(def.shipPart);
                building_CrashedShipPart.SetFaction(Faction.OfMechanoids);
                building_CrashedShipPart.GetComp <CompSpawnerMechanoidsOnDamaged>().pointsLeft = Mathf.Max(parms.points * 0.9f, 300f);
                Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, building_CrashedShipPart);
                skyfaller.shrapnelDirection = shrapnelDirection;
                GenSpawn.Spawn(skyfaller, cell, map);
                num++;
                list.Add(new TargetInfo(cell, map));
            }
            if (num > 0)
            {
                SendStandardLetter(list, null);
            }
            return(num > 0);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map               = (Map)parms.target;
            int     num               = 0;
            int     countToSpawn      = this.CountToSpawn;
            IntVec3 cell              = IntVec3.Invalid;
            float   shrapnelDirection = Rand.Range(0f, 360f);
            int     num2              = 0;
            IntVec3 intVec            = default(IntVec3);

            while (num2 < countToSpawn && CellFinderLoose.TryFindSkyfallerCell(ThingDefOf.CrashedShipPartIncoming, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, (Predicate <IntVec3>)null))
            {
                Building_CrashedShipPart building_CrashedShipPart = (Building_CrashedShipPart)ThingMaker.MakeThing(base.def.shipPart, null);
                building_CrashedShipPart.SetFaction(Faction.OfMechanoids, null);
                building_CrashedShipPart.GetComp <CompSpawnerMechanoidsOnDamaged>().pointsLeft = Mathf.Max((float)(parms.points * 0.89999997615814209), 300f);
                Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, building_CrashedShipPart);
                skyfaller.shrapnelDirection = shrapnelDirection;
                GenSpawn.Spawn(skyfaller, intVec, map);
                num++;
                cell = intVec;
                num2++;
            }
            if (num > 0)
            {
                base.SendStandardLetter(new TargetInfo(cell, map, false));
            }
            return(num > 0);
        }