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);
        }
Beispiel #2
0
        public static void LandShip(Map map, Thing ship)
        {
            Thing    blockingThing;
            IntVec3  center = IntVec3.Invalid;
            CompShip comp   = ship.TryGetComp <CompShip>();

            Area_LandingZone lz = map.areaManager.LandingZone();

            if (lz != null && !lz.TryFindShipLandingArea(ship.def.size, out center, out blockingThing) && blockingThing != null)
            {
                Messages.Message("TraderShipsLandingZoneBlocked".Translate("TraderShipsBlockedBy".Translate(blockingThing)), blockingThing, MessageTypeDefOf.NeutralEvent, true);
            }

            if (!center.IsValid && ThingDefOf.ShipLandingBeacon != null && !DropCellFinder.TryFindShipLandingArea(map, out center, out blockingThing) && blockingThing != null)
            {
                Messages.Message("TraderShipsLandingZoneBlocked".Translate("TraderShipsBlockedBy".Translate(blockingThing)), blockingThing, MessageTypeDefOf.NeutralEvent, true);
            }

            if (!center.IsValid)
            {
                FindCloseLandingSpot(out center, comp.tradeShip.Faction, map, ship.def.size);
            }

            GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(comp.Props.landAnimation, ship), center, map, ThingPlaceMode.Near);
        }
Beispiel #3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("PLAHF_faction"));
            Map     map     = (Map)parms.target;
            //List<TargetInfo> list = new List<TargetInfo>();
            float shrapnelDirection = Rand.Range(0f, 360f);
            Thing lookhere;


            IntVec3 intVec;

            if (!CellFinderLoose.TryFindSkyfallerCell(RimWorld.ThingDefOf.DropPodIncoming, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, true, false, null))
            {
                return(false);
            }
            Building_TacticalManaBomb building_tacticalmanabomb = (Building_TacticalManaBomb)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("Building_TacticalManaBomb", true));

            building_tacticalmanabomb.SetFaction(faction, null);
            building_tacticalmanabomb.spawnpoints = (float)(parms.points * 0.8);
            lookhere = building_tacticalmanabomb;

            Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(RimWorld.ThingDefOf.DropPodIncoming, building_tacticalmanabomb);

            skyfaller.shrapnelDirection = shrapnelDirection;
            GenSpawn.Spawn(skyfaller, intVec, map, WipeMode.Vanish);



            Find.LetterStack.ReceiveLetter("LetterLabelPLAHFTMBAttack".Translate(), "LetterPLAHFTMBAttack".Translate(), LetterDefOf.ThreatBig, lookhere, null, null);


            Find.TickManager.slower.SignalForceNormalSpeedShort();
            Find.StoryWatcher.statsRecord.numRaidsEnemy++;
            return(true);
        }
        public static ArtilleryStrikeIncoming SpawnArtilleryStrikeSkyfaller(ThingDef shellDef, Map map, IntVec3 position)
        {
            var artilleryStrikeIncoming = (ArtilleryStrikeIncoming)SkyfallerMaker.MakeSkyfaller(ThingDefOf.VFES_ArtilleryStrikeIncoming);

            artilleryStrikeIncoming.artilleryShellDef = shellDef;
            return((ArtilleryStrikeIncoming)GenSpawn.Spawn(artilleryStrikeIncoming, position, map));
        }
        public override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map                = (Map)parms.target;
            int num                = 0;
            int countToSpawn       = this.CountToSpawn;
            List <TargetInfo> list = new List <TargetInfo>();

            Rand.PushState();
            float shrapnelDirection = Rand.Range(0f, 360f);

            Rand.PopState();
            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);
                building_CrashedShipPart.SetFaction(OfNecrons, 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);
        }
