Beispiel #1
0
        //protected IncidentParms Parms => Find.CurrentMap != null ? StorytellerUtility.DefaultParmsNow(incident.category, Find.CurrentMap) : null;

        public override bool TryExecuteEvent()
        {
            var map = (place as Settlement)?.Map ?? Find.CurrentMap;

            if (!TryFindCell(out var cell, map))             // здесь берётся целевая точка
            {
                return(false);
            }
            System.Random random = new System.Random();
            int           num    = mult;                //количество метеоритов
            int           num2   = random.Next(10, 30); // радиус разлёта от целевой клетки
            List <Thing>  list   = new List <Thing>();
            IntVec3       intVec = cell;
            ThingDef      meteor = ThingDefOf.MeteoriteIncoming;          //здесь глубоко зарыт разрешённый материал для метеорита

            for (int i = 0; i < num; i++)                                 // 1 итерация - 1 метеорит
            {
                intVec += (Rand.InsideUnitCircleVec3 * num2).ToIntVec3(); // точка удара с поправкой на разлёт

                while (!intVec.InBounds(map) || intVec.Fogged(map))       // рероллы пока не выпадет точка в радиусе разлёта, удовлетворяющая условию
                {
                    intVec += (Rand.InsideUnitCircleVec3 * num2).ToIntVec3();
                }
                list = ThingSetMakerDefOf.Meteorite.root.Generate();                    // ??
                SkyfallerMaker.SpawnSkyfaller(meteor, list, intVec, map);               //залп!

                intVec = cell;
            }

            string label = "В УКРЫТИЕ";
            string text  = "Началась орбитальная бомбардировка";

            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.ThreatBig, new TargetInfo(cell, map));
            return(true);
        }
Beispiel #2
0
        private static void StartLeap(Pawn pawn, IntVec3 cell)
        {
            float num;

            RotatePawn(pawn, cell, out num);
            var exactPos = pawn.DrawPos;
            var cellPos  = cell.ToVector3Shifted();

            exactPos.y = 0;
            cellPos.y  = 0;

            float speed         = WP_DefOf.WP_PawnSkyfaller.skyfaller.speed;
            float distance      = Vector3.Distance(exactPos, cellPos);
            int   ticksToImpact = (int)(distance / speed);

            num += 270f;
            bool flag4 = num >= 360f;

            if (flag4)
            {
                num -= 360f;
            }
            PawnSkyfaller skyfaller = SkyfallerMaker.SpawnSkyfaller(WP_DefOf.WP_PawnSkyfaller, cell, pawn.Map) as PawnSkyfaller;

            skyfaller.ticksToImpact = ticksToImpact;
            skyfaller.angle         = num;
            pawn.DeSpawn(0);
            skyfaller.innerContainer.TryAdd(pawn, false);
        }
        public static bool Prefix(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            for (int index = 0; index < info.innerContainer.Count; index++)
            {
                if (info.innerContainer[index].TryGetComp <CompLaunchableSRTS>() != null)
                {
                    Thing         ship          = info.innerContainer[index];
                    string        shipType      = ship.def.defName;
                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(shipType + "_Active"), (ThingDef)null);
                    activeDropPod.Contents = info;

                    EnsureInBoundsSRTS(ref c, info.innerContainer[index].def, map);
                    SRTSIncoming incomingSRTS = (SRTSIncoming)SkyfallerMaker.SpawnSkyfaller(ThingDef.Named(shipType + "_Incoming"), (Thing)activeDropPod, c, map);
                    incomingSRTS.SRTSRotation = ship.Rotation;
                    return(false);
                }
                else if (DefDatabase <ThingDef> .GetNamedSilentFail(info.innerContainer[index].def.defName.Split('_')[0])?.GetCompProperties <CompProperties_BombsAway>() != null)
                {
                    ThingDef td = DefDatabase <ThingDef> .GetNamed(info.innerContainer[index].def.defName.Split('_')[0]);

                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(info.innerContainer[index].def, null);
                    activeDropPod.Contents = info;
                    SRTSIncoming incomingSRTS = (SRTSIncoming)SkyfallerMaker.SpawnSkyfaller(ThingDef.Named(td.defName + "_Incoming"), activeDropPod, c, map);
                    return(false);
                }
            }
            return(true);
        }
        public static bool Prefix(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            Thing            dropship = null;
            CompUSCMDropship cargo    = null;

            //    CompTransporter comp2 = null;
            for (int index = 0; index < info.innerContainer.Count; index++)
            {
                if (info.innerContainer[index].TryGetComp <CompUSCMDropship>() != null)
                {
                    dropship = info.innerContainer[index];
                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(USCMDefOf.RRY_USCM_ActiveDropshipUD4L, null);

                    activeDropPod.Contents = info;
                    EnsureInBounds(ref c, info.innerContainer[index].def, map);
                    info.innerContainer.Remove(dropship);
                    cargo = dropship.TryGetComp <CompUSCMDropship>();
                    cargo.Transporter.innerContainer = info.innerContainer;
                    SkyfallerMaker.SpawnSkyfaller(USCMDefOf.RRY_USCM_DropshipUD4LIncoming, dropship, c, map);
                    return(false);
                }
            }

            return(true);
        }
