private static void Postfix(Pawn ___pawn, ref IEnumerable <Thing> __result, Pawn playerNegotiator) { var result = __result.ToList(); Map oldMap = ___pawn.Map; IntVec3 oldPosition = playerNegotiator.Position; bool select = false; if (Find.Selector.SelectedObjects.Contains(___pawn)) { select = true; } foreach (var map in ZUtils.GetAllMapsInClosestOrder(___pawn, oldMap, oldPosition)) { if (map != oldMap) { IEnumerable <Thing> enumerable = ___pawn.Map.listerThings.AllThings.Where((Thing x) => x.def.category == ThingCategory.Item && TradeUtility.PlayerSellableNow(x, ___pawn) && !x.Position.Fogged(x.Map) && (___pawn.Map.areaManager.Home[x.Position] || x.IsInAnyStorage()) && ReachableForTrade(x, ___pawn)); foreach (Thing item in enumerable) { result.Add(item); } if (___pawn.GetLord() != null) { foreach (Pawn item2 in from x in TradeUtility.AllSellableColonyPawns(___pawn.Map) where !x.Downed && ReachableForTrade(x, ___pawn) select x) { result.Add(item2); } } } } if (___pawn.Map != oldMap) { Traverse.Create(___pawn).Field("mapIndexOrState") .SetValue((sbyte)Find.Maps.IndexOf(oldMap)); Traverse.Create(___pawn).Field("positionInt") .SetValue(oldPosition); } if (select) { Find.Selector.Select(___pawn); } __result = result; }
public new IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { HashSet <Thing> alreadyListed = new HashSet <Thing>(); // technically, this is pawn selling things to itself, but the code doesn't seem to care, and // using this method instead of just listing all things allows for compatibility with storage // mods that patch Pawn_TraderTracker.ColonyThingsWillingToBuy. foreach (Thing thing in new Pawn_TraderTracker(playerNegotiator).ColonyThingsWillingToBuy(playerNegotiator)) { alreadyListed.Add(thing); yield return(thing); } foreach (Pawn pawn in TradeUtility.AllSellableColonyPawns(playerNegotiator.Map).Where(x => !x.Downed && ReachableForTrade(playerNegotiator, x))) { if (!alreadyListed.Contains(pawn)) { yield return(pawn); } } yield break; }