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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 static bool Prefix(ActiveDropPod __instance)
 {
     try
     {
         var pod = __instance;
         if (pod?.Map == null)
         {
             return(true);
         }
         Mod.ShieldManager.ImpactShield(pod.Map, Common.ToVector2(pod.Position), (shield, point) =>
         {
             if (shield.Damage(Mod.Settings.DropPodDamage, point))
             {
                 foreach (var pawn in pod.Contents.innerContainer.Where(p => p is Pawn))
                 {
                     pawn.Kill(new DamageInfo(new DamageDef(), 100));
                 }
                 pod.Destroy();
                 return(true);
             }
             return(false);
         });
     }
     catch (InvalidOperationException) {}
     return(true);
 }
Esempio n. 5
0
        private void DropBomb()
        {
            for (int i = 0; i < (bombType == BombingType.precise ? this.precisionBombingNumBombs : 1); ++i)
            {
                if (innerContainer.Any(x => ((ActiveDropPod)x)?.Contents.innerContainer.Any(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)) ?? false))
                {
                    ActiveDropPod srts = (ActiveDropPod)innerContainer.First();

                    Thing thing = srts?.Contents.innerContainer.FirstOrDefault(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName));
                    if (thing is null)
                    {
                        return;
                    }

                    Thing thing2 = srts?.Contents.innerContainer.Take(thing, 1);

                    IntVec3 bombPos = bombCells[0];
                    if (bombType == BombingType.carpet)
                    {
                        bombCells.RemoveAt(0);
                    }
                    int timerTickExplode = 20 + Rand.Range(0, 5); //Change later to allow release timer
                    if (SRTSHelper.CEModLoaded)
                    {
                        goto Block_CEPatched;
                    }
                    FallingBomb bombThing = new FallingBomb(thing2, thing2.TryGetComp <CompExplosive>(), this.Map, this.def.skyfaller.shadow);
                    bombThing.HitPoints      = int.MaxValue;
                    bombThing.ticksRemaining = timerTickExplode;

                    IntVec3 c = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                 where x.InBounds(this.Map)
                                 select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);
                    bombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c) * -10);
                    bombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c) / bombThing.ticksRemaining;
                    Thing t = GenSpawn.Spawn(bombThing, c, this.Map);
                    GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(t, thing2.TryGetComp <CompExplosive>().Props.explosiveDamageType, null);
                    continue;

                    Block_CEPatched :;
                    ThingComp     CEComp      = (thing2 as ThingWithComps)?.AllComps.Find(x => x.GetType().Name == "CompExplosiveCE");
                    FallingBombCE CEbombThing = new FallingBombCE(thing2, CEComp.props, CEComp, this.Map, this.def.skyfaller.shadow);
                    CEbombThing.HitPoints      = int.MaxValue;
                    CEbombThing.ticksRemaining = timerTickExplode;
                    IntVec3 c2 = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                  where x.InBounds(this.Map)
                                  select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);
                    CEbombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c2) * -10);
                    CEbombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c2) / CEbombThing.ticksRemaining;
                    Thing CEt = GenSpawn.Spawn(CEbombThing, c2, this.Map);
                    //GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(CEt, DamageDefOf., null); /*Is GenExplosion CE compatible?*/
                }
            }
            if (bombType == BombingType.precise && bombCells.Any())
            {
                bombCells.Clear();
            }
        }
Esempio n. 6
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);
 }
Esempio n. 7
0
 public static void MakeSRTSBombingAt(IntVec3 c1, IntVec3 c2, List <IntVec3> bombCells, BombingType bombType, Map map, ActiveDropPodInfo info, Map originalMap, IntVec3 returnSpot)
 {
     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 srts     = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(shipType + "_Active"), null);
             srts.Contents = info;
             BomberSkyfallerMaker.SpawnSkyfaller(ThingDef.Named(shipType + "_BomberRun"), srts, c1, c2, bombCells, bombType, map, ship.thingIDNumber, ship, originalMap, returnSpot);
         }
     }
 }
Esempio n. 8
0
        public static void Prefix(ActiveDropPod __instance)
        {
            ActiveDropPodInfo activeDropPodInfo = Traverse.Create((object)__instance).Field("contents").GetValue <ActiveDropPodInfo>();

            for (int index = activeDropPodInfo.innerContainer.Count - 1; index >= 0; --index)
            {
                Thing thing = activeDropPodInfo.innerContainer[index];
                if (thing?.TryGetComp <CompLaunchableSRTS>() != null)
                {
                    GenSpawn.Spawn(thing, __instance.Position, __instance.Map, thing.Rotation);
                    break;
                }
            }
        }
