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()); } } }
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); } }
public static void DrawDropSpotShadow(ShipBase ship, int ticks, ShipBase_Traveling travelingShip = null) { if (ticks < 0) { ticks = 0; } Vector3 result = Gen.TrueCenter(ship); if (travelingShip != null) { result = travelingShip.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.FlyingItem); } result += DropShipUtility.drawOffsetFor(ship, ticks, true); result.y = Altitudes.AltitudeFor(AltitudeLayer.Shadows); Color white = Color.white; white.a = Mathf.InverseLerp(200f, 150f, (float)ticks); DropShipUtility.shadowPropertyBlock.SetColor(ShaderIDs.ColorId, white); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(result, ship.compShip.parent.Rotation.AsQuat, new Vector3(1f, 1f, 1f)); Graphics.DrawMesh(ship.compShip.parent.Graphic.MeshAt(ship.compShip.parent.Rotation), matrix, ship.compShip.dropShadow.MatSingle, 0, null, 0, DropShipUtility.shadowPropertyBlock); }
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); }
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); }
public static Vector3 DrawPosAt(ShipBase ship, int ticks, ShipBase_Traveling travelingShip = null) { if (ticks < 0) { ticks = 0; } Vector3 result = Gen.TrueCenter(ship); if (travelingShip != null) { result = Gen.TrueCenter(travelingShip.Position, travelingShip.containingShip.Rotation, travelingShip.containingShip.def.size, Altitudes.AltitudeFor(AltitudeLayer.FlyingItem)); } result += DropShipUtility.drawOffsetFor(ship, ticks, false); return(result); }
public static bool ShipIsAlreadyDropping(ShipBase ship, Map map) { if (ship.Spawned) { return(true); } IEnumerator <Thing> enumerator = map.listerThings.AllThings.Where(x => x is ShipBase_Traveling).GetEnumerator(); while (enumerator.MoveNext()) { ShipBase_Traveling current = enumerator.Current as ShipBase_Traveling; if (current.containingShip == ship) { return(true); } } return(false); }
private void ShipsLeaving() { WorldShip worldShip = (WorldShip)WorldObjectMaker.MakeWorldObject(ShipNamespaceDefOfs.WorldShip); worldShip.SetFaction(this.containingShip.Faction); worldShip.Tile = this.Map.Tile; worldShip.AddShip(this.containingShip, true); Find.World.worldObjects.Add(worldShip); 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; worldShip.AddShip(dropPodLeaving.containingShip, true); dropPodLeaving.Destroy(DestroyMode.Vanish); } } worldShip.Launch(this.destinationTile, this.destinationCell, arrivalAction, pawnArriveMode); this.DeSpawn(); }
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 override void Tick() { base.Tick(); if (Find.Targeter.IsTargeting || Find.WorldTargeter.IsTargeting) { if (this.isTargeting) { GhostDrawer.DrawGhostThing(UI.MouseCell(), this.Rotation, this.def, null, new Color(0.5f, 1f, 0.6f, 0.4f), AltitudeLayer.Blueprint); } } else { this.isTargeting = false; } for (int i = 0; i < DropShipUtility.AllPawnsInShip(this).Count; i++) { Pawn pawn = DropShipUtility.AllPawnsInShip(this)[i]; float num = 0.6f; float num2 = RestUtility.PawnHealthRestEffectivenessFactor(pawn); num = 0.7f * num + 0.3f * num * num2; pawn.needs.rest.TickResting(num); } if (this.shipState == ShipState.Incoming) { this.drawTickOffset--; if (this.drawTickOffset <= 0) { this.drawTickOffset = 0; } this.refuelableComp.ConsumeFuel(this.refuelableComp.Props.fuelConsumptionRate / 60f); } if (ReadyForTakeoff && ActivatedLaunchSequence) { this.timeToLiftoff--; if (this.ShouldWait) { int num = GenDate.TicksPerHour; this.timeToLiftoff += num; this.timeWaited += num; if (this.timeWaited >= maxTimeToWait) { this.ShouldWait = false; this.timeToLiftoff = 0; } } if (this.timeToLiftoff == 0) { this.shipState = ShipState.Outgoing; this.ActivatedLaunchSequence = false; this.timeWaited = 0; } } if (shipState == ShipState.Outgoing) { this.drawTickOffset++; this.refuelableComp.ConsumeFuel(this.refuelableComp.Props.fuelConsumptionRate / 60f); if (this.Spawned) { ShipBase_Traveling travelingShip = new ShipBase_Traveling(this); GenSpawn.Spawn(travelingShip, this.Position, this.Map); this.DeSpawn(); } } }
public override void Tick() { base.Tick(); if (Find.Targeter.IsTargeting || Find.WorldTargeter.IsTargeting) { if (this.IsTargeting) { GhostDrawer.DrawGhostThing(UI.MouseCell(), this.Rotation, this.def, null, new Color(0.5f, 1f, 0.6f, 0.4f), AltitudeLayer.Blueprint); } } else { this.IsTargeting = false; } for (int i = 0; i < DropShipUtility.AllPawnsInShip(this).Count; i++) { Pawn pawn = DropShipUtility.AllPawnsInShip(this)[i]; float num = 0.6f; num = 0.7f * num + 0.3f * num; pawn.needs.rest.TickResting(num); } if (this.shipState == ShipState.Incoming) { this.drawTickOffset--; if (this.drawTickOffset <= 0) { this.drawTickOffset = 0; } this.ConsumeFuel(); } if (ReadyForTakeoff && ActivatedLaunchSequence) { this.timeToLiftoff--; if (this.ShouldWait) { int num = GenDate.TicksPerHour; this.timeToLiftoff += num; this.timeWaited += num; if (this.timeWaited >= maxTimeToWait) { this.ShouldWait = false; this.timeToLiftoff = 0; } } if (this.timeToLiftoff == 0) { this.shipState = ShipState.Outgoing; this.ActivatedLaunchSequence = false; this.timeWaited = 0; } } if (shipState == ShipState.Outgoing) { this.drawTickOffset++; this.ConsumeFuel(); if (this.Spawned) { ShipBase_Traveling travelingShip = new ShipBase_Traveling(this, this.LaunchAsFleet, ShipArrivalAction.StayOnWorldMap); Map curMap = this.Map; IntVec3 curPos = this.Position; //GenSpawn.Spawn(travelingShip, curPos, curMap, this.Rotation, false); this.DeSpawn(); //Log.Message(GenAdj.CellsOccupiedBy(curPos, Rot4.North, def.Size).Count().ToString()); //foreach (IntVec3 current in GenAdj.CellsOccupiedBy(curPos, Rot4.North, def.Size)) //{ // Log.Message("A: " + curMap.thingGrid.ThingsAt(current).ToList<Thing>().Count.ToString()); // foreach (Thing current2 in curMap.thingGrid.ThingsAt(current).ToList<Thing>()) // { // if (current2.def == null) Log.Message("NoDef?"); // Log.Message("B"); // if (GenSpawn.SpawningWipes(def, current2.def)) // { // Log.Message("Destroyng:" + current2.Label); // current2.Destroy(DestroyMode.Vanish); // } // } //} GenSpawn.Spawn(travelingShip, curPos, curMap, this.Rotation, WipeMode.Vanish, false); } } }