Beispiel #6
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 #7
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);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var map               = (Map)parms.target;
            int num               = 0;
            int countToSpawn      = this.CountToSpawn;
            var list              = new List <TargetInfo>();
            var shrapnelDirection = Rand.Range(0f, 360f);

            for (int i = 0; i < countToSpawn; i++)
            {
                IntVec3 intVec = default(IntVec3);
                if (!CellFinderLoose.TryFindSkyfallerCell(ThingDefOf.CrashedShipPartIncoming, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, true, false, null))
                {
                    break;
                }
                var building_CrashedShipPart = (Building_CrashedShipPart)ThingMaker.MakeThing(def.shipPart, null);
                building_CrashedShipPart.SetFaction(Faction.OfMechanoids, null);
                building_CrashedShipPart.GetComp <CompSpawnerMechanoidsOnDamaged>().pointsLeft = Mathf.Max(parms.points * ShipPointsFactor, 300f);
                var 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)
            {
                SendStandardLetter(list, null);
            }
            return(num > 0);
        }
Beispiel #9
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);
        }
        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 #11
0
        public static void SpawnTraderShip()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            list.Add(new DebugMenuOption("Incoming", DebugMenuOptionMode.Tool, delegate()
            {
                Thing thing   = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
                CompShip comp = thing.TryGetComp <CompShip>();
                comp.GenerateInternalTradeShip(Find.CurrentMap);

                GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(comp.Props.landAnimation, thing), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4));
            }));

            list.Add(new DebugMenuOption("Stationary", DebugMenuOptionMode.Tool, delegate()
            {
                Thing thing = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
                thing.TryGetComp <CompShip>().GenerateInternalTradeShip(Find.CurrentMap);

                GenPlace.TryPlaceThing(thing, UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4));
            }));


            list.Add(new DebugMenuOption("Crash", DebugMenuOptionMode.Tool, delegate()
            {
                Thing ship    = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
                CompShip comp = ship.TryGetComp <CompShip>();
                comp.GenerateInternalTradeShip(Find.CurrentMap);
                comp.mustCrash = true;
                GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Globals.TraderShipsShipCrashing, ship), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near);
            }));

            List <DebugMenuOption> options = list;

            Find.WindowStack.Add(new Dialog_DebugOptionListLister(options));
        }
Beispiel #12
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);
        }
Beispiel #13
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 #14
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);
            }
        }
        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 #16
0
        public override void MapLoaded(Map map)
        {
            base.MapLoaded(map);

            CompatabilityAddMissingWaterTags();
            AddDefaultFishableTags();
            AddDefaultWaterAffordances();
            Logger.Message("MapLoaded: Fishable terrain options: " + string.Join(", ", FetchFishingTagged().ConvertAll <string>(t => t.ToString()).ToArray()));

            // Cleanup extra dolphins
            foreach (Thing d in map.GetDirectlyHeldThings().Where((Thing t) => (t as DolphinAway) != null))
            {
                Logger.Message("Caught a lazy dolphin... teleporting off-world");
                d.Destroy();
            }

            IntVec3?launchPoint = RandomFishable(map);

            if (launchPoint.HasValue)
            {
                Logger.Message("Humans are here... so long and thanks for all the fish @ (" + launchPoint + ")");
                DolphinAway dolphin = (DolphinAway)ThingMaker.MakeThing(ThingDef.Named("DolphinAway"), null);
                // Needs his fish before leaving...
                Thing fish = ThingMaker.MakeThing(ThingDef.Named("DeadFish"));
                dolphin.innerContainer.TryAdd(fish);
                this.dolphinLeaving = (DolphinAway)SkyfallerMaker.MakeSkyfaller(ThingDef.Named("DolphinAway"), dolphin);
                GenSpawn.Spawn(this.dolphinLeaving, launchPoint.GetValueOrDefault(), map);
            }
        }
        public override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            List <TargetInfo> list        = new List <TargetInfo>();
            ThingDef          shipPartDef = def.mechClusterBuilding;
            IntVec3           intVec      = FindDropPodLocation(map, (IntVec3 spot) => CanPlaceAt(spot));

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

            thing.SetFaction(faction, null);
            List <Pawn> list2 = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
            {
                groupKind = PawnGroupKindDefOf.Combat,
                tile      = map.Tile,
                faction   = faction,
                points    = points
            }).ToList();

            LordMaker.MakeNewLord(faction, new LordJob_SleepThenMechanoidsDefend(new List <Thing>
            {
                thing
            }, faction, 28f, intVec, canAssaultColony: false, isMechCluster: false), map, list2);
            DropPodUtility.DropThingsNear(intVec, map, list2.Cast <Thing>());
            foreach (Pawn item in list2)
            {
                item.TryGetCompFast <CompCanBeDormant>()?.ToSleep();
            }
            list.AddRange(list2.Select((Pawn p) => new TargetInfo(p)));
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, thing), intVec, map);
            list.Add(new TargetInfo(intVec, map));
            SendStandardLetter(parms, list);
            return(true);

            bool CanPlaceAt(IntVec3 loc)
            {
                CellRect cellRect = GenAdj.OccupiedRect(loc, Rot4.North, shipPartDef.Size);

                if (loc.Fogged(map) || !cellRect.InBounds(map))
                {
                    return(false);
                }
                foreach (IntVec3 item2 in cellRect)
                {
                    RoofDef roof = item2.GetRoof(map);
                    if (roof != null && roof.isNatural)
                    {
                        return(false);
                    }
                }
                return(GenConstruct.CanBuildOnTerrain(shipPartDef, loc, map, Rot4.North));
            }
        }