Esempio n. 9
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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        private void ExitMap()
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(this.def.defName.Split('_')[0] + "_Active"), null);

            activeDropPod.Contents = new ActiveDropPodInfo();
            activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer((IEnumerable <Thing>)((ActiveDropPod)innerContainer.First()).Contents.innerContainer, true, true);

            TravelingSRTS travelingTransportPods = (TravelingSRTS)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("TravelingSRTS", true));

            travelingTransportPods.Tile = this.Map.Tile;
            travelingTransportPods.SetFaction(Faction.OfPlayer);
            travelingTransportPods.destinationTile = this.originalMap.Tile;
            travelingTransportPods.arrivalAction   = new TransportPodsArrivalAction_LandInSpecificCell(this.originalMap.Parent, this.sourceLandingSpot);
            travelingTransportPods.flyingThing     = this;
            Find.WorldObjects.Add((WorldObject)travelingTransportPods);
            travelingTransportPods.AddPod(activeDropPod.Contents, true);
            this.Destroy();
        }
Esempio n. 12
0
 static bool Prefix(ref ActiveDropPod __instance)
 {
     if (__instance.Contents == null)
     {
         return(false);
     }
     __instance.Contents.innerContainer.ThingOwnerTick();
     if (!__instance.Spawned)
     {
         return(false);
     }
     __instance.age += RefcellRespeedConfig.currentTimeMultiplier;
     if (__instance.age <= __instance.Contents.openDelay)
     {
         return(false);
     }
     PodOpen(__instance);
     return(false);
 }
Esempio n. 13
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);
        }
        public void LaunchLightPod(Thing pod, CompTransporter compTransporter, int destinationTile, IntVec3 destinationCell)
        {
            Map           map                = this.Map;
            int           groupID            = compTransporter.groupID;
            ThingOwner    directlyHeldThings = compTransporter.GetDirectlyHeldThings();
            ActiveDropPod activeDropPod      = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod);

            activeDropPod.Contents = new ActiveDropPodInfo();
            activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, canMergeWithExistingStacks: true, destroyLeftover: true);
            WorldTransport.TM_DropPodLeaving obj = (WorldTransport.TM_DropPodLeaving)SkyfallerMaker.MakeSkyfaller(TorannMagicDefOf.TM_LightPodLeaving, activeDropPod);
            obj.groupID         = groupID;
            obj.destinationTile = destinationTile;
            obj.arrivalAction   = null;
            obj.arrivalCell     = destinationCell;
            obj.draftFlag       = this.draftFlag;
            compTransporter.CleanUpLoadingVars(map);
            compTransporter.parent.Destroy();
            GenSpawn.Spawn(obj, compTransporter.parent.Position, map);
        }
Esempio n. 15
0
        public void Launch(int destinationTile, TransportPodsArrivalAction arrivalAction)
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod);

            activeDropPod.Contents = new ActiveDropPodInfo();
            activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(caravan.GetDirectlyHeldThings(), true, true);

            TravelingTransportPods travelingTransportPods = (TravelingTransportPods)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.TravelingShuttle);

            travelingTransportPods.Tile = Tile;
            travelingTransportPods.SetFaction(Faction.OfPlayer);
            travelingTransportPods.destinationTile = destinationTile;
            travelingTransportPods.arrivalAction   = arrivalAction;
            travelingTransportPods.AddPod(activeDropPod.Contents, false);
            Find.WorldObjects.Add(travelingTransportPods);

            caravan.Destroy();
            settlementFC.shuttleUsesRemaining -= cost;
        }
        public void LaunchLightPod(int destinationTile, IntVec3 destinationCell, TransportPodsArrivalAction arrivalAction)
        {
            Map map = this.CasterPawn.Map;

            CreatePodGroup();
            podTList[0].TryRemoveLord(map);
            int groupID = podTList[0].groupID;

            for (int i = 0; i < podTList.Count; i++)
            {
                ThingOwner    directlyHeldThings = podTList[i].GetDirectlyHeldThings();
                ActiveDropPod activeDropPod      = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod);
                activeDropPod.Contents = new ActiveDropPodInfo();
                activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, canMergeWithExistingStacks: true, destroyLeftover: true);
                WorldTransport.TM_DropPodLeaving obj = (WorldTransport.TM_DropPodLeaving)SkyfallerMaker.MakeSkyfaller(TorannMagicDefOf.TM_LightPodLeaving, activeDropPod);
                obj.groupID         = groupID;
                obj.destinationTile = destinationTile;
                obj.arrivalAction   = arrivalAction;
                obj.arrivalCell     = destinationCell;
                obj.draftFlag       = this.draftFlag;
                podTList[i].CleanUpLoadingVars(map);
                podTList[i].parent.Destroy();
                GenSpawn.Spawn(obj, podTList[i].parent.Position, map);
            }
            CameraJumper.TryHideWorld();
            if (!map.mapPawns.AnyColonistSpawned && !map.IsPlayerHome)
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("TM_AbandoningMap".Translate(map.Parent.LabelCap));
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(stringBuilder.ToString(), delegate
                {
                    Settlement sm = map.Parent as Settlement;
                    WorldTransport.TM_DelayedDestroyMap ddm = new WorldTransport.TM_DelayedDestroyMap();
                    ddm.parent     = sm;
                    ddm.delayTicks = 120;
                    sm.AllComps.Add(ddm);
                }));
            }
        }
        public static void Prefix(ActiveDropPod __instance)
        {
            ActiveDropPodInfo activeDropPodInfo = Traverse.Create((object)__instance).Field("contents").GetValue <ActiveDropPodInfo>();

            for (int index = activeDropPodInfo.innerContainer.Count - 1; index >= 0; --index)
            {
                Thing thing = activeDropPodInfo.innerContainer[index];
                if (thing != null && thing.def.defName == "Building_Helicopter")
                {
                    Thing lastResultingThing;
                    GenPlace.TryPlaceThing(thing, __instance.Position, __instance.Map, ThingPlaceMode.Direct, out lastResultingThing, (Action <Thing, int>)((placedThing, count) =>
                    {
                        if (Find.TickManager.TicksGame >= 1200 || !TutorSystem.TutorialMode || placedThing.def.category != ThingCategory.Item)
                        {
                            return;
                        }
                        Find.TutorialState.AddStartingItem(placedThing);
                    }), (Predicate <IntVec3>)null);
                    break;
                }
            }
        }
