Esempio n. 1
0
        public static void LaunchLandedFleet(LandedShip landedShip, int destinationTile, IntVec3 destinationCell, PawnsArriveMode pawnArriveMode, TravelingShipArrivalAction arrivalAction)
        {
            if (destinationTile < 0)
            {
                Log.Error("Tried launching landed ship, but its destination tile is " + destinationTile);
                return;
            }

            TravelingShips travelingShips = (TravelingShips)WorldObjectMaker.MakeWorldObject(ShipNamespaceDefOfs.TravelingSuborbitalShip);

            travelingShips.Tile = landedShip.Tile;
            travelingShips.SetFaction(landedShip.Faction);
            travelingShips.destinationTile = destinationTile;
            travelingShips.destinationCell = destinationCell;
            //        travelingShips.destinationCell = this.destinationCell;
            travelingShips.arriveMode    = pawnArriveMode;
            travelingShips.arrivalAction = arrivalAction;
            Find.WorldObjects.Add(travelingShips);
            foreach (ShipBase current in landedShip.ships)
            {
                travelingShips.AddShip(current, true);
                //            current.SavePotentialWorldPawns();
                DropShipUtility.ReimbarkWorldPawnsForLandedShip(current);
            }
            travelingShips.SetFaction(landedShip.Faction);
            TravelingShipsUtility.AddAllLandedPawnsToWorld(landedShip);
            if (Find.World.worldObjects.Contains(landedShip))
            {
                Find.World.worldObjects.Remove(landedShip);
            }
        }
Esempio n. 2
0
        private void GroupLeftMap()
        {
            if (this.destinationTile < 0)
            {
                Log.Error("Drop pod left the map, but its destination tile is " + this.destinationTile);
                this.Destroy(DestroyMode.Vanish);
                return;
            }
            TravelingShips travelingShips = (TravelingShips)WorldObjectMaker.MakeWorldObject(ShipNamespaceDefOfs.TravelingSuborbitalShip);

            travelingShips.Tile = base.Map.Tile;
            travelingShips.SetFaction(this.Faction);
            travelingShips.destinationTile = this.destinationTile;
            travelingShips.destinationCell = this.destinationCell;
            travelingShips.arriveMode      = this.pawnArriveMode;
            travelingShips.arrivalAction   = this.arrivalAction;
            Find.WorldObjects.Add(travelingShips);
            Predicate <Thing> predicate = delegate(Thing t)
            {
                if (t != this)
                {
                    if (t is ShipBase_Traveling)
                    {
                        ShipBase_Traveling ship = (ShipBase_Traveling)t;
                        if (ship.containingShip.shipState == ShipState.Outgoing)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            };
            List <Thing> tmpleavingShips = base.Map.listerThings.AllThings.FindAll(x => predicate(x));

            for (int i = 0; i < tmpleavingShips.Count; i++)
            {
                ShipBase_Traveling dropPodLeaving = tmpleavingShips[i] as ShipBase_Traveling;
                if (dropPodLeaving != null && dropPodLeaving.fleetID == this.fleetID)
                {
                    dropPodLeaving.alreadyLeft = true;
                    travelingShips.AddShip(dropPodLeaving.containingShip, true);
                    dropPodLeaving.Destroy(DestroyMode.Vanish);
                }
            }
            travelingShips.AddShip(this.containingShip, true);
            travelingShips.SetFaction(this.containingShip.Faction);

            this.Destroy(DestroyMode.Vanish);
        }
Esempio n. 3
0
        private void Arrived()
        {
            if (this.arrived)
            {
                return;
            }

            this.arrived = true;
            if (TravelingShipsUtility.TryAddToLandedFleet(this, this.destinationTile))
            {
                return;
            }
            if (this.arrivalAction == TravelingShipArrivalAction.BombingRun)
            {
                TravelingShips travelingShips = (TravelingShips)WorldObjectMaker.MakeWorldObject(ShipNamespaceDefOfs.TravelingSuborbitalShip);
                travelingShips.Tile = this.destinationTile;
                travelingShips.SetFaction(Faction.OfPlayer);
                travelingShips.destinationTile = this.initialTile;
                travelingShips.destinationCell = this.launchCell;
                travelingShips.arriveMode      = this.arriveMode;
                travelingShips.arrivalAction   = TravelingShipArrivalAction.EnterMapFriendly;
                Find.WorldObjects.Add(travelingShips);
                Find.WorldObjects.Remove(this);
            }
            else
            {
                Map map = Current.Game.FindMap(this.destinationTile);
                if (map != null)
                {
                    this.SpawnShipsInMap(map, null);
                }
                else if (!this.LandedShipHasCaravanOwner)
                {
                    for (int i = 0; i < this.ships.Count; i++)
                    {
                        this.ships[i].GetInnerContainer().ClearAndDestroyContentsOrPassToWorld(DestroyMode.Vanish);
                    }
                    this.RemoveAllPods();
                    Find.WorldObjects.Remove(this);
                    Messages.Message("MessageTransportPodsArrivedAndLost".Translate(), new GlobalTargetInfo(this.destinationTile), MessageSound.Negative);
                }
                else
                {
                    FactionBase factionBase = Find.WorldObjects.FactionBases.Find((FactionBase x) => x.Tile == this.destinationTile);

                    if (factionBase != null && factionBase.Faction != Faction.OfPlayer && this.arrivalAction != TravelingShipArrivalAction.StayOnWorldMap)
                    {
                        LongEventHandler.QueueLongEvent(delegate
                        {
                            Map map2 = AttackCaravanArrivalActionUtility.GenerateFactionBaseMap(factionBase);

                            string extraMessagePart = null;
                            if (this.arrivalAction == TravelingShipArrivalAction.EnterMapAssault && !factionBase.Faction.HostileTo(Faction.OfPlayer))
                            {
                                factionBase.Faction.SetHostileTo(Faction.OfPlayer, true);
                                extraMessagePart = "MessageTransportPodsArrived_BecameHostile".Translate(new object[]
                                {
                                    factionBase.Faction.Name
                                }).CapitalizeFirst();
                            }
                            Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                            Current.Game.VisibleMap       = map2;
                            Find.CameraDriver.JumpTo(map2.Center);
                            this.SpawnShipsInMap(map2, extraMessagePart);
                        }, "GeneratingMapForNewEncounter", false, null);
                    }
                    else
                    {
                        this.SpawnCaravanAtDestinationTile();
                    }
                }
            }
        }