public static bool ShouldIgnoreInventoryOf(Pawn pawn, IgnorePawnsInventoryMode ignoreMode) { bool result; switch (ignoreMode) { case IgnorePawnsInventoryMode.Ignore: result = true; break; case IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload: result = (pawn.Spawned && pawn.inventory.UnloadEverything); break; case IgnorePawnsInventoryMode.IgnoreIfAssignedToUnloadOrPlayerPawn: result = ((pawn.Spawned && pawn.inventory.UnloadEverything) || Dialog_FormCaravan.CanListInventorySeparately(pawn)); break; case IgnorePawnsInventoryMode.DontIgnore: result = false; break; default: throw new NotImplementedException("IgnorePawnsInventoryMode"); } return(result); }
public static bool ShouldIgnoreInventoryOf(Pawn pawn, IgnorePawnsInventoryMode ignoreMode) { switch (ignoreMode) { case IgnorePawnsInventoryMode.Ignore: return(true); case IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload: if (pawn.Spawned) { return(pawn.inventory.UnloadEverything); } return(false); case IgnorePawnsInventoryMode.IgnoreIfAssignedToUnloadOrPlayerPawn: if (!pawn.Spawned || !pawn.inventory.UnloadEverything) { return(Dialog_FormCaravan.CanListInventorySeparately(pawn)); } return(true); case IgnorePawnsInventoryMode.DontIgnore: return(false); default: throw new NotImplementedException("IgnorePawnsInventoryMode"); } }
private void AddItemsFromTransferablesToRandomInventories(List <Pawn> pawns) { this.transferables.RemoveAll((TransferableOneWay x) => x.AnyThing is Pawn); if (this.ListPlayerPawnsInventorySeparately) { for (int i = 0; i < pawns.Count; i++) { if (Dialog_FormCaravan.CanListInventorySeparately(pawns[i])) { ThingOwner <Thing> innerContainer = pawns[i].inventory.innerContainer; for (int j = innerContainer.Count - 1; j >= 0; j--) { this.RemoveCarriedItemFromTransferablesOrDrop(innerContainer[j], pawns[i], this.transferables); } } } for (int k = 0; k < this.transferables.Count; k++) { if (this.transferables[k].things.Any((Thing x) => !x.Spawned)) { this.transferables[k].things.SortBy((Thing x) => x.Spawned); } } } for (int l = 0; l < this.transferables.Count; l++) { if (!(this.transferables[l].AnyThing is Corpse)) { TransferableUtility.Transfer(this.transferables[l].things, this.transferables[l].CountToTransfer, delegate(Thing splitPiece, IThingHolder originalHolder) { Thing item = splitPiece.TryMakeMinified(); CaravanInventoryUtility.FindPawnToMoveInventoryTo(item, pawns, null, null).inventory.innerContainer.TryAdd(item, true); }); } } for (int m = 0; m < this.transferables.Count; m++) { if (this.transferables[m].AnyThing is Corpse) { TransferableUtility.TransferNoSplit(this.transferables[m].things, this.transferables[m].CountToTransfer, delegate(Thing originalThing, int numToTake) { if (this.AutoStripSpawnedCorpses) { Corpse corpse = originalThing as Corpse; if (corpse != null && corpse.Spawned) { corpse.Strip(); } } Thing item = originalThing.SplitOff(numToTake); CaravanInventoryUtility.FindPawnToMoveInventoryTo(item, pawns, null, null).inventory.innerContainer.TryAdd(item, true); }, true, true); } } }
private void AddItemsToTransferables() { List <Thing> list = CaravanFormingUtility.AllReachableColonyItems(this.map, this.reform, this.reform, this.reform); for (int i = 0; i < list.Count; i++) { this.AddToTransferables(list[i], false); } if (this.AutoStripSpawnedCorpses) { for (int j = 0; j < list.Count; j++) { if (list[j].Spawned) { this.TryAddCorpseInventoryAndGearToTransferables(list[j]); } } } if (this.ListPlayerPawnsInventorySeparately) { List <Pawn> list2 = Dialog_FormCaravan.AllSendablePawns(this.map, this.reform); for (int k = 0; k < list2.Count; k++) { if (Dialog_FormCaravan.CanListInventorySeparately(list2[k])) { ThingOwner <Thing> innerContainer = list2[k].inventory.innerContainer; for (int l = 0; l < innerContainer.Count; l++) { this.AddToTransferables(innerContainer[l], true); if (this.AutoStripSpawnedCorpses && innerContainer[l].Spawned) { this.TryAddCorpseInventoryAndGearToTransferables(innerContainer[l]); } } } } } }