Esempio n. 18
0
        public static void Prefix(ActiveDropPod __instance)
        {
            Traverse          tv       = Traverse.Create(__instance);
            ActiveDropPodInfo contents = tv.Field("contents").GetValue <ActiveDropPodInfo>();

            for (int i = contents.innerContainer.Count - 1; i >= 0; i--)
            {
                Thing thing = contents.innerContainer[i];
                Thing thing2;
                if (thing != null && thing.def.defName == "Building_Helicopter")
                {
                    GenPlace.TryPlaceThing(thing, __instance.Position, __instance.Map, ThingPlaceMode.Direct, out thing2, delegate(Thing placedThing, int count)
                    {
                        if (Find.TickManager.TicksGame < 1200 && TutorSystem.TutorialMode && placedThing.def.category == ThingCategory.Item)
                        {
                            Find.TutorialState.AddStartingItem(placedThing);
                        }
                    }, null);
                    break;
                }
            }
        }
 public static void RecordPodContents(ActiveDropPod __instance)
 {
     RerollToolbox.RecordPlayerAddedMapThings(__instance, __instance.Map);
 }
        private void DropBomb()
        {
            for (int i = 0; i < (bombType == BombingType.precise ? this.precisionBombingNumBombs : 1); ++i)
            {
                if (innerContainer.Any(x => ((ActiveDropPod)x)?.Contents.innerContainer.Any(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)) ?? false))
                {
                    ActiveDropPod srts = (ActiveDropPod)innerContainer.First();

                    Thing thing = srts?.Contents.innerContainer.FirstOrDefault(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName));
                    if (thing is null)
                    {
                        return;
                    }

                    Thing thing2 = srts?.Contents.innerContainer.Take(thing, 1);

                    IntVec3 bombPos = bombCells[0];
                    if (bombType == BombingType.carpet)
                    {
                        bombCells.RemoveAt(0);
                    }
                    int timerTickExplode = 20 + Rand.Range(0, 5); //Change later to allow release timer
                    if (SRTSHelper.CEModLoaded)
                    {
                        goto Block_CEPatched;
                    }
                    FallingBomb bombThing = new FallingBomb(thing2, thing2.TryGetComp <CompExplosive>(), this.Map, this.def.skyfaller.shadow);
                    bombThing.HitPoints      = int.MaxValue;
                    bombThing.ticksRemaining = timerTickExplode;

                    IntVec3 c = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                 where x.InBounds(this.Map)
                                 select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);
                    bombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c) * -10);
                    bombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c) / bombThing.ticksRemaining;
                    Thing t = GenSpawn.Spawn(bombThing, c, this.Map);
                    GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(t, thing2.TryGetComp <CompExplosive>().Props.explosiveDamageType, null);
                    continue;

                    Block_CEPatched :;
                    // Replaced referencing the projectile trough the detonateProjectile property of the item's def with referencing trough AmmoSetDef. The reason is taht not all mortar shells had detonateProjectile. Don't ask how I came up with this.
                    ProjectileCE_Explosive bombCE = (ProjectileCE_Explosive)ThingMaker.MakeThing((thing2.def as AmmoDef).AmmoSetDefs.Find(set => set.ammoTypes.Any()).ammoTypes.Find(link => link.ammo == (thing2.def as AmmoDef)).projectile, null);
                    //ProjectileCE_Explosive bombCE = (ProjectileCE_Explosive)ThingMaker.MakeThing((AccessTools.Field(thing2.def.GetType(), "detonateProjectile").GetValue(thing2.def) as ThingDef), null);

                    /*ThingComp CEComp = (thing2 as ThingWithComps)?.AllComps.Find(x => x.GetType().Name == "CompExplosiveCE");
                     * FallingBombCE CEbombThing = new FallingBombCE(thing2, CEComp.props, CEComp, this.Map, this.def.skyfaller.shadow);
                     * CEbombThing.HitPoints = int.MaxValue;
                     * CEbombThing.ticksRemaining = timerTickExplode;*/
                    IntVec3 c2 = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                  where x.InBounds(this.Map)
                                  select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);

                    /*CEbombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c2) * -10);
                     * CEbombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c2) / CEbombThing.ticksRemaining;
                     * Thing CEt = GenSpawn.Spawn(CEbombThing, c2, this.Map);*/
                    //Basically Im stea- "borrrowing" code from Verb_LaunchProjectileCE.
                    GenSpawn.Spawn(bombCE, this.DrawPosCell, this.Map);
                    bombCE.canTargetSelf        = false;
                    bombCE.minCollisionDistance = 1;
                    bombCE.intendedTarget       = null;
                    bombCE.AccuracyFactor       = 1f;
                    bombCE.Launch(this,
                                  this.DrawPosCell.ToIntVec2.ToVector2(),
                                  0f,
                                  this.angle + UnityEngine.Random.Range(-60f, 60f),
                                  5f,
                                  (float)SPExtra.Distance(this.DrawPosCell, c2),
                                  this);
                    //GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(CEt, DamageDefOf., null); /*Is GenExplosion CE compatible?*/
                }
            }
            if (bombType == BombingType.precise && bombCells.Any())
            {
                bombCells.Clear();
            }
        }
        // Token: 0x060028DA RID: 10458 RVA: 0x001352F0 File Offset: 0x001336F0
        public void TryLaunch(int destinationTile, TransportPodsArrivalAction arrivalAction, Caravan cafr = null)
        {
            //Log.Warning("CARR:" + this.carr+"/"+cafr);
            if (cafr == null)
            {
                if (!this.parent.Spawned)
                {
                    Log.Error("Tried to launch " + this.parent + ", but it's unspawned.", false);
                    return;
                }
            }

            /*
             * List<CompTransporter> transportersInGroup = this.TransportersInGroup;
             * if (transportersInGroup == null)
             * {
             *  Log.Error("Tried to launch " + this.parent + ", but it's not in any group.", false);
             *  return;
             * }
             */
            if (this.parent.Spawned)
            {
                if (!this.LoadingInProgressOrReadyToLaunch)
                {
                    return;
                }
            }
            if (!this.AllInGroupConnectedToFuelingPort || !this.AllFuelingPortSourcesInGroupHaveAnyFuel)
            {
                return;
            }
            if (cafr == null)
            {
                Map map = this.parent.Map;
                int num = Find.WorldGrid.TraversalDistanceBetween(map.Tile, destinationTile, true, int.MaxValue);
                if (num > this.MaxLaunchDistance)
                {
                    return;
                }
                this.Transporter.TryRemoveLord(map);
                int   groupID = this.Transporter.groupID;
                float amount  = Mathf.Max(CompLaunchableHelicopter.FuelNeededToLaunchAtDist((float)num), 1f);
                //for (int i = 0; i < transportersInGroup.Count; i++)

                CompTransporter compTransporter   = this.FuelingPortSource.TryGetComp <CompTransporter>(); //transportersInGroup[i];
                Building        fuelingPortSource = this.FuelingPortSource;                                //compTransporter.Launchable.FuelingPortSource;
                if (fuelingPortSource != null)
                {
                    fuelingPortSource.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
                }
                ThingOwner directlyHeldThings = compTransporter.GetDirectlyHeldThings();

                Thing helicopter = ThingMaker.MakeThing(ThingDef.Named("Building_Helicopter"));
                helicopter.SetFactionDirect(Faction.OfPlayer);

                CompRefuelable compr  = helicopter.TryGetComp <CompRefuelable>();
                Type           tcr    = compr.GetType();
                FieldInfo      finfos = tcr.GetField("fuel", BindingFlags.NonPublic | BindingFlags.Instance);
                finfos.SetValue(compr, fuelingPortSource.TryGetComp <CompRefuelable>().Fuel);

                compr.TargetFuelLevel = fuelingPortSource.TryGetComp <CompRefuelable>().TargetFuelLevel;

                helicopter.stackCount = 1;
                directlyHeldThings.TryAddOrTransfer(helicopter);

                ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named("ActiveHelicopter"), null);
                activeDropPod.Contents = new ActiveDropPodInfo();
                activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, true, true);
                HelicopterLeaving dropPodLeaving = (HelicopterLeaving)SkyfallerMaker.MakeSkyfaller(ThingDef.Named("HelicopterLeaving"), activeDropPod);
                dropPodLeaving.groupID         = groupID;
                dropPodLeaving.destinationTile = destinationTile;
                dropPodLeaving.arrivalAction   = arrivalAction;
                compTransporter.CleanUpLoadingVars(map);
                //compTransporter.parent
                IntVec3 poc = fuelingPortSource.Position;
                // fuelingPortSource.Destroy(DestroyMode.Vanish);
                HelicopterStatic.HelicopterDestroy(fuelingPortSource, DestroyMode.Vanish);
                GenSpawn.Spawn(dropPodLeaving, poc, map, WipeMode.Vanish);

                CameraJumper.TryHideWorld();
            }
            else
            {
                int num = Find.WorldGrid.TraversalDistanceBetween(carr.Tile, destinationTile, true, int.MaxValue);
                if (num > this.MaxLaunchDistance)
                {
                    return;
                }
                float amount = Mathf.Max(CompLaunchableHelicopter.FuelNeededToLaunchAtDist((float)num), 1f);
                if (FuelingPortSource != null)
                {
                    FuelingPortSource.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
                }


                ThingOwner <Pawn> directlyHeldThings = (ThingOwner <Pawn>)cafr.GetDirectlyHeldThings();
                Thing             helicopter         = null;
                foreach (Pawn pawn in directlyHeldThings.InnerListForReading)
                {
                    Pawn_InventoryTracker pinv = pawn.inventory;
                    for (int i = 0; i < pinv.innerContainer.Count; i++)
                    {
                        if (pinv.innerContainer[i].def.defName == ("Building_Helicopter"))
                        {
                            helicopter = pinv.innerContainer[i];
                            pinv.innerContainer[i].holdingOwner.Remove(pinv.innerContainer[i]);

                            break;
                        }
                    }
                }

                ThingOwner <Thing> finalto = new ThingOwner <Thing>();
                List <Pawn>        lpto    = directlyHeldThings.AsEnumerable <Pawn>().ToList();
                foreach (Pawn p in lpto)
                {
                    finalto.TryAddOrTransfer(p);
                }


                if (helicopter != null)
                {
                    // Log.Warning("TRY ADD"+helicopter);
                    if (helicopter.holdingOwner == null)
                    {
                        //Log.Warning("NULL");
                        //directlyHeldThings.
                        finalto.TryAddOrTransfer(helicopter, false);
                    }
                }


                ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named("ActiveHelicopter"), null);
                activeDropPod.Contents = new ActiveDropPodInfo();
                activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(
                    //directlyHeldThings
                    finalto, true, true);

                cafr.RemoveAllPawns();
                if (cafr.Spawned)
                {
                    Find.WorldObjects.Remove(cafr);
                }

                TravelingTransportPods travelingTransportPods = (TravelingTransportPods)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("TravelingHelicopters", true));
                travelingTransportPods.Tile = cafr.Tile;
                travelingTransportPods.SetFaction(Faction.OfPlayer);
                travelingTransportPods.destinationTile = destinationTile;
                travelingTransportPods.arrivalAction   = arrivalAction;
                Find.WorldObjects.Add(travelingTransportPods);
                travelingTransportPods.AddPod(activeDropPod.Contents, true);
                activeDropPod.Contents = null;
                activeDropPod.Destroy(DestroyMode.Vanish);
                // CameraJumper.TryHideWorld();
                Find.WorldTargeter.StopTargeting();
            }
        }
