Ejemplo n.º 1
0
        public ShipBase_Traveling(ShipBase ship, bool launchAsFleet = false, TravelingShipArrivalAction arrivalAction = TravelingShipArrivalAction.StayOnWorldMap)
        {
            this.containingShip  = ship;
            this.def             = ship.compShip.sProps.LeavingShipDef;
            this.def.size        = ship.def.size;
            this.def.graphicData = ship.def.graphicData;
            this.launchAsFleet   = launchAsFleet;
            this.Rotation        = ship.Rotation;

            this.arrivalAction = arrivalAction;
        }
Ejemplo n.º 2
0
 public ShipBase_Traveling(ShipBase ship, RimWorld.Planet.GlobalTargetInfo target, PawnsArriveMode arriveMode, TravelingShipArrivalAction arrivalAction = TravelingShipArrivalAction.StayOnWorldMap, bool leavingForTarget = true)
 {
     this.containingShip   = ship;
     this.def              = ship.compShip.sProps.LeavingShipDef;
     this.def.size         = ship.def.size;
     this.def.graphicData  = ship.def.graphicData;
     this.destinationTile  = target.Tile;
     this.destinationCell  = target.Cell;
     this.pawnArriveMode   = arriveMode;
     this.leavingForTarget = leavingForTarget;
     this.Rotation         = ship.Rotation;
     this.arrivalAction    = arrivalAction;
 }
Ejemplo n.º 3
0
        public void SwitchOriginToDest()
        {
            this.traveledPct = 0f;
            this.arrived = false;
            this.arrivalAction = TravelingShipArrivalAction.EnterMapFriendly;

            int bufferTile = this.destinationTile;

            this.destinationCell = this.launchCell;
            this.destinationTile = this.initialTile;

            this.initialTile = bufferTile;
            this.launchCell = IntVec3.Zero;
        }
Ejemplo n.º 4
0
 public void TryLaunch(RimWorld.Planet.GlobalTargetInfo target, PawnsArriveMode arriveMode, TravelingShipArrivalAction arrivalAction, bool launchedAsSingleShip = false)
 {
     this.timeToLiftoff = 0;
     if (this.parentLandedShip == null)
     {
         this.shipState = ShipState.Outgoing;
         ShipBase_Traveling travelingShip = new ShipBase_Traveling(this, target, arriveMode, arrivalAction);
         GenSpawn.Spawn(travelingShip, this.Position, this.Map);
         this.DeSpawn();
         if (this.LaunchAsFleet)
         {
             foreach (ShipBase current in DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID))
             {
                 if (current != this)
                 {
                     current.shipState = ShipState.Outgoing;
                     ShipBase_Traveling travelingShip2 = new ShipBase_Traveling(current, target, arriveMode, arrivalAction);
                     GenSpawn.Spawn(travelingShip2, current.Position, current.Map);
                     current.DeSpawn();
                 }
             }
         }
     }
     else
     {
         //      Find.WorldSelector.Select(parentLandedShip);
         TravelingShipsUtility.LaunchLandedFleet(this.parentLandedShip, target.Tile, target.Cell, arriveMode, arrivalAction);
         this.landedShipCached = null;
         //Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.World, false);
     }
 }
Ejemplo n.º 5
0
        public static void DropShipGroups(IntVec3 dropCenter, Map map, List <ShipBase> shipsToDrop, TravelingShipArrivalAction arrivalAction, bool launchdAsSingleShip = false)
        {
            foreach (ShipBase current in shipsToDrop)
            {
                IntVec3 dropLoc;
                //      if (TryFindShipDropLocationNear(dropCenter, 200, map, out dropLoc, current.def.size))
                //   if (DropCellFinder.TryFindRaidDropCenterClose(out dropLoc, map))
                try
                {
                    dropLoc = dropCenter;
                    if (dropLoc.IsValid && launchdAsSingleShip)
                    {
                        Log.Message("Dropping single Ship");
                    }
                    else
                    {
                        if (!DropShipUtility.TryFindShipDropSpotNear(current, dropCenter, map, out dropLoc, true, true))
                        {
                            DropShipUtility.TryFindShipDropSpotNear(current, DropCellFinder.FindRaidDropCenterDistant(map), map, out dropLoc, true, true);
                        }
                    }
                    current.drawTickOffset          = current.compShip.sProps.TicksToImpact + Rand.Range(10, 60);
                    current.ActivatedLaunchSequence = false;
                    current.shipState = ShipState.Incoming;
                    ShipBase_Traveling incomingShip = new ShipBase_Traveling(current, false, arrivalAction);
                    //             Log.Message("Dropping " + incomingShip.containingShip.ShipNick);
                    GenSpawn.Spawn(incomingShip, dropLoc, map);
                }

                catch (Exception ex)
                {
                    Log.Error("Couldn't drop ships in map: " + ex.ToString());
                }
            }
        }
Ejemplo n.º 6
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);
            }
        }