private bool TrySplitCaravan() { List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables); if (!CheckForErrors(pawnsFromTransferables)) { return(false); } for (int i = 0; i < pawnsFromTransferables.Count; i++) { CaravanInventoryUtility.MoveAllInventoryToSomeoneElse(pawnsFromTransferables[i], caravan.PawnsListForReading, pawnsFromTransferables); } for (int j = 0; j < pawnsFromTransferables.Count; j++) { caravan.RemovePawn(pawnsFromTransferables[j]); } Caravan newCaravan = CaravanMaker.MakeCaravan(pawnsFromTransferables, caravan.Faction, caravan.Tile, addToWorldPawnsIfNotAlready: true); transferables.RemoveAll((TransferableOneWay x) => x.AnyThing is Pawn); for (int k = 0; k < transferables.Count; k++) { TransferableUtility.TransferNoSplit(transferables[k].things, transferables[k].CountToTransfer, delegate(Thing thing, int numToTake) { Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing); if (ownerOf == null) { Log.Error("Error while splitting a caravan: Thing " + thing + " has no owner. Where did it come from then?"); } else { CaravanInventoryUtility.MoveInventoryToSomeoneElse(ownerOf, thing, newCaravan.PawnsListForReading, null, numToTake); } }); } return(true); }