Esempio n. 22
0
        //private bool ChoseWorldTarget(GlobalTargetInfo target)
        //{
        //    Utility.DebugReport("ChooseWorldTarget Called");
        //    if (!LoadingInProgressOrReadyToLaunch)
        //    {
        //        return true;
        //    }

        //    if (!target.IsValid)
        //    {
        //        Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput);
        //        return false;
        //    }

        //    var num = Find.WorldGrid.TraversalDistanceBetween(parent.Map.Tile, target.Tile);
        //    if (num > MaxLaunchDistance)
        //    {
        //        //Messages.Message("MessageTransportPodsDestinationIsTooFar".Translate(new object[]
        //        //{
        //        //    CompLaunchable.FuelNeededToLaunchAtDist((float)num).ToString("0.#")
        //        //}), MessageTypeDefOf.RejectInput);
        //        return false;
        //    }

        //    if (target.WorldObject is MapParent {HasMap: true} mapParent)
        //    {
        //        var myMap = parent.Map;
        //        var map = mapParent.Map;
        //        Current.Game.CurrentMap = map;
        //        var arg_139_0 = Find.Targeter;

        //        void ActionWhenFinished()
        //        {
        //            if (Find.Maps.Contains(myMap))
        //            {
        //                Current.Game.CurrentMap = myMap;
        //            }
        //        }

        //        arg_139_0.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
        //        {
        //            if (!LoadingInProgressOrReadyToLaunch)
        //            {
        //                Utility.DebugReport("ChooseTarget Exited - LoadingInProgressOrReadyToLaunch");
        //                return;
        //            }

        //            TryLaunch(x.ToGlobalTargetInfo(map), PawnsArrivalModeDefOf.EdgeDrop, false);
        //        }, null, ActionWhenFinished, TargeterMouseAttachment);
        //        return true;
        //    }

        //    if (target.WorldObject is Settlement && target.WorldObject.Faction != Faction.OfPlayer)
        //    {
        //        Find.WorldTargeter.closeWorldTabWhenFinished = false;
        //        var list = new List<FloatMenuOption>();
        //        if (!target.WorldObject.Faction.HostileTo(Faction.OfPlayer))
        //        {
        //            list.Add(new FloatMenuOption("VisitFactionBase".Translate(
        //                target.WorldObject.Label
        //            ), delegate
        //            {
        //                if (!LoadingInProgressOrReadyToLaunch)
        //                {
        //                    return;
        //                }

        //                TryLaunch(target, PawnsArrivalModeDefOf.EdgeDrop, false);
        //                CameraJumper.TryHideWorld();
        //            }));
        //        }

        //        list.Add(new FloatMenuOption("DropAtEdge".Translate(), delegate
        //        {
        //            if (!LoadingInProgressOrReadyToLaunch)
        //            {
        //                return;
        //            }

        //            TryLaunch(target, PawnsArrivalModeDefOf.EdgeDrop, true);
        //            CameraJumper.TryHideWorld();
        //        }));
        //        list.Add(new FloatMenuOption("DropInCenter".Translate(), delegate
        //        {
        //            if (!LoadingInProgressOrReadyToLaunch)
        //            {
        //                return;
        //            }

        //            TryLaunch(target, PawnsArrivalModeDefOf.CenterDrop, true);
        //            CameraJumper.TryHideWorld();
        //        }));
        //        Find.WindowStack.Add(new FloatMenu(list));
        //        return true;
        //    }
        //    Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput);
        //    return false;
        //    //this.TryLaunch(target, PawnsArrivalModeDefOf.Undecided, false);
        //    //return true;
        //}

        public void TryLaunch(int destinationTile, TransportPodsArrivalAction arrivalAction)
        {
            Utility.DebugReport("TryLaunch Called");
            if (!parent.Spawned)
            {
                Log.Error("Tried to launch " + parent + ", but it's unspawned.");
                return;
            }

            var transportersInGroup = TransportersInGroup;

            if (transportersInGroup == null)
            {
                Log.Error("Tried to launch " + parent + ", but it's not in any group.");
                return;
            }

            if (!LoadingInProgressOrReadyToLaunch)
            {
                Utility.DebugReport("TryLaunch Failed");
                return;
            }

            var map = parent.Map;
            var num = Find.WorldGrid.TraversalDistanceBetween(map.Tile, destinationTile);

            if (num > MaxLaunchDistance)
            {
                Utility.DebugReport("TryLaunch Failed #2");
                return;
            }

            Transporter.TryRemoveLord(map);
            var groupID = Transporter.groupID;

            foreach (var compTransporterPawn in transportersInGroup)
            {
                var compTransporter = compTransporterPawn;
                var originalPawn    = (Pawn)compTransporter.parent;
                var oldPosition     = compTransporter.parent.Position;


                ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod, null);
                activeDropPod.Contents = new ActiveDropPodInfo();
                activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(compTransporter.GetDirectlyHeldThings(), true, true);
                FlyShipLeaving flyShipLeaving = (FlyShipLeaving)SkyfallerMaker.MakeSkyfaller(PawnFlyerDef.leavingDef ?? ThingDefOf.DropPodLeaving, activeDropPod);
                flyShipLeaving.groupID         = groupID;
                flyShipLeaving.destinationTile = destinationTile;
                flyShipLeaving.arrivalAction   = arrivalAction;
                flyShipLeaving.worldObjectDef  = PawnFlyerDef.travelingDef;
                //flyShipLeaving.worldObjectDef = WorldObjectDefOf.TravelingTransportPods;
                compTransporter.CleanUpLoadingVars(map);
                //compTransporter.parent.Destroy(DestroyMode.Vanish);
                compTransporterPawn.parent.DeSpawn();
                flyShipLeaving.Contents.innerContainer.TryAddOrTransfer(originalPawn);
                GenSpawn.Spawn(flyShipLeaving, oldPosition, map, WipeMode.Vanish);

                //Utility.DebugReport("Transporter Outspawn Attempt");
                //var compTransporter = compTransporterPawn;
                //Utility.DebugReport("Transporter Outspawn " + compTransporter.parent.Label);
                //var pawnFlyerLeaving = (Skyfaller) ThingMaker.MakeThing(PawnFlyerDef.leavingDef);
                //pawnFlyerLeaving.groupID = groupID;
                //pawnFlyerLeaving.pawnFlyer = parent as PawnFlyer;
                //pawnFlyerLeaving.destinationTile = target.Tile;
                //pawnFlyerLeaving.destinationCell = target.Cell;
                //pawnFlyerLeaving.arriveMode = arriveMode;
                //pawnFlyerLeaving.attackOnArrival = attackOnArrival;
                //var innerContainer = compTransporter.GetDirectlyHeldThings();
                //pawnFlyerLeaving.Contents = new ActiveDropPodInfo();
                //innerContainer.TryTransferAllToContainer(pawnFlyerLeaving.Contents.innerContainer);
                ////pawnFlyerLeaving.Contents.innerContainer. //TryAddMany(innerContainer);
                //innerContainer.Clear();
                //compTransporter.CleanUpLoadingVars(map);
                //compTransporter.parent.DeSpawn();
                //pawnFlyerLeaving.Contents.innerContainer.TryAdd(compTransporter.parent);
                //GenSpawn.Spawn(pawnFlyerLeaving, compTransporter.parent.Position, map);
            }
            CameraJumper.TryHideWorld();
        }
