private void TryLaunch(GlobalTargetInfo target, PawnsArrivalModeDef arriveMode, bool attackOnArrival)
        {
            Cthulhu.Utility.DebugReport("TryLaunch Called");
            if (!this.parent.Spawned)
            {
                Log.Error("Tried to launch " + this.parent + ", but it's unspawned.");
                return;
            }
            List <CompTransporterPawn> transportersInGroup = this.TransportersInGroup;

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

            if (num > this.MaxLaunchDistance)
            {
                Cthulhu.Utility.DebugReport("TryLaunch Failed #2");
                return;
            }
            this.Transporter.TryRemoveLord(map);
            int groupID = this.Transporter.groupID;

            for (int i = 0; i < transportersInGroup.Count; i++)
            {
                Cthulhu.Utility.DebugReport("Transporter Outspawn Attempt");
                CompTransporterPawn compTransporter = transportersInGroup[i];
                Cthulhu.Utility.DebugReport("Transporter Outspawn " + compTransporter.parent.Label);
                PawnFlyersLeaving pawnFlyerLeaving = (PawnFlyersLeaving)ThingMaker.MakeThing(PawnFlyerDef.leavingDef, null);
                pawnFlyerLeaving.groupID         = groupID;
                pawnFlyerLeaving.pawnFlyer       = this.parent as PawnFlyer;
                pawnFlyerLeaving.destinationTile = target.Tile;
                pawnFlyerLeaving.destinationCell = target.Cell;
                pawnFlyerLeaving.arriveMode      = arriveMode;
                pawnFlyerLeaving.attackOnArrival = attackOnArrival;
                ThingOwner 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);
            }
        }
Example #2
0
        private void GroupLeftMap()
        {
            if (this.groupID < 0)
            {
                Log.Error("Drop pod left the map, but its group ID is " + this.groupID);
                this.Destroy(DestroyMode.Vanish);
                return;
            }

            if (this.destinationTile < 0)
            {
                Log.Error("Drop pod left the map, but its destination tile is " + this.destinationTile);
                this.Destroy(DestroyMode.Vanish);
                return;
            }

            Lord lord = FindLord(this.groupID, base.Map);

            if (lord != null)
            {
                base.Map.lordManager.RemoveLord(lord);
            }

            PawnFlyersTraveling PawnFlyersTraveling = (PawnFlyersTraveling)WorldObjectMaker.MakeWorldObject(PawnFlyerDef.travelingDef);

            PawnFlyersTraveling.pawnFlyer       = this.pawnFlyer;
            PawnFlyersTraveling.Tile            = base.Map.Tile;
            PawnFlyersTraveling.destinationTile = this.destinationTile;
            PawnFlyersTraveling.destinationCell = this.destinationCell;
            PawnFlyersTraveling.arriveMode      = this.arriveMode;
            PawnFlyersTraveling.attackOnArrival = this.attackOnArrival;
            Find.WorldObjects.Add(PawnFlyersTraveling);
            PawnFlyersLeaving.tmpActiveDropPods.Clear();
            PawnFlyersLeaving.tmpActiveDropPods.AddRange(base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ActiveDropPod));

            for (int i = 0; i < PawnFlyersLeaving.tmpActiveDropPods.Count; i++)
            {
                PawnFlyersLeaving pawnFlyerLeaving = PawnFlyersLeaving.tmpActiveDropPods[i] as PawnFlyersLeaving;
                if (pawnFlyerLeaving != null && pawnFlyerLeaving.groupID == this.groupID)
                {
                    Cthulhu.Utility.DebugReport("Transport Already Left");
                    pawnFlyerLeaving.alreadyLeft = true;
                    PawnFlyersTraveling.AddPod(pawnFlyerLeaving.contents, true);
                    pawnFlyerLeaving.contents = null;
                    pawnFlyerLeaving.Destroy(DestroyMode.Vanish);
                }
            }
        }