public void AddAllTradeables() { foreach (Thing current in TradeSession.trader.ColonyThingsWillingToBuy(TradeSession.playerNegotiator)) { if (TradeUtility.PlayerSellableNow(current)) { this.AddToTradeables(current, Transactor.Colony); } } if (!TradeSession.giftMode) { foreach (Thing current2 in TradeSession.trader.Goods) { this.AddToTradeables(current2, Transactor.Trader); } } //if (!TradeSession.giftMode) //{ // if (this.tradeables.Find((Tradeable x) => x.IsCurrency) == null) // { // Thing thing = ThingMaker.MakeThing(ThingDefOf.Silver, null); // thing.stackCount = 0; // this.AddToTradeables(thing, Transactor.Trader); // } //} }
/*[HarmonyPostfix] * public static void AllLaunchableThingsForTradePostfix(Map map, IEnumerable<Thing> __result) * { * * }*/ private static IEnumerable <Thing> AllLaunchableThingsForTrade(Map map) { HashSet <Thing> yielded = new HashSet <Thing>(); foreach (IntVec3 cell in AllTradeableCells(map)) { List <Thing> thingList = cell.GetThingList(map); for (int i = 0; i < thingList.Count(); i++) { Thing t = thingList[i]; if (t.def.category == ThingCategory.Item && TradeUtility.PlayerSellableNow(t) && !yielded.Contains(t)) { yielded.Add(t); yield return(t); } } } }
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); } } } } ZUtils.TeleportThing(___pawn, oldMap, oldPosition); if (select) { Find.Selector.Select(___pawn); } __result = result; }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { foreach (Map map in Find.Maps) { if (map.IsPlayerHome) { foreach (Thing thing in map.listerThings.AllThings) { if (thing.IsInAnyStorage() == true && thing.def.category == ThingCategory.Item && TradeUtility.PlayerSellableNow(thing, this) && !FactionColonies.canCraftItem(thing.def, true)) { yield return(thing); } } } } }