public static void Postfix(Caravan ___caravan, List <TransferableOneWay> ___transferables) { if (!SimpleSidearms.Settings.HideSidearmsInCaravanDialogs) { return; } if (___caravan?.pawns == null) { return; } // create list of all transferable things var caravanInventory = new List <Thing>(); foreach (var transferable in ___transferables) { caravanInventory.Add(transferable.AnyThing); } // remove sidearms from list var things = CaravanUtility.RemoveRememberedWeaponsFromThingList(caravanInventory, ___caravan.pawns); // remove sidearms from transferables (there surely are more efficient ways for doing this, but heh...) for (int i = 0; i < ___transferables.Count;) { var transferable = ___transferables[i]; if (!things.Contains(transferable.AnyThing)) { ___transferables.Remove(transferable); continue; } i++; } }
public static void Postfix(List <Pawn> __state) { if (!SimpleSidearms.Settings.PreserveInventoryInCaravans) { return; } if (!(__state?.Count > 0)) { return; } // check for missing sidearms and transfer ones picked up by other pawns back to the correct inventory CaravanUtility.TransferWeaponsToCorrectInventory(__state); }
public static IEnumerable <Thing> Postfix(IEnumerable <Thing> __result, Pawn playerNegotiator) { if (!SimpleSidearms.Settings.HideSidearmsInCaravanDialogs) { return(__result); } // get all pawns in the caravan var pawns = playerNegotiator?.GetCaravan()?.pawns; if (pawns?.Count > 0) { return(CaravanUtility.RemoveRememberedWeaponsFromThingList(__result.ToList(), pawns)); } // just in case there is no caravan for some reason return(__result); }