public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod, null);

            activeDropPod.Contents = info;
            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.DropPodIncoming, activeDropPod, c, map);
        }
        public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info, bool explode = false)
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod, null);

            activeDropPod.Contents = info;
            ThingDef skyfaller = (!explode) ? ThingDefOf.DropPodIncoming : ThingDefOf.ExplosiveDropPodIncoming;

            SkyfallerMaker.SpawnSkyfaller(skyfaller, activeDropPod, c, map);
        }
Ejemplo n.º 3
0
        private void TryLaunch(GlobalTargetInfo target, PawnsArriveMode arriveMode, bool attackOnArrival)
        {
            if (!this.parent.Spawned)
            {
                Log.Error("Tried to launch " + this.parent + ", but it's unspawned.");
                return;
            }
            List <CompTransporter> transportersInGroup = this.TransportersInGroup;

            if (transportersInGroup == null)
            {
                Log.Error("Tried to launch " + this.parent + ", but it's not in any group.");
                return;
            }
            if (!this.LoadingInProgressOrReadyToLaunch || !this.AllInGroupConnectedToFuelingPort || !this.AllFuelingPortSourcesInGroupHaveAnyFuel)
            {
                return;
            }
            Map map = this.parent.Map;
            int num = Find.WorldGrid.TraversalDistanceBetween(map.Tile, target.Tile);

            if (num > this.MaxLaunchDistance)
            {
                return;
            }
            this.Transporter.TryRemoveLord(map);
            int   groupID = this.Transporter.groupID;
            float amount  = Mathf.Max(CompLaunchable.FuelNeededToLaunchAtDist((float)num), 1f);

            for (int i = 0; i < transportersInGroup.Count; i++)
            {
                CompTransporter compTransporter   = transportersInGroup[i];
                Building        fuelingPortSource = compTransporter.Launchable.FuelingPortSource;
                if (fuelingPortSource != null)
                {
                    fuelingPortSource.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
                }
                ThingOwner    directlyHeldThings = compTransporter.GetDirectlyHeldThings();
                ActiveDropPod activeDropPod      = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod, null);
                activeDropPod.Contents = new ActiveDropPodInfo();
                activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, true, true);
                DropPodLeaving dropPodLeaving = (DropPodLeaving)SkyfallerMaker.MakeSkyfaller(ThingDefOf.DropPodLeaving, activeDropPod);
                dropPodLeaving.groupID         = groupID;
                dropPodLeaving.destinationTile = target.Tile;
                dropPodLeaving.destinationCell = target.Cell;
                dropPodLeaving.arriveMode      = arriveMode;
                dropPodLeaving.attackOnArrival = attackOnArrival;
                compTransporter.CleanUpLoadingVars(map);
                compTransporter.parent.Destroy(DestroyMode.Vanish);
                GenSpawn.Spawn(dropPodLeaving, compTransporter.parent.Position, map);
            }
        }
Ejemplo n.º 4
0
        public void TryLaunch(int destinationTile, TransportPodsArrivalAction arrivalAction)
        {
            if (!parent.Spawned)
            {
                Log.Error(string.Concat("Tried to launch ", parent, ", but it's unspawned."));
                return;
            }
            List <CompTransporter> transportersInGroup = TransportersInGroup;

            if (transportersInGroup == null)
            {
                Log.Error(string.Concat("Tried to launch ", parent, ", but it's not in any group."));
            }
            else
            {
                if (!LoadingInProgressOrReadyToLaunch || !AllInGroupConnectedToFuelingPort || !AllFuelingPortSourcesInGroupHaveAnyFuel)
                {
                    return;
                }
                Map         map         = parent.Map;
                int         num         = Find.WorldGrid.TraversalDistanceBetween(map.Tile, destinationTile);
                CompShuttle compShuttle = parent.TryGetComp <CompShuttle>();
                if (num <= MaxLaunchDistance || (compShuttle != null && compShuttle.IsMissionShuttle))
                {
                    Transporter.TryRemoveLord(map);
                    int   groupID = Transporter.groupID;
                    float amount  = Mathf.Max(FuelNeededToLaunchAtDist(num), 1f);
                    compShuttle?.SendLaunchedSignals(transportersInGroup);
                    for (int i = 0; i < transportersInGroup.Count; i++)
                    {
                        CompTransporter compTransporter = transportersInGroup[i];
                        compTransporter.Launchable.FuelingPortSource?.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
                        ThingOwner    directlyHeldThings = compTransporter.GetDirectlyHeldThings();
                        ActiveDropPod activeDropPod      = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod);
                        activeDropPod.Contents = new ActiveDropPodInfo();
                        activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, canMergeWithExistingStacks: true, destroyLeftover: true);
                        DropPodLeaving obj = (DropPodLeaving)SkyfallerMaker.MakeSkyfaller(Props.skyfallerLeaving ?? ThingDefOf.DropPodLeaving, activeDropPod);
                        obj.groupID         = groupID;
                        obj.destinationTile = destinationTile;
                        obj.arrivalAction   = arrivalAction;
                        obj.worldObjectDef  = ((compShuttle != null) ? WorldObjectDefOf.TravelingShuttle : WorldObjectDefOf.TravelingTransportPods);
                        compTransporter.CleanUpLoadingVars(map);
                        compTransporter.parent.Destroy();
                        GenSpawn.Spawn(obj, compTransporter.parent.Position, map);
                    }
                    CameraJumper.TryHideWorld();
                }
            }
        }
