static bool Prefix(ref Settlement_TraderTracker __instance, ref TraderKindDef __result) { if (__instance.ParentHolder is City city) { __result = city.WorldTraderKind; return(false); } return(true); }
static bool Prefix(Settlement_TraderTracker __instance) { if (Multiplayer.Client != null) { var trading = Multiplayer.WorldComp.trading; for (int i = 0; i < trading.Count; i++) { if (trading[i].trader == __instance.settlement) { return(false); } } } return(true); }
public static bool GiveSoldThingToTraderPrefix(ref Settlement_TraderTracker __instance, Thing toGive, int countToGive, Pawn playerNegotiator) { WorldShip worldShip = playerNegotiator.GetWorldShip(); if (worldShip != null) { Thing thing = toGive.SplitOff(countToGive); var init = __instance.StockListForReading.Count; thing.PreTraded(TradeAction.PlayerSells, playerNegotiator, __instance.settlement); if (!__instance.GetDirectlyHeldThings().TryAdd(thing, false)) { thing.Destroy(DestroyMode.Vanish); } return(false); } return(true); }
public static void Postfix(Settlement_TraderTracker __instance) { Thing thing = ThingMaker.MakeThing(BankDefOf.BankNote); int min = 0; int max = 0; switch (__instance.settlement.Faction.def.techLevel) { case TechLevel.Neolithic: min = 0; max = 5; break; case TechLevel.Medieval: min = 3; max = 7; break; case TechLevel.Industrial: min = 4; max = 11; break; case TechLevel.Spacer: case TechLevel.Ultra: min = 7; max = 14; break; case TechLevel.Archotech: min = 9; max = 16; break; } thing.stackCount = Rand.Range(min, max); ((ThingOwner <Thing>)AccessTools.Field(typeof(Settlement_TraderTracker), "stock").GetValue(__instance)).TryAdd(thing); }
public City() { trader = new Settlement_TraderTracker(this); }
static bool Prefix(Settlement_TraderTracker __instance) { return(Multiplayer.Client == null || !Multiplayer.WorldComp.trading.Any(t => t.trader == __instance.settlement)); }