Beispiel #5
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            IntVec3 intVec3;
            Map     map = (Map)parms.target;

            if (!this.TryFindCell(out intVec3, map))
            {
                return(false);
            }
            List <Thing> things = ThingSetMakerDefOf.Meteorite.root.Generate();

            if (Controller.Settings.crashBurn.Equals(true) && Rand.Value < 0.67f)
            {
                SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncomingFlame, things, intVec3, map);
            }
            else
            {
                SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, things, intVec3, map);
            }
            LetterDef letterDef = (!things[0].def.building.isResourceRock ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent);
            string    str       = string.Format(this.def.letterText, things[0].def.label).CapitalizeFirst();

            Find.LetterStack.ReceiveLetter(this.def.letterLabel, str, letterDef, new TargetInfo(intVec3, map, false), null);
            return(true);
        }
        private void DoEvent()
        {
            IntVec3 rndTarg = new IntVec3(Rand.Range(16, this.SingleMap.Size.x - 16), 0, Rand.Range(16, this.SingleMap.Size.z - 16));

            if (Rand.Chance(.1f * eventDifficulty))
            {
                rndTarg = FindEnemyPawnOrBuilding(rndTarg);
            }
            IntVec3 rndPos   = rndTarg;
            int     accuracy = 5 - eventDifficulty;

            rndPos.x += Rand.Range(-accuracy, accuracy);
            rndPos.z += Rand.Range(-accuracy, accuracy);
            if (rndPos.IsValid && rndPos.InBounds(this.SingleMap) && rndPos.DistanceToEdge(this.SingleMap) > 6)
            {
                if (eventDifficulty > 2 && Rand.Chance(eventDifficulty * .05f))
                {
                    SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Large, rndPos, this.SingleMap);
                }
                else if (eventDifficulty > 1 && Rand.Chance(eventDifficulty * .1f))
                {
                    SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Small, rndPos, this.SingleMap);
                }
                else
                {
                    SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Tiny, rndPos, this.SingleMap);
                }
            }
        }
Beispiel #7
0
        public void FlyAbility(Pawn pawn, IntVec3 targetCell)
        {
            bool flag = this.cooldownTicks > 0f;

            if (flag)
            {
                Messages.Message("Fly_Cooldown".Translate(), MessageTypeDefOf.RejectInput, false);
            }
            else
            {
                this.soundQueued = true;
                float num;
                this.RotateFlyer(pawn, targetCell, out num);
                float speed = GitThingDefOf.FlyAbilitySkyfaller.skyfaller.speed;
                float num2  = pawn.Position.DistanceTo(targetCell);
                int   num3  = (int)(num2 / speed);
                num += 270f;
                bool flag2 = num >= 360f;
                if (flag2)
                {
                    num -= 360f;
                }
                Skyfaller           skyfaller           = SkyfallerMaker.SpawnSkyfaller(GitThingDefOf.FlyAbilitySkyfaller, targetCell, pawn.Map);
                FlyAbilitySkyfaller flyAbilitySkyfaller = skyfaller as FlyAbilitySkyfaller;
                skyfaller.ticksToImpact = num3;
                flyAbilitySkyfaller.ticksToImpactMax = num3;
                flyAbilitySkyfaller.skyfallerPawn    = new PawnRenderer(pawn);
                skyfaller.angle = num;
                this.drafted    = pawn.Drafted;
                pawn.DeSpawn(DestroyMode.Vanish);
                skyfaller.innerContainer.TryAdd(pawn, false);
            }
        }
