public static void RemoveExistingTransferable(TransferableOneWay transferable, Map map = null, ShipBase ship = null) { List <Thing> thingsInCargoToRemov = new List <Thing>(); List <ShipBase> tmpShips = new List <ShipBase>(); if (ship != null) { tmpShips.Add(ship); } else if (map != null) { tmpShips = DropShipUtility.ShipsOnMap(map); } else { Log.Error("Tried removing transferables with neither ship nor map specified"); } for (int j = 0; j < transferable.things.Count; j++) { for (int k = 0; k < tmpShips.Count; k++) { Thing thing = tmpShips[k].GetDirectlyHeldThings().FirstOrDefault(x => x == (transferable.things[j])); if (thing != null) { Log.Message("FoundCargo"); thingsInCargoToRemov.Add(transferable.things[j]); // transferable.CountToTransfer -= transferable.things[j].stackCount; } } } transferable.things.RemoveAll(x => thingsInCargoToRemov.Contains(x)); }
public Thing FindShip(Pawn pawn) { List <ShipBase> allShips = DropShipUtility.ShipsOnMap(pawn.Map).FindAll(x => DropShipUtility.HasPassengerSeats(x) && x.Faction == pawn.Faction); if (allShips.NullOrEmpty()) { return(null); } return(allShips.RandomElement()); }
public static void MaxCountTransferablePostFix(TransferableOneWay __instance) { Map map = Find.VisibleMap; List <ShipBase> ships = DropShipUtility.ShipsOnMap(map); for (int i = 0; i < ships.Count; i++) { for (int j = 0; j < ships[i].GetDirectlyHeldThings().Count; j++) { __instance.things.RemoveAll(x => ships[i].GetDirectlyHeldThings().Contains(x)); } } }
public static void RemoveExistingTransferable(TransferableOneWay transferable, Map map = null, ShipBase ship = null) { List <Thing> thingsInCargoToRemov = new List <Thing>(); List <ShipBase> tmpShips = new List <ShipBase>(); if (ship != null) { tmpShips.Add(ship); } else if (map != null) { tmpShips = DropShipUtility.ShipsOnMap(map); } else { Log.Error("Tried removing transferables with neither ship nor map specified"); } }
public Thing FindShip(Pawn pawn) { List <ShipBase> allShips = DropShipUtility.ShipsOnMap(pawn.Map).FindAll(x => DropShipUtility.HasPassengerSeats(x)); if (allShips.NullOrEmpty()) { return(null); } ShipBase ship = null; Log.Message(allShips.Count.ToString()); return(allShips.RandomElement()); //if (allShips.TryRandomElementByWeight<ShipBase>((ShipBase x) => 100 / x.Position.DistanceToSquared(pawn.Position), out ship)) //{ // Log.Message("Found"); // return ship; //} //else //{ // Log.Message("NotFoundShips"); // return null; //} }