Esempio n. 23
0
        private void TryLaunchBombRun(int destTile, Pair <IntVec3, IntVec3> targetPoints, IEnumerable <IntVec3> bombCells, MapParent mapParent)
        {
            if (!this.parent.Spawned)
            {
                Log.Error("Tried to launch " + this.parent + ", but it's unspawned.");
                return;
            }

            if (!CompLauncher.LoadingInProgressOrReadyToLaunch || !CompLauncher.AllInGroupConnectedToFuelingPort || !CompLauncher.AllFuelingPortSourcesInGroupHaveAnyFuel)
            {
                return;
            }

            Map map = this.parent.Map;
            int num = Find.WorldGrid.TraversalDistanceBetween(map.Tile, destTile);

            if (num > CompLauncher.MaxLaunchDistance)
            {
                return;
            }
            CompLauncher.Transporter.TryRemoveLord(map);
            int             groupID        = CompLauncher.Transporter.groupID;
            float           amount         = Mathf.Max(CompLaunchableSRTS.FuelNeededToLaunchAtDist((float)num, this.parent.GetComp <CompLaunchableSRTS>().BaseFuelPerTile), 1f);
            CompTransporter comp1          = CompLauncher.FuelingPortSource.TryGetComp <CompTransporter>();
            Building        fuelPortSource = CompLauncher.FuelingPortSource;

            if (fuelPortSource != null)
            {
                fuelPortSource.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
            }
            ThingOwner directlyHeldThings = comp1.GetDirectlyHeldThings();

            Thing thing = ThingMaker.MakeThing(ThingDef.Named(parent.def.defName), null);

            thing.SetFactionDirect(Faction.OfPlayer);
            thing.Rotation = CompLauncher.FuelingPortSource.Rotation;
            CompRefuelable comp2 = thing.TryGetComp <CompRefuelable>();

            comp2.GetType().GetField("fuel", BindingFlags.Instance | BindingFlags.NonPublic).SetValue((object)comp2, (object)fuelPortSource.TryGetComp <CompRefuelable>().Fuel);
            comp2.TargetFuelLevel = fuelPortSource.TryGetComp <CompRefuelable>().TargetFuelLevel;
            thing.stackCount      = 1;
            directlyHeldThings.TryAddOrTransfer(thing, true);

            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(parent.def.defName + "_Active"), null);

            activeDropPod.Contents = new ActiveDropPodInfo();
            activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer((IEnumerable <Thing>)directlyHeldThings, true, true);

            SRTSLeaving srtsLeaving = (SRTSLeaving)SkyfallerMaker.MakeSkyfaller(ThingDef.Named(parent.def.defName + "_Leaving"), (Thing)activeDropPod);

            srtsLeaving.rotation        = CompLauncher.FuelingPortSource.Rotation;
            srtsLeaving.groupID         = groupID;
            srtsLeaving.destinationTile = destTile;
            srtsLeaving.arrivalAction   = new SRTSArrivalActionBombRun(mapParent, targetPoints, bombCells, this.bombType, map, CompLauncher.FuelingPortSource.Position);

            comp1.CleanUpLoadingVars(map);
            IntVec3 position = fuelPortSource.Position;

            SRTSStatic.SRTSDestroy((Thing)fuelPortSource, DestroyMode.Vanish);
            GenSpawn.Spawn((Thing)srtsLeaving, position, map, WipeMode.Vanish);
            CameraJumper.TryHideWorld();
        }
        public void TryLaunch(int destinationTile, TransportPodsArrivalAction arrivalAction, Caravan cafr = null)
        {
            if (cafr == null && !this.parent.Spawned)
            {
                Log.Error("Tried to launch " + (object)this.parent + ", but it's unspawned.", false);
            }
            else
            {
                if (this.parent.Spawned && !this.LoadingInProgressOrReadyToLaunch || (!this.AllInGroupConnectedToFuelingPort || !this.AllFuelingPortSourcesInGroupHaveAnyFuel))
                {
                    return;
                }
                if (cafr == null)
                {
                    Map map = this.parent.Map;
                    int num = Find.WorldGrid.TraversalDistanceBetween(map.Tile, destinationTile, true, int.MaxValue);
                    if (num > this.MaxLaunchDistance)
                    {
                        return;
                    }
                    this.Transporter.TryRemoveLord(map);
                    int             groupId           = this.Transporter.groupID;
                    float           amount            = Mathf.Max(CompLaunchableSRTS.FuelNeededToLaunchAtDist((float)num), 1f);
                    CompTransporter comp1             = this.FuelingPortSource.TryGetComp <CompTransporter>();
                    Building        fuelingPortSource = this.FuelingPortSource;
                    if (fuelingPortSource != null)
                    {
                        fuelingPortSource.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
                    }
                    ThingOwner directlyHeldThings = comp1.GetDirectlyHeldThings();

                    // Neceros Edit
                    Thing thing = ThingMaker.MakeThing(ThingDef.Named(parent.def.defName), (ThingDef)null);
                    thing.SetFactionDirect(Faction.OfPlayer);
                    thing.Rotation = this.FuelingPortSource.Rotation;
                    CompRefuelable comp2 = thing.TryGetComp <CompRefuelable>();
                    comp2.GetType().GetField("fuel", BindingFlags.Instance | BindingFlags.NonPublic).SetValue((object)comp2, (object)fuelingPortSource.TryGetComp <CompRefuelable>().Fuel);
                    comp2.TargetFuelLevel = fuelingPortSource.TryGetComp <CompRefuelable>().TargetFuelLevel;
                    thing.stackCount      = 1;
                    directlyHeldThings.TryAddOrTransfer(thing, true);

                    // Neceros Edit
                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(parent.def.defName + "_Active"), null);
                    activeDropPod.Contents = new ActiveDropPodInfo();
                    activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer((IEnumerable <Thing>)directlyHeldThings, true, true);

                    // Neceros Edit
                    SRTSLeaving srtsLeaving = (SRTSLeaving)SkyfallerMaker.MakeSkyfaller(ThingDef.Named(parent.def.defName + "_Leaving"), (Thing)activeDropPod);
                    srtsLeaving.rotation        = this.FuelingPortSource.Rotation;
                    srtsLeaving.groupID         = groupId;
                    srtsLeaving.destinationTile = destinationTile;
                    srtsLeaving.arrivalAction   = arrivalAction;
                    comp1.CleanUpLoadingVars(map);
                    IntVec3 position = fuelingPortSource.Position;
                    SRTSStatic.SRTSDestroy((Thing)fuelingPortSource, DestroyMode.Vanish);
                    GenSpawn.Spawn((Thing)srtsLeaving, position, map, WipeMode.Vanish);
                    CameraJumper.TryHideWorld();
                }
                else
                {
                    int num = Find.WorldGrid.TraversalDistanceBetween(this.carr.Tile, destinationTile, true, int.MaxValue);
                    if (num > this.MaxLaunchDistance)
                    {
                        return;
                    }
                    float amount = Mathf.Max(CompLaunchableSRTS.FuelNeededToLaunchAtDist((float)num), 1f);
                    if (this.FuelingPortSource != null)
                    {
                        this.FuelingPortSource.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
                    }
                    ThingOwner <Pawn> directlyHeldThings = (ThingOwner <Pawn>)cafr.GetDirectlyHeldThings();
                    Thing             thing = null;
                    foreach (Pawn pawn in directlyHeldThings.InnerListForReading)
                    {
                        Pawn_InventoryTracker inventory = pawn.inventory;
                        for (int index = 0; index < inventory.innerContainer.Count; ++index)
                        {
                            // Neceros Edit
                            if (inventory.innerContainer[index].TryGetComp <CompLaunchableSRTS>() != null)
                            {
                                thing = inventory.innerContainer[index];
                                inventory.innerContainer[index].holdingOwner.Remove(inventory.innerContainer[index]);
                                break;
                            }
                        }
                    }
                    /*Add caravan items to SRTS - SmashPhil */
                    foreach (Pawn p in directlyHeldThings.InnerListForReading)
                    {
                        p.inventory.innerContainer.InnerListForReading.ForEach(x => AddThingsToSRTS(x));
                        p.inventory.innerContainer.Clear();
                    }

                    ThingOwner <Thing> thingOwner = new ThingOwner <Thing>();
                    foreach (Pawn pawn in directlyHeldThings.AsEnumerable <Pawn>().ToList <Pawn>())
                    {
                        thingOwner.TryAddOrTransfer((Thing)pawn, true);
                    }
                    if (thing != null && thing.holdingOwner == null)
                    {
                        thingOwner.TryAddOrTransfer(thing, false);
                    }

                    // Neceros Edit
                    ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(parent.def.defName + "_Active"), (ThingDef)null);
                    activeDropPod.Contents = new ActiveDropPodInfo();
                    activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer((IEnumerable <Thing>)thingOwner, true, true);
                    activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer((IEnumerable <Thing>)thingsInsideShip, true, true);
                    thingsInsideShip.Clear();

                    cafr.RemoveAllPawns();
                    if (cafr.Spawned)
                    {
                        Find.WorldObjects.Remove((WorldObject)cafr);
                    }
                    TravelingTransportPods travelingTransportPods = (TravelingTransportPods)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("TravelingSRTS", true));
                    travelingTransportPods.Tile = cafr.Tile;
                    travelingTransportPods.SetFaction(Faction.OfPlayer);
                    travelingTransportPods.destinationTile = destinationTile;
                    travelingTransportPods.arrivalAction   = arrivalAction;
                    Find.WorldObjects.Add((WorldObject)travelingTransportPods);
                    travelingTransportPods.AddPod(activeDropPod.Contents, true);
                    activeDropPod.Contents = (ActiveDropPodInfo)null;
                    activeDropPod.Destroy(DestroyMode.Vanish);
                    Find.WorldTargeter.StopTargeting();
                }
            }
        }
Esempio n. 25
0
 static void PodOpen(ActiveDropPod instance)
 {
 }