Beispiel #8
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002084 File Offset: 0x00000284
        public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            var activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named("ActiveSlagPod"));

            activeDropPod.Contents = info;
            SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("SlagScatter"), activeDropPod, c, map);
        }
Beispiel #9
0
        public static bool Prefix(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            Thing        dropship = null;
            CompDropship cargo    = null;

            //    CompTransporter comp2 = null;
            for (int index = 0; index < info.innerContainer.Count; index++)
            {
                if (info.innerContainer[index].TryGetCompFast <CompDropship>() != null)
                {
                    dropship = info.innerContainer[index];
                    string        defName       = dropship.def.defName;
                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(defName + "_Active"), null);

                    activeDropPod.Contents = info;
                    EnsureInBounds(ref c, info.innerContainer[index].def, map);
                    info.innerContainer.Remove(dropship);
                    cargo = dropship.TryGetCompFast <CompDropship>();
                    cargo.Transporter.innerContainer = info.innerContainer;
                    SkyfallerMaker.SpawnSkyfaller(ThingDef.Named(defName + "_Incoming"), dropship, c, map);
                    return(false);
                }
            }

            return(true);
        }
Beispiel #10
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;
            IntVec3  impactPos;

            if (!initialized)
            {
                Initialize(map);
            }

            impactPos = cellRect.RandomCell;
            if (this.age > (lastStrike + strikeDelay) && impactPos.Standable(map) && impactPos.InBounds(map))
            {
                this.lastStrike  = this.age;
                this.strikeDelay = Rand.Range(45, 90);
                skyfallers.Add(SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("Skyfaller_RainOfFire"), impactPos, map));
                skyfallers[skyfallers.Count - 1].angle = Rand.Range(-40, 0);
            }
            else if (this.age > (lastStrikeSmall + smallStrikeDelay) && this.age > smallStartDelay)
            {
                this.lastStrikeSmall = this.age;
                skyfallersSmall.Add(SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("Skyfaller_RainOfFire_Small"), impactPos, map));
                skyfallersSmall[skyfallersSmall.Count - 1].angle = Rand.Range(-40, 0);
            }

            for (int i = 0; i < skyfallers.Count(); i++)
            {
                if (skyfallers[i].ticksToImpact == 0)
                {
                    this.expandingTick++;
                    IntVec3 centerCell = skyfallers[i].Position;
                    IntVec3 curCell;
                    IEnumerable <IntVec3> oldExplosionCells = GenRadial.RadialCellsAround(centerCell, expandingTick - 1, true);
                    IEnumerable <IntVec3> newExplosionCells = GenRadial.RadialCellsAround(centerCell, expandingTick, true);
                    IEnumerable <IntVec3> explosionCells    = newExplosionCells.Except(oldExplosionCells);
                    for (int j = 0; j < explosionCells.Count(); j++)
                    {
                        curCell = explosionCells.ToArray <IntVec3>()[j];
                        if (curCell.InBounds(map) && curCell.IsValid)
                        {
                            Vector3 heading   = (curCell - centerCell).ToVector3();
                            float   distance  = heading.magnitude;
                            Vector3 direction = heading / distance;
                            EffectMaker.MakeEffect(WizardryDefOf.Mote_ExpandingFlame, curCell.ToVector3(), this.Map, .8f, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 4f, Rand.Range(100, 200));
                            EffectMaker.MakeEffect(WizardryDefOf.Mote_RecedingFlame, curCell.ToVector3(), this.Map, .7f, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 1f, 0);
                        }
                    }
                    if (expandingTick == 3)
                    {
                        this.expandingTick = 0;
                        skyfallers.Remove(skyfallers[i]);
                    }
                }
            }
        }
