public bool CanFulfillRequest(LandedShip tradeShip) { Pawn pawn = tradeShip.Map.PlayerPawnsForStoryteller.FirstOrDefault(); if (pawn == null) { return(false); } int foundCount = 0; foreach (Thing thing in tradeShip.ColonyThingsWillingToBuy(pawn).Where(x => x.def == requestedThingDef && PlayerCanGive(x))) { foundCount += thing.stackCount; } return(foundCount >= requestedCount); }
public void FulfillRequest(LandedShip tradeShip) { Pawn pawn = tradeShip.Map.PlayerPawnsForStoryteller.FirstOrDefault(); if (pawn == null) { return; } int toSend = requestedCount; foreach (Thing thing in tradeShip.ColonyThingsWillingToBuy(pawn).Where(x => x.def == requestedThingDef && PlayerCanGive(x)).OrderBy(x => x.MarketValue).ToList()) { int count = Math.Min(thing.stackCount, toSend); tradeShip.GiveSoldThingToTrader(thing, count, pawn); toSend -= count; if (toSend <= 0) { break; } } }