public static bool AllInventoryItemsPrefix(ref SettlementBase_TraderTracker __instance, ref IEnumerable <Thing> __result, Pawn playerNegotiator) { WorldShip worldShip = playerNegotiator.GetWorldShip(); if (worldShip != null) { Predicate <Thing> cargoValidator = delegate(Thing t) { Pawn pawn = t as Pawn; if (pawn != null) { if (pawn.IsColonist || (pawn.records.GetAsInt(RecordDefOf.TimeAsColonistOrColonyAnimal) > 0 && pawn.records.GetAsInt(RecordDefOf.TimeAsPrisoner) == 0)) { return(false); } } return(true); }; List <Thing> newResult = new List <Thing>(); foreach (var data in worldShip.WorldShipData) { foreach (Thing t in data.Ship.GetDirectlyHeldThings().Where(x => cargoValidator(x))) { newResult.Add(t); } } __result = newResult; return(false); } return(true); }
public static bool GiveSoldThingToPlayerPrefix(ref SettlementBase_TraderTracker __instance, Thing toGive, int countToGive, Pawn playerNegotiator) { WorldShip worldShip = playerNegotiator.GetWorldShip(); if (worldShip != null) { Thing thing = toGive.SplitOff(countToGive); thing.PreTraded(TradeAction.PlayerBuys, playerNegotiator, __instance.settlement); worldShip.trader.GiveSoldThingToPlayer(toGive, countToGive, playerNegotiator); return(false); } return(true); }
static bool Prefix(SettlementBase_TraderTracker __instance) { return(Multiplayer.Client == null || !Multiplayer.WorldComp.trading.Any(t => t.trader == __instance.settlement)); }