Beispiel #11
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;
            IntVec3  impactPos;

            if (!initialized)
            {
                Initialize(map);
            }
            impactPos = cellRect.RandomCell;
            if (this.age > lastStrikeLarge + Rand.Range(200 - (pwr.level * 30), duration / (4 + pwr.level)) && impactPos.Standable(map) && impactPos.InBounds(map))
            {
                this.lastStrikeLarge = this.age;
                SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Blizzard_Large, impactPos, map);
                MoteMaker.ThrowSmoke(impactPos.ToVector3(), map, 5f);
                ticksTillSnow[snowCount] = TorannMagicDefOf.TM_Blizzard_Large.skyfaller.ticksToImpactRange.RandomInRange + 4;
                snowPos[snowCount]       = impactPos;
                snowCount++;
            }
            impactPos = cellRect.RandomCell;
            if (this.age > lastStrikeTiny + Rand.Range(6 - (pwr.level), 18 - (2 * pwr.level)) && impactPos.Standable(map) && impactPos.InBounds(map))
            {
                this.lastStrikeTiny = this.age;
                SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Blizzard_Tiny, impactPos, map);
                MoteMaker.ThrowSmoke(impactPos.ToVector3(), map, 1f);
                ticksTillSnow[snowCount] = TorannMagicDefOf.TM_Blizzard_Tiny.skyfaller.ticksToImpactRange.RandomInRange + 2;
                snowPos[snowCount]       = impactPos;
                snowCount++;
            }
            impactPos = cellRect.RandomCell;
            if (this.age > lastStrikeSmall + Rand.Range(30 - (2 * pwr.level), 60 - (4 * pwr.level)) && impactPos.Standable(map) && impactPos.InBounds(map))
            {
                this.lastStrikeSmall = this.age;
                SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Blizzard_Small, impactPos, map);
                MoteMaker.ThrowSmoke(impactPos.ToVector3(), map, 3f);
                ticksTillSnow[snowCount] = TorannMagicDefOf.TM_Blizzard_Small.skyfaller.ticksToImpactRange.RandomInRange + 2;
                snowPos[snowCount]       = impactPos;
                snowCount++;
            }

            for (int i = 0; i <= snowCount; i++)
            {
                if (ticksTillSnow[i] == 0)
                {
                    AddSnowRadial(snowPos[i], map, 2f, 2f);
                    MoteMaker.ThrowSmoke(snowPos[i].ToVector3(), map, 4f);
                    ticksTillSnow[i]--;
                }
                else
                {
                    ticksTillSnow[i]--;
                }
            }
        }
Beispiel #12
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            RFScenarios_Initializer.usingMoonFall = true;
            float SkyFallType = Rand.Value;

            if (SkyFallType < 0.2f)
            {
                // Meteor Swarm
                Messages.Message("RFScenarios.MessageMeteorSwarmTribal".Translate(), MessageTypeDefOf.NeutralEvent);
                return(true);
            }
            else if (SkyFallType < 0.25f)
            {
                // Flashstorm
                Map map = (Map)parms.target;
                if ((map).gameConditionManager.ConditionIsActive(GameConditionDefOf.Flashstorm))
                {
                    return(false);
                }
                FloatRange durationDays = new FloatRange(0.075f, 0.1f);
                int        num          = Mathf.RoundToInt(durationDays.RandomInRange * 60000f);
                GameCondition_Flashstorm gameConditionFlashstorm = (GameCondition_Flashstorm)GameConditionMaker.MakeCondition(GameConditionDefOf.Flashstorm, num);
                map.gameConditionManager.RegisterCondition(gameConditionFlashstorm);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelFlashstorm".Translate(), "RFScenarios.FlashstormTribal".Translate(), LetterDefOf.ThreatSmall, new TargetInfo(gameConditionFlashstorm.centerLocation.ToIntVec3, map, false), null);
                if (map.weatherManager.curWeather.rainRate > 0.1f)
                {
                    map.weatherDecider.StartNextWeather();
                }
                return(true);
            }
            else
            {
                // Meteorite
                IntVec3 intVec3;
                Map     map = (Map)parms.target;
                if (!this.TryFindCell(out intVec3, map))
                {
                    return(false);
                }
                List <Thing> list = ThingSetMakerDefOf.Meteorite.root.Generate();
                if (Controller.Settings.crashBurn.Equals(true) && Rand.Value < 0.67f)
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncomingFlame, list, intVec3, map);
                }
                else
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, intVec3, map);
                }
                LetterDef letterDef = (!list[0].def.building.isResourceRock ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent);
                String    text      = TranslatorFormattedStringExtensions.Translate("RFScenarios.MeteoriteTribal", list[0].def.label);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelMeteoriteTribal".Translate(), text, letterDef, new TargetInfo(intVec3, map, false), null);
                return(true);
            }
        }