Beispiel #18
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(parms);
            List <TargetInfo> list = new List <TargetInfo>();

            Rand.PushState();
            float shrapnelDirection = Rand.Range(0f, 360f);

            Rand.PopState();
            Faction faction = null;
            CompProperties_SpawnerOnDamaged props = this.def.mechClusterBuilding?.GetCompProperties <CompProperties_SpawnerOnDamaged>();

            if (props == null)
            {
                return(false);
            }

            /*
             * if (faction == null)
             * {
             *  faction = onDamaged.OfFaction;
             *  if (faction == null)
             *  {
             *      return false;
             *  }
             * }
             */
            for (int i = 0; i < countToSpawn; i++)
            {
                IntVec3              intVec;
                Building             CrashedShipPart = (Building)ThingMaker.MakeThing(this.def.mechClusterBuilding, null);
                CompSpawnerOnDamaged onDamaged       = CrashedShipPart.TryGetComp <CompSpawnerOnDamaged>();
                ThingDef             faller          = onDamaged?.Props.skyFaller ?? ThingDefOf.CrashedShipPartIncoming;
                if (!CellFinderLoose.TryFindSkyfallerCell(faller, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, true, false, null))
                {
                    break;
                }
                //    CrashedShipPart.SetFaction(faction, null);
                if (onDamaged != null)
                {
                    onDamaged.pointsLeft = Mathf.Max(parms.points * 0.9f, 300f);
                }

                Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(faller, CrashedShipPart);
                skyfaller.shrapnelDirection = shrapnelDirection;
                Thing thing =
                    GenSpawn.Spawn(skyfaller, intVec, map, WipeMode.Vanish);
                num++;
                list.Add(CrashedShipPart);
            }
            if (num > 0)
            {
                base.SendStandardLetter(parms, list, Array.Empty <NamedArgument>());
            }
            return(num > 0);
        }
        public void TryLaunch(int destinationTile)
        {
            var arrivalAction = CurrentArrivalAction;

            if (arrivalAction != null)
            {
                arrivalAction.source = parent;
            }

            // Play sounds
            var verb = Turret.CurrentEffectiveVerb;

            if (verb.verbProps.soundCast != null)
            {
                verb.verbProps.soundCast.PlayOneShot(new TargetInfo(parent.Position, parent.Map));
            }
            if (verb.verbProps.soundCastTail != null)
            {
                verb.verbProps.soundCastTail.PlayOneShotOnCamera(parent.Map);
            }

            // Make active artillery strike thing
            var activeArtilleryStrike = (ActiveArtilleryStrike)ThingMaker.MakeThing(ThingDefOf.VFES_ActiveArtilleryStrike);

            activeArtilleryStrike.missRadius = ArtilleryStrikeUtility.FinalisedMissRadius(Turret.CurrentEffectiveVerb.verbProps.ForcedMissRadius, Props.maxForcedMissRadiusFactor, parent.Tile, destinationTile, Props.worldTileRange);

            // Simulate an attack
            if (ChangeableProjectile != null)
            {
                activeArtilleryStrike.shellDef   = ChangeableProjectile.Projectile;
                activeArtilleryStrike.shellCount = 1;
                ChangeableProjectile.Notify_ProjectileLaunched();
            }
            else
            {
                activeArtilleryStrike.shellDef = verb.GetProjectile();
                for (int j = 0; j < verb.verbProps.burstShotCount; j++)
                {
                    activeArtilleryStrike.shellCount++;
                    if (verb.verbProps.consumeFuelPerShot > 0 && RefuelableComp != null)
                    {
                        RefuelableComp.ConsumeFuel(verb.verbProps.consumeFuelPerShot);
                    }
                }
            }
            NonPublicMethods.Building_TurretGun_BurstComplete(Turret);

            var artilleryStrikeLeaving = (ArtilleryStrikeLeaving)SkyfallerMaker.MakeSkyfaller(ThingDefOf.VFES_ArtilleryStrikeLeaving, activeArtilleryStrike);

            artilleryStrikeLeaving.startCell       = parent.Position;
            artilleryStrikeLeaving.edgeCell        = FacingEdgeCell;
            artilleryStrikeLeaving.rotation        = CurAngle;
            artilleryStrikeLeaving.destinationTile = destinationTile;
            artilleryStrikeLeaving.arrivalAction   = arrivalAction;
            artilleryStrikeLeaving.groupID         = Find.TickManager.TicksGame;

            GenSpawn.Spawn(artilleryStrikeLeaving, parent.Position, parent.Map);
        }
