public bool TryExecute(out bool actuallyTraded) { bool result; if (TradeSession.giftMode) { this.UpdateCurrencyCount(); this.LimitCurrencyCountToFunds(); int goodwillChange = FactionGiftUtility.GetGoodwillChange(this.tradeables, TradeSession.trader.Faction); FactionGiftUtility.GiveGift(this.tradeables, TradeSession.trader.Faction, TradeSession.playerNegotiator); actuallyTraded = ((float)goodwillChange > 0f); result = true; } else if (this.SilverTradeable == null || this.SilverTradeable.CountPostDealFor(Transactor.Colony) < 0) { Find.WindowStack.WindowOfType <Dialog_Trade>().FlashSilver(); Messages.Message("MessageColonyCannotAfford".Translate(), MessageTypeDefOf.RejectInput, false); actuallyTraded = false; result = false; } else { this.UpdateCurrencyCount(); this.LimitCurrencyCountToFunds(); actuallyTraded = false; float num = 0f; foreach (Tradeable tradeable in this.tradeables) { if (tradeable.ActionToDo != TradeAction.None) { actuallyTraded = true; } if (tradeable.ActionToDo == TradeAction.PlayerSells) { num += tradeable.CurTotalSilverCostForDestination; } tradeable.ResolveTrade(); } this.Reset(); if (TradeSession.trader.Faction != null) { TradeSession.trader.Faction.Notify_PlayerTraded(num, TradeSession.playerNegotiator); } Pawn pawn = TradeSession.trader as Pawn; if (pawn != null) { TaleRecorder.RecordTale(TaleDefOf.TradedWith, new object[] { TradeSession.playerNegotiator, pawn }); } TradeSession.playerNegotiator.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Trade); result = true; } return(result); }
public static bool CheckAndSignalRelevantHandlers(TransportPodsArrivalAction_GiveGift __instance, List <ActiveDropPodInfo> pods) { var settlement = Traverse.Create(__instance).Field("settlement").GetValue <Settlement>(); var unused = DesynchronizedMain.ArrivalActionAndSenderLinker.SafelyGetMapOfGivenAction(__instance); foreach (var activeDropPodInfo in pods) { foreach (var thing in activeDropPodInfo.innerContainer) { if (!(thing is Pawn)) { } } } FactionGiftUtility.GiveGift(pods, settlement); // Original method need not be called. return(false); }
public static bool CheckAndSignalRelevantHandlers(TransportPodsArrivalAction_GiveGift __instance, List <ActiveDropPodInfo> pods) { Settlement settlement = Traverse.Create(__instance).Field("settlement").GetValue <Settlement>(); Map mapOfSender = DesynchronizedMain.ArrivalActionAndSenderLinker.SafelyGetMapOfGivenAction(__instance); for (int i = 0; i < pods.Count; i++) { for (int j = 0; j < pods[i].innerContainer.Count; j++) { Pawn pawn = pods[i].innerContainer[j] as Pawn; if (pawn == null) { continue; } } } FactionGiftUtility.GiveGift(pods, settlement); // Original method need not be called. return(false); }