Beispiel #13
0
 public static bool Prefix(IntVec3 c, Map map, ActiveDropPodInfo info)
 {
     if (info.innerContainer.Contains(ThingDef.Named("Building_Helicopter")))
     {
         ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named("ActiveHelicopter"), null);
         activeDropPod.Contents = info;
         SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("HelicopterIncoming"), activeDropPod, c, map);
         return(false);
     }
     return(true);
 }
Beispiel #14
0
        // Token: 0x06000028 RID: 40 RVA: 0x00002CB8 File Offset: 0x00000EB8
        public void DoJumpJet(Pawn Pilot, IntVec3 targCell)
        {
            JPRotatePilot(Pilot, targCell, out var angle);
            if (JPSkyFallType == null)
            {
                JPSkyFallType = "SFJetPack";
            }

            var JPSF = DefDatabase <ThingDef> .GetNamed(JPSkyFallType, false);

            if (JPSF == null)
            {
                JPSF = DefDatabase <ThingDef> .GetNamed("SFJetPack");

                JPSkyFallType = "SFJetPack";
            }

            var SFspeed = JPSF.skyfaller.speed;

            if (SFspeed <= 0f)
            {
                SFspeed = 1f;
            }

            var distance   = Pilot.Position.DistanceTo(targCell);
            var timeToLand = (int)(distance / SFspeed);

            angle += 270f;
            if (angle >= 360f)
            {
                angle -= 360f;
            }

            int fuelUsed;

            if (Settings.UseCarry)
            {
                fuelUsed = (int)Math.Floor(distance * JPFuelRate /
                                           JPWeightUtility.JPCarryFactor(Pilot, def, JPFuelItem));
            }
            else
            {
                fuelUsed = (int)Math.Floor(distance * JPFuelRate);
            }

            JPFuelAmount -= fuelUsed;
            var skyfaller = SkyfallerMaker.SpawnSkyfaller(JPSF, targCell, Pilot.Map);

            skyfaller.ticksToImpact = timeToLand;
            skyfaller.angle         = angle;
            JPPilotIsDrafted        = Pilot.Drafted;
            Pilot.DeSpawn();
            skyfaller.innerContainer.TryAdd(Pilot, false);
        }
        public static void MakeFlyerLandAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension = null)
        {
            ThingDef ActiveDropPod = DefDatabase <ThingDef> .GetNamed("OG_Active_DeepStrike_Flyer");

            ThingDef DropPodIncoming = DefDatabase <ThingDef> .GetNamed("OG_DeepStrike_Flyer_Incoming");

            ActiveFlyer activeDropPod = (ActiveFlyer)ThingMaker.MakeThing(ActiveDropPod, null);

            activeDropPod.Contents           = info;
            activeDropPod.Contents.leaveSlag = false;
            SkyfallerMaker.SpawnSkyfaller(DropPodIncoming, activeDropPod, c, map);
        }
        protected override bool TryCastShot()
        {
            Map     map        = base.CasterPawn.Map;
            IntVec3 centerCell = this.currentTarget.Cell;

            verVal = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Meteor.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Meteor_ver").level;
            pwrVal = this.UseAbilityProps.TargetAoEProperties.range;

            bool result = false;
            bool arg_40_0;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                IntVec3 arg_29_0 = this.currentTarget.Cell;
                arg_40_0 = this.currentTarget.Cell.IsValid;
            }
            else
            {
                arg_40_0 = false;
            }
            bool flag = arg_40_0;

            if (flag)
            {
                if (pwrVal == 5)
                {
                    List <Thing> list = GenerateMeteoriteComposition(pwrVal);
                    SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_Meteorite_III"), list, centerCell, map);
                }
                else if (pwrVal == 4)
                {
                    List <Thing> list = GenerateMeteoriteComposition(pwrVal);
                    SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_Meteorite_II"), list, centerCell, map);
                }
                else if (pwrVal == 3)
                {
                    List <Thing> list = GenerateMeteoriteComposition(pwrVal);
                    SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_Meteorite_I"), list, centerCell, map);
                }
                else
                {
                    List <Thing> list = GenerateMeteoriteComposition(pwrVal);
                    SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("TM_Meteorite"), list, centerCell, map);
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            return(result);
        }
