public void GiveSoldThingToTrader(Thing toGive, int countToGive, Pawn playerNegotiator) { if (this.Goods.Contains(toGive)) { Log.Error("Tried to add " + toGive + " to stock (pawn's trader tracker), but it's already here.", false); return; } Pawn pawn = toGive as Pawn; if (pawn != null) { pawn.PreTraded(TradeAction.PlayerSells, playerNegotiator, this.pawn); this.AddPawnToStock(pawn); } else { Thing thing = toGive.SplitOff(countToGive); thing.PreTraded(TradeAction.PlayerSells, playerNegotiator, this.pawn); Thing thing2 = TradeUtility.ThingFromStockToMergeWith(this.pawn, thing); if (thing2 != null) { if (!thing2.TryAbsorbStack(thing, false)) { thing.Destroy(DestroyMode.Vanish); } } else { this.AddThingToRandomInventory(thing); } } }
private void InitPriceDataIfNeeded() { if (this.pricePlayerBuy > 0f) { return; } if (this.IsCurrency) { this.pricePlayerBuy = this.BaseMarketValue; this.pricePlayerSell = this.BaseMarketValue; return; } this.priceFactorBuy_TraderPriceType = this.PriceTypeFor(TradeAction.PlayerBuys).PriceMultiplier(); this.priceFactorSell_TraderPriceType = this.PriceTypeFor(TradeAction.PlayerSells).PriceMultiplier(); this.priceGain_PlayerNegotiator = TradeSession.playerNegotiator.GetStatValue(StatDefOf.TradePriceImprovement, true); this.priceGain_Settlement = TradeSession.trader.TradePriceImprovementOffsetForPlayer; this.priceFactorSell_ItemSellPriceFactor = this.AnyThing.GetStatValue(StatDefOf.SellPriceFactor, true); this.pricePlayerBuy = TradeUtility.GetPricePlayerBuy(this.AnyThing, this.priceFactorBuy_TraderPriceType, this.priceGain_PlayerNegotiator, this.priceGain_Settlement); this.pricePlayerSell = TradeUtility.GetPricePlayerSell(this.AnyThing, this.priceFactorSell_TraderPriceType, this.priceGain_PlayerNegotiator, this.priceGain_Settlement); if (this.pricePlayerSell >= this.pricePlayerBuy) { Log.ErrorOnce("Trying to put player-sells price above player-buys price for " + this.AnyThing, 65387, false); this.pricePlayerSell = this.pricePlayerBuy; } }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { using (IEnumerator <Thing> enumerator = TradeUtility.AllLaunchableThings(base.Map).GetEnumerator()) { if (enumerator.MoveNext()) { Thing t = enumerator.Current; yield return(t); /*Error: Unable to find new state assignment for yield return*/; } } using (IEnumerator <Pawn> enumerator2 = TradeUtility.AllSellableColonyPawns(base.Map).GetEnumerator()) { if (enumerator2.MoveNext()) { Pawn p = enumerator2.Current; yield return((Thing)p); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_0154: /*Error near IL_0155: Unexpected return in MoveNext()*/; }
public static IEnumerable <Thing> AllLaunchableThings(Map map) { HashSet <Thing> yieldedThings = new HashSet <Thing>(); foreach (Building_OrbitalTradeBeacon item in Building_OrbitalTradeBeacon.AllPowered(map)) { foreach (IntVec3 tradeableCell in item.TradeableCells) { List <Thing> thingList = tradeableCell.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing t = thingList[i]; if (TradeUtility.EverTradeable(t.def) && t.def.category == ThingCategory.Item && !yieldedThings.Contains(t) && TradeUtility.TradeableNow(t)) { yieldedThings.Add(t); yield return(t); /*Error: Unable to find new state assignment for yield return*/; } } } } yield break; IL_01f0: /*Error near IL_01f1: Unexpected return in MoveNext()*/; }
private static bool DisplayTradeStats(StatRequest req) { ThingDef thingDef; if ((thingDef = req.Def as ThingDef) == null) { return(false); } if (req.HasThing && EquipmentUtility.IsBiocoded(req.Thing)) { return(false); } if (thingDef.category == ThingCategory.Building && thingDef.Minifiable) { return(true); } if (TradeUtility.EverPlayerSellable(thingDef)) { return(true); } if (thingDef.tradeability.TraderCanSell() && (thingDef.category == ThingCategory.Item || thingDef.category == ThingCategory.Pawn)) { return(true); } return(false); }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { IEnumerable <Thing> items = from x in pawn.Map.listerThings.AllThings where x.def.category == ThingCategory.Item && TradeUtility.PlayerSellableNow(x) && !x.Position.Fogged(x.Map) && (((_003CColonyThingsWillingToBuy_003Ec__Iterator1) /*Error near IL_0042: stateMachine*/)._0024this.pawn.Map.areaManager.Home[x.Position] || x.IsInAnyStorage()) && ((_003CColonyThingsWillingToBuy_003Ec__Iterator1) /*Error near IL_0042: stateMachine*/)._0024this.ReachableForTrade(x) select x; using (IEnumerator <Thing> enumerator = items.GetEnumerator()) { if (enumerator.MoveNext()) { Thing t = enumerator.Current; yield return(t); /*Error: Unable to find new state assignment for yield return*/; } } if (pawn.GetLord() != null) { using (IEnumerator <Pawn> enumerator2 = (from x in TradeUtility.AllSellableColonyPawns(pawn.Map) where !x.Downed && ((_003CColonyThingsWillingToBuy_003Ec__Iterator1) /*Error near IL_011d: stateMachine*/)._0024this.ReachableForTrade(x) select x).GetEnumerator()) { if (enumerator2.MoveNext()) { Pawn p = enumerator2.Current; yield return((Thing)p); /*Error: Unable to find new state assignment for yield return*/; } } } yield break; IL_01b8: /*Error near IL_01b9: Unexpected return in MoveNext()*/; }
private void InitPriceDataIfNeeded() { if (!(pricePlayerBuy > 0f)) { if (IsCurrency) { pricePlayerBuy = BaseMarketValue; pricePlayerSell = BaseMarketValue; } else { priceFactorBuy_TraderPriceType = PriceTypeFor(TradeAction.PlayerBuys).PriceMultiplier(); priceFactorSell_TraderPriceType = PriceTypeFor(TradeAction.PlayerSells).PriceMultiplier(); priceGain_PlayerNegotiator = TradeSession.playerNegotiator.GetStatValue(StatDefOf.TradePriceImprovement); priceGain_Settlement = TradeSession.trader.TradePriceImprovementOffsetForPlayer; priceFactorSell_ItemSellPriceFactor = AnyThing.GetStatValue(StatDefOf.SellPriceFactor); pricePlayerBuy = TradeUtility.GetPricePlayerBuy(AnyThing, priceFactorBuy_TraderPriceType, priceGain_PlayerNegotiator, priceGain_Settlement); pricePlayerSell = TradeUtility.GetPricePlayerSell(AnyThing, priceFactorSell_TraderPriceType, priceGain_PlayerNegotiator, priceGain_Settlement); if (pricePlayerSell >= pricePlayerBuy) { Log.ErrorOnce("Trying to put player-sells price above player-buys price for " + AnyThing, 65387); pricePlayerSell = pricePlayerBuy; } } } }
private void AddAllTradeables() { foreach (Thing item in TradeSession.trader.ColonyThingsWillingToBuy(TradeSession.playerNegotiator)) { if (TradeUtility.PlayerSellableNow(item)) { if (!TradeSession.playerNegotiator.IsWorldPawn() && !InSellablePosition(item, out string reason)) { if (reason != null && !cannotSellReasons.Contains(reason)) { cannotSellReasons.Add(reason); } } else { AddToTradeables(item, Transactor.Colony); } } } if (!TradeSession.giftMode) { foreach (Thing good in TradeSession.trader.Goods) { AddToTradeables(good, Transactor.Trader); } } if (!TradeSession.giftMode && tradeables.Find((Tradeable x) => x.IsCurrency) == null) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Silver); thing.stackCount = 0; AddToTradeables(thing, Transactor.Trader); } }
public static Map PlayerHomeMapWithMostLaunchableSilver() { return((from x in Find.Maps where x.IsPlayerHome select x).MaxBy((Map x) => (from t in TradeUtility.AllLaunchableThings(x) where t.def == ThingDefOf.Silver select t).Sum((Thing t) => t.stackCount))); }
protected override bool TryExecuteWorker(IncidentParms parms) { Faction faction = Find.FactionManager.RandomAlliedFaction(false, false, false, TechLevel.Undefined); if (faction == null) { return(false); } int tile; if (!TileFinder.TryFindNewSiteTile(out tile, 8, 30, false, true, -1)) { return(false); } SitePartDef sitePart; Faction siteFaction; if (!SiteMakerHelper.TryFindSiteParams_SingleSitePart(SiteCoreDefOf.ItemStash, (!Rand.Chance(0.15f)) ? IncidentWorker_QuestItemStash.ItemStashQuestThreatTag : null, out sitePart, out siteFaction, null, true, null)) { return(false); } int randomInRange = IncidentWorker_QuestItemStash.TimeoutDaysRange.RandomInRange; List <Thing> list = this.GenerateItems(siteFaction); bool sitePartsKnown = Rand.Chance(0.5f); int num = 0; if (Rand.Chance(this.FeeDemandChance(faction))) { num = IncidentWorker_QuestItemStash.FeeRange.RandomInRange; } string letterText = this.GetLetterText(faction, list, randomInRange, sitePart, sitePartsKnown, num); if (num > 0) { Map map = TradeUtility.PlayerHomeMapWithMostLaunchableSilver(); ChoiceLetter_ItemStashFeeDemand choiceLetter_ItemStashFeeDemand = (ChoiceLetter_ItemStashFeeDemand)LetterMaker.MakeLetter(this.def.letterLabel, letterText, LetterDefOf.ItemStashFeeDemand); choiceLetter_ItemStashFeeDemand.title = "ItemStashQuestTitle".Translate(); choiceLetter_ItemStashFeeDemand.radioMode = true; choiceLetter_ItemStashFeeDemand.map = map; choiceLetter_ItemStashFeeDemand.fee = num; choiceLetter_ItemStashFeeDemand.siteDaysTimeout = randomInRange; choiceLetter_ItemStashFeeDemand.items.TryAddRangeOrTransfer(list, false, false); choiceLetter_ItemStashFeeDemand.siteFaction = siteFaction; choiceLetter_ItemStashFeeDemand.sitePart = sitePart; choiceLetter_ItemStashFeeDemand.alliedFaction = faction; choiceLetter_ItemStashFeeDemand.sitePartsKnown = sitePartsKnown; choiceLetter_ItemStashFeeDemand.StartTimeout(60000); Find.LetterStack.ReceiveLetter(choiceLetter_ItemStashFeeDemand, null); } else { Site o = IncidentWorker_QuestItemStash.CreateSite(tile, sitePart, randomInRange, siteFaction, list, sitePartsKnown); Find.LetterStack.ReceiveLetter(this.def.letterLabel, letterText, this.def.letterDef, o, null); } return(true); }
public override bool ShouldShowFor(BuildableDef def) { ThingDef thingDef = def as ThingDef; if (thingDef == null) { return(false); } return(TradeUtility.EverTradeable(thingDef) || thingDef.category == ThingCategory.Building); }
private static DiaOption RequestTraderOption(Map map, int silverCost) { string text = "RequestTrader".Translate(silverCost.ToString()); if (FactionDialogMaker.AmountSendableSilver(map) < silverCost) { DiaOption diaOption = new DiaOption(text); diaOption.Disable("NeedSilverLaunchable".Translate(silverCost)); return(diaOption); } if (!FactionDialogMaker.faction.def.allowedArrivalTemperatureRange.ExpandedBy(-4f).Includes(map.mapTemperature.SeasonalTemp)) { DiaOption diaOption2 = new DiaOption(text); diaOption2.Disable("BadTemperature".Translate()); return(diaOption2); } int num = FactionDialogMaker.faction.lastTraderRequestTick + 240000 - Find.TickManager.TicksGame; if (num > 0) { DiaOption diaOption3 = new DiaOption(text); diaOption3.Disable("WaitTime".Translate(num.ToStringTicksToPeriod(true, false, true))); return(diaOption3); } DiaOption diaOption4 = new DiaOption(text); DiaNode diaNode = new DiaNode("TraderSent".Translate(FactionDialogMaker.faction.leader.LabelIndefinite()).CapitalizeFirst()); diaNode.options.Add(FactionDialogMaker.OKToRoot()); DiaNode diaNode2 = new DiaNode("ChooseTraderKind".Translate(FactionDialogMaker.faction.leader.LabelIndefinite())); foreach (TraderKindDef caravanTraderKind in FactionDialogMaker.faction.def.caravanTraderKinds) { TraderKindDef localTk = caravanTraderKind; DiaOption diaOption5 = new DiaOption(localTk.LabelCap); diaOption5.action = delegate { IncidentParms incidentParms = new IncidentParms(); incidentParms.target = map; incidentParms.faction = FactionDialogMaker.faction; incidentParms.traderKind = localTk; incidentParms.forced = true; Find.Storyteller.incidentQueue.Add(IncidentDefOf.TraderCaravanArrival, Find.TickManager.TicksGame + 120000, incidentParms); FactionDialogMaker.faction.lastTraderRequestTick = Find.TickManager.TicksGame; TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, silverCost, map, null); }; diaOption5.link = diaNode; diaNode2.options.Add(diaOption5); } DiaOption diaOption6 = new DiaOption("GoBack".Translate()); diaOption6.linkLateBind = FactionDialogMaker.ResetToRoot(); diaNode2.options.Add(diaOption6); diaOption4.link = diaNode2; return(diaOption4); }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { foreach (Thing item in TradeUtility.AllLaunchableThingsForTrade(base.Map, this)) { yield return(item); } foreach (Pawn item2 in TradeUtility.AllSellableColonyPawns(base.Map)) { yield return(item2); } }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { foreach (Thing t in TradeUtility.AllLaunchableThings(base.Map)) { yield return(t); } foreach (Pawn p in TradeUtility.AllSellableColonyPawns(base.Map)) { yield return(p); } }
public void GiveSoldThingToPlayer(Thing toGive, int countToGive, Pawn playerNegotiator) { Thing thing = toGive.SplitOff(countToGive); thing.PreTraded(TradeAction.PlayerBuys, playerNegotiator, this); Pawn pawn = thing as Pawn; if (pawn != null) { this.soldPrisoners.Remove(pawn); } TradeUtility.SpawnDropPod(DropCellFinder.TradeDropSpot(base.Map), base.Map, thing); }
private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator) { TaggedString taggedString = "RequestAICoreInformation".Translate(ThingDefOf.AIPersonaCore.label, 1500.ToString()); if (faction.PlayerGoodwill < 40) { DiaOption diaOption = new DiaOption(taggedString); diaOption.Disable("NeedGoodwill".Translate(40.ToString("F0"))); return(diaOption); } bool num = PlayerItemAccessibilityUtility.ItemStashHas(ThingDefOf.AIPersonaCore); Slate slate = new Slate(); slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(Find.World)); slate.Set("asker", faction.leader); slate.Set("itemStashSingleThing", ThingDefOf.AIPersonaCore); bool flag = QuestScriptDefOf.OpportunitySite_ItemStash.CanRun(slate); if (num || !flag) { DiaOption diaOption2 = new DiaOption(taggedString); diaOption2.Disable("NoKnownAICore".Translate(1500)); return(diaOption2); } if (AmountSendableSilver(map) < 1500) { DiaOption diaOption3 = new DiaOption(taggedString); diaOption3.Disable("NeedSilverLaunchable".Translate(1500)); return(diaOption3); } return(new DiaOption(taggedString) { action = delegate { Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(QuestScriptDefOf.OpportunitySite_ItemStash, slate); if (!quest.hidden) { QuestUtility.SendLetterQuestAvailable(quest); } TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 1500, map, null); Current.Game.GetComponent <GameComponent_OnetimeNotification>().sendAICoreRequestReminder = false; }, link = new DiaNode("RequestAICoreInformationResult".Translate(faction.leader).CapitalizeFirst()) { options = { OKToRoot(faction, negotiator) } } }); }
private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator) { string text = "RequestAICoreInformation".Translate(ThingDefOf.AIPersonaCore.label, 1500.ToString()); if (faction.PlayerGoodwill < 40) { DiaOption diaOption = new DiaOption(text); diaOption.Disable("NeedGoodwill".Translate(40.ToString("F0"))); return(diaOption); } IncidentDef def = IncidentDefOf.Quest_ItemStashAICore; bool flag = PlayerItemAccessibilityUtility.ItemStashHas(ThingDefOf.AIPersonaCore); IncidentParms coreIncidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, Find.World); coreIncidentParms.faction = faction; bool flag2 = def.Worker.CanFireNow(coreIncidentParms, false); if (flag || !flag2) { DiaOption diaOption2 = new DiaOption(text); diaOption2.Disable("NoKnownAICore".Translate(1500)); return(diaOption2); } if (FactionDialogMaker.AmountSendableSilver(map) < 1500) { DiaOption diaOption3 = new DiaOption(text); diaOption3.Disable("NeedSilverLaunchable".Translate(1500)); return(diaOption3); } DiaOption diaOption4 = new DiaOption(text); diaOption4.action = delegate { if (def.Worker.TryExecute(coreIncidentParms)) { TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 1500, map, null); } Current.Game.GetComponent <GameComponent_OnetimeNotification>().sendAICoreRequestReminder = false; }; string text2 = "RequestAICoreInformationResult".Translate(faction.leader).CapitalizeFirst(); diaOption4.link = new DiaNode(text2) { options = { FactionDialogMaker.OKToRoot(faction, negotiator) } }; return(diaOption4); }
public static bool PlayerSellableNow(Thing t) { t = t.GetInnerIfMinified(); if (!TradeUtility.EverPlayerSellable(t.def)) { return(false); } if (t.IsNotFresh()) { return(false); } Apparel apparel = t as Apparel; return(apparel == null || !apparel.WornByCorpse); }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { 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)); foreach (Thing item in enumerable) { yield return(item); } if (pawn.GetLord() != null) { foreach (Pawn item2 in from x in TradeUtility.AllSellableColonyPawns(pawn.Map) where !x.Downed && ReachableForTrade(x) select x) { yield return(item2); } } }
public static IEnumerable <Thing> AllLaunchableThings(Map map) { HashSet <Thing> yieldedThings = new HashSet <Thing>(); foreach (Building_OrbitalTradeBeacon beacon in Building_OrbitalTradeBeacon.AllPowered(map)) { foreach (IntVec3 c in beacon.TradeableCells) { List <Thing> thingList = c.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing t = thingList[i]; if (TradeUtility.EverTradeable(t.def) && t.def.category == ThingCategory.Item && !yieldedThings.Contains(t) && TradeUtility.TradeableNow(t)) { yieldedThings.Add(t); yield return(t); } } } } }
public override bool ShouldShowFor(StatRequest req) { ThingDef thingDef = req.Def as ThingDef; if (thingDef == null) { return(false); } if (thingDef.category == ThingCategory.Building) { return(true); } if (TradeUtility.EverPlayerSellable(thingDef)) { return(true); } if (thingDef.tradeability.TraderCanSell() && (thingDef.category == ThingCategory.Item || thingDef.category == ThingCategory.Pawn)) { return(true); } return(false); }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { IEnumerable <Thing> items = from x in this.pawn.Map.listerThings.AllThings where TradeUtility.EverTradeable(x.def) && x.def.category == ThingCategory.Item && !x.Position.Fogged(x.Map) && (this.$this.pawn.Map.areaManager.Home[x.Position] || x.IsInAnyStorage()) && TradeUtility.TradeableNow(x) && this.$this.ReachableForTrade(x) select x; foreach (Thing t in items) { yield return(t); } bool hasLord = this.pawn.GetLord() != null; if (hasLord) { foreach (Pawn p in from x in TradeUtility.AllSellableColonyPawns(this.pawn.Map) where !x.Downed && this.$this.ReachableForTrade(x) select x) { yield return(p); } } }
private static DiaOption OfferGiftOption(Map map) { if (FactionDialogMaker.AmountSendableSilver(map) < 300) { DiaOption diaOption = new DiaOption("OfferGift".Translate()); diaOption.Disable("NeedSilverLaunchable".Translate(new object[] { 300 })); return(diaOption); } float goodwillDelta = 12f * FactionDialogMaker.negotiator.GetStatValue(StatDefOf.DiplomacyPower, true); DiaOption diaOption2 = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(new object[] { 300, goodwillDelta.ToString("#####0") }) + ")"); diaOption2.action = delegate { TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 300, map, null); FactionDialogMaker.faction.AffectGoodwillWith(Faction.OfPlayer, goodwillDelta); }; string text = "SilverGiftSent".Translate(new object[] { FactionDialogMaker.faction.leader.LabelIndefinite(), Mathf.RoundToInt(goodwillDelta) }).CapitalizeFirst(); diaOption2.link = new DiaNode(text) { options = { FactionDialogMaker.OKToRoot() } }; return(diaOption2); }
public void GiveSoldThingToTrader(Thing toGive, int countToGive, Pawn playerNegotiator) { Thing thing = toGive.SplitOff(countToGive); thing.PreTraded(TradeAction.PlayerSells, playerNegotiator, this); Thing thing2 = TradeUtility.ThingFromStockToMergeWith(this, thing); if (thing2 != null) { if (!thing2.TryAbsorbStack(thing, respectStackLimit: false)) { thing.Destroy(); } return; } Pawn pawn = thing as Pawn; if (pawn != null && pawn.RaceProps.Humanlike) { soldPrisoners.Add(pawn); } things.TryAdd(thing, canMergeWithExistingStacks: false); }
private void AddAllTradeables() { foreach (Thing t in TradeSession.trader.ColonyThingsWillingToBuy(TradeSession.playerNegotiator)) { if (TradeUtility.PlayerSellableNow(t)) { string text; if (!TradeSession.playerNegotiator.IsWorldPawn() && !this.InSellablePosition(t, out text)) { if (text != null && !this.cannotSellReasons.Contains(text)) { this.cannotSellReasons.Add(text); } } else { this.AddToTradeables(t, Transactor.Colony); } } } if (!TradeSession.giftMode) { foreach (Thing t2 in TradeSession.trader.Goods) { this.AddToTradeables(t2, 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); } } }
private void InitPriceDataIfNeeded() { if (pricePlayerBuy > 0f) { return; } if (IsCurrency) { pricePlayerBuy = BaseMarketValue; pricePlayerSell = BaseMarketValue; return; } priceFactorBuy_TraderPriceType = PriceTypeFor(TradeAction.PlayerBuys).PriceMultiplier(); priceFactorSell_TraderPriceType = PriceTypeFor(TradeAction.PlayerSells).PriceMultiplier(); priceGain_PlayerNegotiator = TradeSession.playerNegotiator.GetStatValue(StatDefOf.TradePriceImprovement); priceGain_Settlement = TradeSession.trader.TradePriceImprovementOffsetForPlayer; priceFactorSell_ItemSellPriceFactor = AnyThing.GetStatValue(StatDefOf.SellPriceFactor); pricePlayerBuy = TradeUtility.GetPricePlayerBuy(AnyThing, priceFactorBuy_TraderPriceType, priceGain_PlayerNegotiator, priceGain_Settlement); pricePlayerSell = TradeUtility.GetPricePlayerSell(AnyThing, priceFactorSell_TraderPriceType, priceGain_PlayerNegotiator, priceGain_Settlement, TradeSession.TradeCurrency); if (pricePlayerSell >= pricePlayerBuy) { pricePlayerSell = pricePlayerBuy; } }
public void GiveSoldThingToTrader(Thing toGive, int countToGive, Pawn playerNegotiator) { Thing thing = toGive.SplitOff(countToGive); thing.PreTraded(TradeAction.PlayerSells, playerNegotiator, this); Thing thing2 = TradeUtility.ThingFromStockToMergeWith(this, thing); if (thing2 != null) { if (!thing2.TryAbsorbStack(thing, false)) { thing.Destroy(DestroyMode.Vanish); } } else { Pawn pawn = thing as Pawn; if (pawn != null && pawn.RaceProps.Humanlike) { this.soldPrisoners.Add(pawn); } this.things.TryAdd(thing, false); } }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: if (base.ArchivedOnly) { this.$current = base.Option_Close; if (!this.$disposing) { this.$PC = 1; } return(true); } accept = new DiaOption("RansomDemand_Accept".Translate()); accept.action = delegate() { this.faction.kidnapped.RemoveKidnappedPawn(this.kidnapped); Find.WorldPawns.RemovePawn(this.kidnapped); IntVec3 intVec; if (this.faction.def.techLevel < TechLevel.Industrial) { if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.Standable(this.map) && this.map.reachability.CanReachColony(c), this.map, CellFinder.EdgeRoadChance_Friendly, out intVec) && !CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.Standable(this.map), this.map, CellFinder.EdgeRoadChance_Friendly, out intVec)) { Log.Warning("Could not find any edge cell.", false); intVec = DropCellFinder.TradeDropSpot(this.map); } GenSpawn.Spawn(this.kidnapped, intVec, this.map, WipeMode.Vanish); } else { intVec = DropCellFinder.TradeDropSpot(this.map); TradeUtility.SpawnDropPod(intVec, this.map, this.kidnapped); } CameraJumper.TryJump(intVec, this.map); TradeUtility.LaunchSilver(this.map, this.fee); Find.LetterStack.RemoveLetter(this); }; accept.resolveTree = true; if (!TradeUtility.ColonyHasEnoughSilver(this.map, this.fee)) { accept.Disable("NeedSilverLaunchable".Translate(new object[] { this.fee.ToString() })); } this.$current = accept; if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: this.$current = base.Option_Reject; if (!this.$disposing) { this.$PC = 3; } return(true); case 3u: this.$current = base.Option_Postpone; if (!this.$disposing) { this.$PC = 4; } return(true); case 4u: this.$PC = -1; break; } return(false); }
private static int AmountSendableSilver(Map map) { return((from t in TradeUtility.AllLaunchableThingsForTrade(map) where t.def == ThingDefOf.Silver select t).Sum((Thing t) => t.stackCount)); }
private void CalculateSellableItems(TraderKindDef trader) { sellableItems.Clear(); cachedSellableItemsByCategory.Clear(); cachedSellablePawns = null; List <ThingDef> allDefsListForReading = DefDatabase <ThingDef> .AllDefsListForReading; for (int i = 0; i < allDefsListForReading.Count; i++) { if (allDefsListForReading[i].PlayerAcquirable && !allDefsListForReading[i].IsCorpse && !typeof(MinifiedThing).IsAssignableFrom(allDefsListForReading[i].thingClass) && trader.WillTrade(allDefsListForReading[i]) && TradeUtility.EverPlayerSellable(allDefsListForReading[i])) { sellableItems.Add(allDefsListForReading[i]); } } sellableItems.SortBy((ThingDef x) => x.label); }