public static float ApproxDaysWorthOfFood_Ship(ShipBase ship, List <TransferableOneWay> transferables, bool canEatPlants) { tmpTransferables.Clear(); for (int i = 0; i < transferables.Count; i++) { TransferableOneWay oneWay = new TransferableOneWay(); oneWay.things.AddRange(transferables[i].things); oneWay.AdjustTo(transferables[i].CountToTransfer); Pawn pawn = oneWay.AnyThing as Pawn; tmpTransferables.Add(oneWay); } foreach (Pawn current in ship.GetDirectlyHeldThings().Where(x => x is Pawn)) { DropShipUtility.AddThingsToTransferables(tmpTransferables, current); } for (int i = 0; i < ship.GetDirectlyHeldThings().Count; i++) { if (!(ship.GetDirectlyHeldThings()[i] is Pawn)) { DropShipUtility.AddThingsToTransferables(tmpTransferables, ship.GetDirectlyHeldThings()[i]); } } return(DaysWorthOfFoodCalculator.ApproxDaysWorthOfFood(tmpTransferables, canEatPlants, IgnorePawnsInventoryMode.DontIgnore)); }
public static float ApproxDaysWorthOfFood_Ship(ShipBase ship, List <TransferableOneWay> transferables, bool canEatPlants) { tmpTransferables.Clear(); for (int i = 0; i < transferables.Count; i++) { TransferableOneWay oneWay = new TransferableOneWay(); oneWay.things.AddRange(transferables[i].things); oneWay.AdjustTo(transferables[i].CountToTransfer); Pawn pawn = oneWay.AnyThing as Pawn; tmpTransferables.Add(oneWay); } foreach (Pawn current in ship.GetDirectlyHeldThings().Where(x => x is Pawn)) { DropShipUtility.AddThingsToTransferables(tmpTransferables, current); } for (int i = 0; i < ship.GetDirectlyHeldThings().Count; i++) { if (!(ship.GetDirectlyHeldThings()[i] is Pawn)) { DropShipUtility.AddThingsToTransferables(tmpTransferables, ship.GetDirectlyHeldThings()[i]); } } var potentialFood = tmpTransferables.Where(t => (t.AnyThing is Pawn) == false).SelectMany(x => x.things).ToList(); var pawns = tmpTransferables.Where(t => t.AnyThing is Pawn).SelectMany(x => x.things).Cast <Pawn>().ToList(); return(DaysWorthOfFoodCalculator.ApproxDaysWorthOfFood(pawns, potentialFood, 0, IgnorePawnsInventoryMode.DontIgnore, ship.Faction)); }
public static void ReimbarkWorldPawnsForShip(ShipBase ship) { List <Thing> pawnsToMove = new List <Thing>(); foreach (Pawn current in ship.GetDirectlyHeldThings()) { current.holdingOwner = ship.GetDirectlyHeldThings(); if (!ship.GetDirectlyHeldThings().Contains(current)) { pawnsToMove.Add(current); } } ship.GetDirectlyHeldThings().TryAddRangeOrTransfer(pawnsToMove); }
public static List <Pawn> AllPawnsInShip(ShipBase ship) { List <Pawn> tmp = new List <Pawn>(); for (int i = 0; i > ship.GetDirectlyHeldThings().Count; i++) { Pawn pawn = ship.GetDirectlyHeldThings()[i] as Pawn; if (pawn != null) { tmp.Add(pawn); } } return(tmp); }
private void InterfaceDrop(Thing thing, ShipBase ship) { ship.GetDirectlyHeldThings().TryDrop(thing, ThingPlaceMode.Near, out thing); if (thing is Pawn) { Pawn pawn = (Pawn)thing; Lord LoadLord = LoadShipCargoUtility.FindLoadLord(ship, ship.Map); if (LoadLord != null) { LoadLord.ownedPawns.Remove(pawn); } } }
public void GiveSoldThingToPlayer(Thing toGive, int countToGive, Pawn playerNegotiator) { ShipBase shipBase = this.GetShipWithCargoSpace(); if (shipBase != null) { shipBase.GetDirectlyHeldThings().TryAddOrTransfer(toGive, countToGive, true); if (toGive is Pawn p) { if (p.IsWorldPawn()) { Find.WorldPawns.RemovePawn(p); } } } }
public void AddShip(ShipBase ship, bool justLeftTheMap) { if (!this.WorldShipData.Any(x => x.Ship == ship)) { WorldShipData worldShipData = new WorldShipData(ship); foreach (Thing t in ship.GetDirectlyHeldThings()) { if (t is Pawn p) { p.ClearMind(); //if (!Find.WorldPawns.Contains(p)) //{ // Find.WorldPawns.PassToWorld(p); //} } } this.WorldShipData.Add(worldShipData); } if (ship.fleetID > -1) { this._label = DropShipUtility.CurrentShipTracker.PlayerFleetManager[ship.fleetID]; } }
public static bool HasPassengerSeats(ShipBase ship) { return(ship.GetDirectlyHeldThings().ToList <Thing>().Count(x => x is Pawn && x.def.race.Humanlike) < ship.compShip.sProps.maxPassengers); }