Beispiel #17
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;
            IntVec3  impactPos;

            if (!initialized)
            {
                Initialize(map);
            }

            impactPos = cellRect.RandomCell;
            if (this.age > lastStrikeLarge + Rand.Range((200 / (1 + pwrVal)) + 20, (duration / (1 + pwrVal)) + 40) && impactPos.Standable(map) && impactPos.InBounds(map))
            {
                this.lastStrikeLarge = this.age;
                SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Large, impactPos, map);
                CellRect cellRectSec = CellRect.CenteredOn(impactPos, (int)(TorannMagicDefOf.TM_Firestorm_Large.skyfaller.explosionRadius + 2));
                for (int j = 0; j < (int)Rand.Range(1 + verVal, 5 + verVal); j++)
                {
                    this.shrapnelPos[heavyCount]    = cellRectSec.RandomCell;
                    this.ticksTillHeavy[heavyCount] = TorannMagicDefOf.TM_Firestorm_Large.skyfaller.ticksToImpactRange.RandomInRange + 8;
                    heavyCount++;
                }
            }
            impactPos = cellRect.RandomCell;
            if (this.age > lastStrikeTiny + Rand.Range(7 - pwrVal, 20 - pwrVal) && impactPos.Standable(map) && impactPos.InBounds(map))
            {
                this.lastStrikeTiny = this.age;
                SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Tiny, impactPos, map);
            }
            impactPos = cellRect.RandomCell;
            if (this.age > lastStrikeSmall + Rand.Range(18 - (2 * pwrVal), 42 - (2 * pwrVal)) && impactPos.Standable(map) && impactPos.InBounds(map))
            {
                this.lastStrikeSmall = this.age;
                SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Small, impactPos, map);
            }

            for (int i = 0; i <= heavyCount; i++)
            {
                if (ticksTillHeavy[i] == 0)
                {
                    GenExplosion.DoExplosion(shrapnelPos[heavyCount], map, .4f, TMDamageDefOf.DamageDefOf.TM_Firestorm_Small, this.launcher, Rand.Range(5, this.def.projectile.GetDamageAmount(1, null)), 0, SoundDefOf.BulletImpact_Ground, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0.2f, false);
                    ticksTillHeavy[i]--;
                }
                else
                {
                    ticksTillHeavy[i]--;
                }
            }
        }
Beispiel #18
0
        private void SpawnChunk(IntVec3 pos, Map map)
        {
            ThingDef chunkType = ShipChunkOptions.SelectChunkFromAvailableOptions();

            if (Controller.Settings.crashBurn.Equals(true) && Rand.Value < 0.67f)
            {
                SkyfallerMaker.SpawnSkyfaller(ThingDefOf.ShipChunkIncomingFlame, chunkType, pos, map);
            }
            else
            {
                SkyfallerMaker.SpawnSkyfaller(ThingDefOf.ShipChunkIncoming, chunkType, pos, map);
            }
        }
