internal void Arrive(IntVec3 targetCell, ShipArrivalAction arrivalAction, PawnsArrivalModeDef mapArrivalMode) { if (this.IsPlayerControlled && arrivalAction != ShipArrivalAction.BombingRun) { Messages.Message("MessageShipsArrived".Translate(), this, MessageTypeDefOf.NeutralEvent); } if (arrivalAction == ShipArrivalAction.EnterMapAssault || arrivalAction == ShipArrivalAction.EnterMapFriendly) { MapParent parent = Find.WorldObjects.MapParentAt(this.Tile); if (parent != null) { Map map = parent.Map; if (map == null) { LongEventHandler.QueueLongEvent(delegate { MapGeneratorDef def = WorldShipUtility.GetMapGeneratorDefForObject(parent); map = MapGenerator.GenerateMap(Find.World.info.initialMapSize, parent, MapGeneratorDefOf.Base_Faction); targetCell = IntVec3.Zero; }, "GeneratingMap", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap)); } LongEventHandler.QueueLongEvent(delegate { WorldShipUtility.EnterMapWithShip(this, map, targetCell, arrivalAction, mapArrivalMode); }, "SpawningColonists", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap)); } } else if (arrivalAction == ShipArrivalAction.BombingRun) { if (BombingUtility.TryBombWorldTarget(this.Tile, this)) { } } }
private static void Enter(WorldShip worldShip, Map map, IntVec3 targetCell, ShipArrivalAction arrivalAction, PawnsArrivalModeDef pawnsArrivalMode) { List <ShipBase> ships = worldShip.WorldShipData.Select(x => x.Ship).ToList(); IntVec3 cell = GetCellForArrivalMode(worldShip.WorldShipData[0].Ship, targetCell, map, pawnsArrivalMode); DropShipUtility.DropShipGroups(cell, map, ships, arrivalAction, worldShip.WorldShipData.Count == 1); if (worldShip.Spawned) { Find.WorldObjects.Remove(worldShip); } }
public ShipBase_Traveling(ShipBase ship, bool launchAsFleet = false, ShipArrivalAction arrivalAction = ShipArrivalAction.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; }
public static void DropSingleShip(Map map, IntVec3 dropLoc, ShipBase ship, ShipArrivalAction arrivalAction, bool dropPawns = true, bool dropItems = false) { ship.drawTickOffset = ship.compShip.sProps.TicksToImpact + Rand.Range(10, 60); ship.ActivatedLaunchSequence = false; ship.shipState = ShipState.Incoming; ShipBase_Traveling incomingShip = new ShipBase_Traveling(ship, false, arrivalAction); incomingShip.dropPawnsOnTochdown = dropPawns; incomingShip.dropItemsOnTouchdown = dropItems; GenSpawn.Spawn(incomingShip, dropLoc, map); }
public ShipBase_Traveling(ShipBase ship, RimWorld.Planet.GlobalTargetInfo target, PawnsArrivalModeDef arriveMode, ShipArrivalAction arrivalAction = ShipArrivalAction.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; }
public void SwitchOriginToDest() { this.traveledPct = 0f; this.arrived = false; this.arrivalAction = ShipArrivalAction.EnterMapFriendly; int bufferTile = this.destinationTile; this.destinationCell = this.launchCell; this.destinationTile = this.initialTile; this.initialTile = bufferTile; this.launchCell = IntVec3.Zero; }
public void SetDestination(int destTile, IntVec3 destinationCell, ShipArrivalAction arrivalAction, PawnsArrivalModeDef pawnsArrivalMode) { if (this.worldPath != null) { this.worldPath.Dispose(); } this._destinationTile = destTile; this._destinationCell = destinationCell; this._startTile = this._worldShip.Tile; this.drawTileStart = this._startTile; this.worldPath = DropShipUtility.CurrentShipTracker.WorldShipPathFinder.FindPath(_startTile, _destinationTile, this._worldShip, (int)this.MinTicksPerTile); this.status = WorldShipPatherStatus.Travelling; this.moving = true; this._arrivalAction = arrivalAction; this._mapArrivalMode = pawnsArrivalMode; this.currentTileTraversalTicksLeft = this.MinTicksPerTile; this._worldShip.IsTargeting = false; }
public static void EnterMapWithShip(WorldShip worldShip, Map map, IntVec3 targetCell, ShipArrivalAction arrivalAction, PawnsArrivalModeDef pawnsArrivalMode) { TravelingShipsUtility.Enter(worldShip, map, targetCell, arrivalAction, pawnsArrivalMode); }
public void TryLaunch(RimWorld.Planet.GlobalTargetInfo target, PawnsArrivalModeDef arriveMode, ShipArrivalAction arrivalAction, bool launchedAsSingleShip = false) { this.timeToLiftoff = 0; if (this.parentWorldShip == null) { this.shipState = ShipState.Outgoing; ShipBase_Traveling travelingShip = new ShipBase_Traveling(this, target, arriveMode, arrivalAction); Map curMap = this.Map; IntVec3 curPos = this.Position; this.DeSpawn(); GenSpawn.Spawn(travelingShip, curPos, curMap, this.Rotation, WipeMode.Vanish); if (this.LaunchAsFleet) { foreach (ShipBase current in DropShipUtility.CurrentShipTracker.ShipsInFleet(this.fleetID)) { if (current != this && current.Spawned) { current.shipState = ShipState.Outgoing; ShipBase_Traveling travelingShip2 = new ShipBase_Traveling(current, target, arriveMode, arrivalAction); Map shipMap = current.Map; IntVec3 shipPos = current.Position; current.DeSpawn(); GenSpawn.Spawn(travelingShip2, shipPos, shipMap, current.Rotation, WipeMode.Vanish); } } } } else { // Find.WorldSelector.Select(parentLandedShip); //WorldShipUtility.LaunchLandedFleet(this.parentWorldShip, target.Tile, target.Cell, arriveMode, arrivalAction); this.parentWorldShip.Launch(target.Tile, target.Cell, arrivalAction, arriveMode); //this.parentShipCached = null; //Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.World, false); } }
public static void DropShipGroups(IntVec3 dropCenter, Map map, List <ShipBase> shipsToDrop, ShipArrivalAction arrivalAction, bool launchdAsSingleShip = false) { foreach (ShipBase current in shipsToDrop.Where(x => !DropShipUtility.ShipIsAlreadyDropping(x, map))) { current.shouldSpawnTurrets = true; 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) { } 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); GenSpawn.Spawn(incomingShip, dropLoc, map); } catch (Exception ex) { Log.Error("Couldn't drop ships in map: " + ex.ToString()); } } }
public void Launch(int targetTile, IntVec3 targetCell, ShipArrivalAction arrivalAction = ShipArrivalAction.StayOnWorldMap, PawnsArrivalModeDef pawnsArrivalMode = null) { this.pather.SetDestination(targetTile, targetCell, arrivalAction, pawnsArrivalMode); }