Beispiel #20
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 #21
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]--;
                }
            }
        }
        // Token: 0x060047C7 RID: 18375 RVA: 0x00180F4C File Offset: 0x0017F14C
        public override void GenerateIntoMap(Map map)
        {
            method = PlayerPawnsArriveMethod.DropShip;
            if (Find.GameInitData == null)
            {
                return;
            }
            List <List <Thing> > list = new List <List <Thing> >();

            foreach (Pawn item in Find.GameInitData.startingAndOptionalPawns)
            {
                list.Add(new List <Thing>
                {
                    item
                });
            }
            List <Thing> list2 = new List <Thing>();

            foreach (ScenPart scenPart in Find.Scenario.AllParts)
            {
                list2.AddRange(scenPart.PlayerStartingThings());
            }
            int num = 0;

            foreach (Thing thing in list2)
            {
                if (thing.def.CanHaveFaction)
                {
                    thing.SetFactionDirect(Faction.OfPlayer);
                }
                list[num].Add(thing);
                num++;
                if (num >= list.Count)
                {
                    num = 0;
                }
            }
            if ((int)this.method == (int)PlayerPawnsArriveMethod.DropShip)
            {
                Thing        thing    = ThingMaker.MakeThing(dropshipdef, null);
                CompDropship dropship = thing.TryGetComp <CompDropship>();
                foreach (List <Thing> item in list)
                {
                    dropship.Transporter.innerContainer.TryAddRangeOrTransfer(item);
                }
                dropship.autodustoff = true;

                if (DropCellFinder.TryFindDropSpotNear(MapGenerator.PlayerStartSpot, map, out IntVec3 spot, false, false, false, dropshipdef.Size))
                {
                    GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(dropship.Props.incomming, thing), spot, map, ThingPlaceMode.Near, null, null, default(Rot4));
                }
                else
                {
                    GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(dropship.Props.incomming, thing), MapGenerator.PlayerStartSpot, map, ThingPlaceMode.Near, null, null, default(Rot4));
                }
            }
Beispiel #23
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 #24
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);
        }
Beispiel #25
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);
            }
        }
        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 #28
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]--;
                }
            }
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map  = (Map)parms.target;
            Thing   ship = ThingMaker.MakeThing(Globals.TraderShipsShip, null);
            IntVec3 spot = RandomSpot(map);

            CompShip comp = ship.TryGetComp <CompShip>();

            comp.GenerateInternalTradeShip(map);
            comp.mustCrash = true;
            GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Globals.TraderShipsShipCrashing, ship), spot, map, ThingPlaceMode.Near);
            return(true);
        }
Beispiel #30
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);
            }
        }