Beispiel #19
0
        // Token: 0x06002762 RID: 10082 RVA: 0x0012C458 File Offset: 0x0012A858
        public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension)
        {
            ThingDef ActiveDropPod   = ThingDefOf.ActiveDropPod;
            ThingDef DropPodIncoming = ThingDefOf.DropPodIncoming;

            if (extension != null)
            {
                ActiveDropPod   = extension.ActiveDropPod;
                DropPodIncoming = extension.DropPodIncoming;
            }
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ActiveDropPod, null);

            activeDropPod.Contents = info;
            SkyfallerMaker.SpawnSkyfaller(DropPodIncoming, activeDropPod, c, map);
        }
 public void DoMapEvent()
 {
     if (this.rnd < 2) //earth
     {
         //berserk random animal
         List <Pawn> animalList = this.Map.mapPawns.AllPawnsSpawned;
         for (int i = 0; i < animalList.Count; i++)
         {
             int j = Rand.Range(0, animalList.Count);
             if (animalList[j].RaceProps.Animal && !animalList[j].IsColonist)
             {
                 animalList[j].mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, true, false, null);
                 i = animalList.Count;
             }
         }
     }
     else if (this.rnd < 4) //fire
     {
         FindGoodCenterLocation();
         if (Rand.Chance(.6f))
         {
             SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Small, this.centerLocation.ToIntVec3, this.Map);
         }
         else
         {
             SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Firestorm_Tiny, this.centerLocation.ToIntVec3, this.Map);
         }
     }
     else if (this.rnd < 6) //water
     {
         FindGoodCenterLocation();
         if (Rand.Chance(.6f))
         {
             SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Blizzard_Small, this.centerLocation.ToIntVec3, this.Map);
         }
         else
         {
             SkyfallerMaker.SpawnSkyfaller(TorannMagicDefOf.TM_Blizzard_Large, this.centerLocation.ToIntVec3, this.Map);
         }
     }
     else //air
     {
         FindGoodCenterLocation();
         Map.weatherManager.eventHandler.AddEvent(new WeatherEvent_LightningStrike(this.Map, this.centerLocation.ToIntVec3));
         GenExplosion.DoExplosion(this.centerLocation.ToIntVec3, this.Map, this.areaRadius, DamageDefOf.Bomb, null, Rand.Range(6, 16), SoundDefOf.Thunder_OffMap, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true);
     }
 }
Beispiel #21
0
        public static bool Prefix(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            for (int index = 0; index < info.innerContainer.Count; index++)
            {
                if (info.innerContainer[index].TryGetComp <CompLaunchableHelicopter>() != null)
                {
                    Thing         helicopter    = info.innerContainer[index];
                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named("ActiveHelicopter"), null);
                    activeDropPod.Contents = info;

                    EnsureInBounds(ref c, info.innerContainer[index].def, map);
                    SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("HelicopterIncoming"), activeDropPod, c, map);
                    return(false);
                }
            }
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 intVec;

            if (!this.TryFindCell(out intVec, map))
            {
                return(false);
            }
            List <Thing> list = DefDatabase <ThingSetMakerDef> .GetNamed("AA_Meteorite").root.Generate();

            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, intVec, map);
            Find.LetterStack.ReceiveLetter("LetterLabelSkyAsteroid".Translate(), "LetterSkyAsteroid".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null, null);


            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Map map = parms.target as Map;

            if (TryFindCell(out IntVec3 result, map))
            {
                var faller = SkyfallerMaker.SpawnSkyfaller(ThingDefOf.ShipChunkIncoming, ThingDefOfLocal.MechanoidTeleport_Generator, result, map);
                SendStandardLetter(parms, new LookTargets(new TargetInfo(result, map)));
                return(true);
            }

            return(false);
        }
Beispiel #24
0
        public static bool Prefix(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            for (int index = 0; index < info.innerContainer.Count; index++)
            {
                if (info.innerContainer[index].TryGetComp <CompLaunchableSRTS>() != null)
                {
                    Thing         ship          = info.innerContainer[index];
                    string        shipType      = ship.def.defName;
                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(shipType + "_Active"), (ThingDef)null);
                    activeDropPod.Contents = info;

                    EnsureInBoundsSRTS(ref c, info.innerContainer[index].def, map);
                    SRTSIncoming incomingSRTS = (SRTSIncoming)SkyfallerMaker.SpawnSkyfaller(ThingDef.Named(shipType + "_Incoming"), (Thing)activeDropPod, c, map);
                    incomingSRTS.SRTSRotation = ship.Rotation;
                    return(false);
                }
            }
            return(true);
        }