Ejemplo n.º 5
0
        public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod);

            activeDropPod.Contents = info;
            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.DropPodIncoming, activeDropPod, c, map);
            foreach (Thing item in (IEnumerable <Thing>)activeDropPod.Contents.innerContainer)
            {
                Pawn pawn;
                if ((pawn = (item as Pawn)) != null && pawn.IsWorldPawn())
                {
                    Find.WorldPawns.RemovePawn(pawn);
                    pawn.psychicEntropy?.SetInitialPsyfocusLevel();
                }
            }
        }
Ejemplo n.º 6
0
 public void TryLaunch(int destinationTile, TransportPodsArrivalAction arrivalAction)
 {
     if (!this.parent.Spawned)
     {
         Log.Error("Tried to launch " + this.parent + ", but it's unspawned.", false);
     }
     else
     {
         List <CompTransporter> transportersInGroup = this.TransportersInGroup;
         if (transportersInGroup == null)
         {
             Log.Error("Tried to launch " + this.parent + ", but it's not in any group.", false);
         }
         else if (this.LoadingInProgressOrReadyToLaunch && this.AllInGroupConnectedToFuelingPort && this.AllFuelingPortSourcesInGroupHaveAnyFuel)
         {
             Map map = this.parent.Map;
             int num = Find.WorldGrid.TraversalDistanceBetween(map.Tile, destinationTile, true, int.MaxValue);
             if (num <= this.MaxLaunchDistance)
             {
                 this.Transporter.TryRemoveLord(map);
                 int   groupID = this.Transporter.groupID;
                 float amount  = Mathf.Max(CompLaunchable.FuelNeededToLaunchAtDist((float)num), 1f);
                 for (int i = 0; i < transportersInGroup.Count; i++)
                 {
                     CompTransporter compTransporter   = transportersInGroup[i];
                     Building        fuelingPortSource = compTransporter.Launchable.FuelingPortSource;
                     if (fuelingPortSource != null)
                     {
                         fuelingPortSource.TryGetComp <CompRefuelable>().ConsumeFuel(amount);
                     }
                     ThingOwner    directlyHeldThings = compTransporter.GetDirectlyHeldThings();
                     ActiveDropPod activeDropPod      = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod, null);
                     activeDropPod.Contents = new ActiveDropPodInfo();
                     activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, true, true);
                     DropPodLeaving dropPodLeaving = (DropPodLeaving)SkyfallerMaker.MakeSkyfaller(ThingDefOf.DropPodLeaving, activeDropPod);
                     dropPodLeaving.groupID         = groupID;
                     dropPodLeaving.destinationTile = destinationTile;
                     dropPodLeaving.arrivalAction   = arrivalAction;
                     compTransporter.CleanUpLoadingVars(map);
                     compTransporter.parent.Destroy(DestroyMode.Vanish);
                     GenSpawn.Spawn(dropPodLeaving, compTransporter.parent.Position, map, WipeMode.Vanish);
                 }
                 CameraJumper.TryHideWorld();
             }
         }
     }
 }