Beispiel #25
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Map map = (Map)parms.target;

            IntVec3 intVec;

            if (!this.TryFindCell(out intVec, map))
            {
                return(false);
            }

            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, intVec, map);

            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 intVec;

            if (!this.TryFindCell(out intVec, map))
            {
                return(false);
            }

            var list = GenerateBloodStone();

            map.weatherManager.eventHandler.AddEvent(new WeatherEvent_BloodCometFlash(map));
            SkyfallerMaker.SpawnSkyfaller(UvhashDefOf.Uvhash_BloodCometFragmentIncoming, list, intVec, map);
            LetterDef textLetterDef = (!list[0].def.building.isResourceRock) ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent;
            string    text          = string.Format(this.def.letterText, list[0].def.label).CapitalizeFirst();

            Find.LetterStack.ReceiveLetter(this.def.letterLabel, text, textLetterDef, new TargetInfo(intVec, map, false), null);
            return(true);
        }
Beispiel #27
0
        public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info, ThingDef makePodThing, ThingDef makeSkyfallerThing, bool draftFlag = false)
        {
            TM_ActiveDropPod activeDropPod = (TM_ActiveDropPod)ThingMaker.MakeThing(makePodThing);

            activeDropPod.Contents           = info;
            activeDropPod.Contents.openDelay = 5;
            activeDropPod.draftFlag          = draftFlag;
            TM_DropPodIncoming dpi = (TM_DropPodIncoming)SkyfallerMaker.SpawnSkyfaller(makeSkyfallerThing, activeDropPod, c, map);

            dpi.draftFlag = draftFlag;
            foreach (Thing item in (IEnumerable <Thing>)activeDropPod.Contents.innerContainer)
            {
                Pawn pawn;
                if ((pawn = (item as Pawn)) != null && pawn.IsWorldPawn())
                {
                    Find.WorldPawns.RemovePawn(pawn);
                    pawn.psychicEntropy?.SetInitialPsyfocusLevel();
                }
            }
        }
        // Token: 0x0600001C RID: 28 RVA: 0x0000296C File Offset: 0x00000B6C
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var map    = (Map)parms.target;
            var random = new Random();
            var num    = random.Next(1, 6);

            TryFindPresentDropCell(map.Center, map, 300, out var pos);
            var skyfaller = SkyfallerMaker.SpawnSkyfaller(XDefOf.PresentIncoming, XDefOf.Present, pos, map);

            for (var i = 0; i <= num - 1; i++)
            {
                TryFindPresentDropCell(map.Center, map, 300, out pos);
                skyfaller = SkyfallerMaker.SpawnSkyfaller(XDefOf.PresentIncoming, XDefOf.Present, pos, map);
            }

            string text  = "PresentLabel".Translate();
            string text2 = "PresentLetter".Translate();

            Find.LetterStack.ReceiveLetter(text, text2, LetterDefOf.PositiveEvent,
                                           new TargetInfo(skyfaller.Position, map));
            return(true);
        }
Beispiel #29
0
        public static Thing MeteoriteSpawn(Map map, bool mayHitColony)
        {
            IntVec3 intVec;

            if (mayHitColony)
            {
                if (!GetRandomVec3(ThingDefOf.MeteoriteIncoming, map, out intVec, 2))
                {
                    return(null);
                }
            }
            else if (!TryFindMeteoriteCell(out intVec, map))
            {
                return(null);
            }

            var list = ThingSetMakerDefOf.Meteorite.root.Generate();

            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, intVec, map);

            return(list.Last());
        }
Beispiel #30
0
        public static void Vomit(Map map)
        {
            var vomitDef = ThingDef.Named("DropPodIncoming");

            vomitDef.label = "vomit (incoming)";
            vomitDef.graphicData.texPath = "Things/Filth/PoolSoft";

            var vomit = new Filth();

            vomit.def = ThingDefOf.Filth_Vomit;

            IntVec3 intVec;

            if (!GetRandomVec3(vomitDef, map, out intVec))
            {
                return;
            }

            SkyfallerMaker.SpawnSkyfaller(vomitDef, new List <Thing> {
                vomit
            }, intVec, map);
        }