private void CacheTradeables() { this.cachedCurrencyTradeable = (from x in TradeSession.deal.AllTradeables where x.IsCurrency select x).FirstOrDefault <Tradeable>(); this.cachedTradeables = (from tr in TradeSession.deal.AllTradeables where !tr.IsCurrency orderby(!tr.TraderWillTrade) ? -1 : 0 descending select tr).ThenBy((Tradeable tr) => tr, this.sorter1.Comparer).ThenBy((Tradeable tr) => tr, this.sorter2.Comparer).ThenBy(new Func <Tradeable, float>(TransferableUIUtility.DefaultListOrderPriority)).ThenBy((Tradeable tr) => tr.ThingDef.label).ThenBy(delegate(Tradeable tr) { QualityCategory result; if (tr.AnyThing.TryGetQuality(out result)) { return((int)result); } return(-1); }).ThenBy((Tradeable tr) => tr.AnyThing.HitPoints).ToList <Tradeable>(); }
public void UpdateCurrencyCount() { if (this.SilverTradeable == null || TradeSession.giftMode) { return; } float num = 0f; for (int i = 0; i < this.tradeables.Count; i++) { Tradeable tradeable = this.tradeables[i]; if (!tradeable.IsCurrency) { num += tradeable.CurTotalSilverCostForSource; } } this.SilverTradeable.ForceToSource(-Mathf.RoundToInt(num)); }
public void UpdateCurrencyCount() { if (CurrencyTradeable == null || TradeSession.giftMode) { return; } float num = 0f; for (int i = 0; i < tradeables.Count; i++) { Tradeable tradeable = tradeables[i]; if (!tradeable.IsCurrency) { num += tradeable.CurTotalCurrencyCostForSource; } } CurrencyTradeable.ForceToSource(-CurrencyTradeable.CostToInt(num)); }
private void AddToTradeables(Thing t, Transactor trans) { Tradeable tradeable = TransferableUtility.TradeableMatching(t, this.tradeables); if (tradeable == null) { Pawn pawn = t as Pawn; if (pawn != null) { tradeable = new Tradeable_Pawn(); } else { tradeable = new Tradeable(); } this.tradeables.Add(tradeable); } tradeable.AddThing(t, trans); }
public static Tradeable TradeableMatching(Thing thing, List <Tradeable> tradeables) { if (thing == null || tradeables == null) { return(null); } for (int i = 0; i < tradeables.Count; i++) { Tradeable tradeable = tradeables[i]; if (tradeable.HasAnyThing) { TransferAsOneMode mode = (!tradeable.TraderWillTrade) ? TransferAsOneMode.InactiveTradeable : TransferAsOneMode.Normal; if (TransferAsOne(thing, tradeable.AnyThing, mode)) { return(tradeable); } } } return(null); }
private void CacheTradeables() { cachedCurrencyTradeable = (from x in TradeSession.deal.AllTradeables where x.IsCurrency select x).FirstOrDefault(); cachedTradeables = (from tr in TradeSession.deal.AllTradeables where !tr.IsCurrency orderby(!tr.TraderWillTrade) ? (-1) : 0 descending select tr).ThenBy((Tradeable tr) => tr, sorter1.Comparer).ThenBy((Tradeable tr) => tr, sorter2.Comparer).ThenBy(TransferableUIUtility.DefaultListOrderPriority) .ThenBy((Tradeable tr) => tr.ThingDef.label) .ThenBy(delegate(Tradeable tr) { if (tr.AnyThing.TryGetQuality(out QualityCategory qc)) { return((int)qc); } return(-1); }) .ThenBy((Tradeable tr) => tr.AnyThing.HitPoints) .ToList(); }
private static void DrawPrice(Rect rect, Tradeable trad, TradeAction action) { if (!trad.IsCurrency && trad.TraderWillTrade) { rect = rect.Rounded(); if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } TooltipHandler.TipRegion(rect, new TipSignal(() => trad.GetPriceTooltip(action), trad.GetHashCode() * 297)); if (action == TradeAction.PlayerBuys) { switch (trad.PriceTypeFor(action)) { case PriceType.VeryCheap: GUI.color = new Color(0f, 1f, 0f); break; case PriceType.Cheap: GUI.color = new Color(0.5f, 1f, 0.5f); break; case PriceType.Normal: GUI.color = Color.white; break; case PriceType.Expensive: GUI.color = new Color(1f, 0.5f, 0.5f); break; case PriceType.Exorbitant: GUI.color = new Color(1f, 0f, 0f); break; } } else { switch (trad.PriceTypeFor(action)) { case PriceType.VeryCheap: GUI.color = new Color(1f, 0f, 0f); break; case PriceType.Cheap: GUI.color = new Color(1f, 0.5f, 0.5f); break; case PriceType.Normal: GUI.color = Color.white; break; case PriceType.Expensive: GUI.color = new Color(0.5f, 1f, 0.5f); break; case PriceType.Exorbitant: GUI.color = new Color(0f, 1f, 0f); break; } } float priceFor = trad.GetPriceFor(action); string label = priceFor.ToStringMoney(); Rect rect2 = new Rect(rect); rect2.xMax -= 5f; rect2.xMin += 5f; if (Text.Anchor == TextAnchor.MiddleLeft) { rect2.xMax += 300f; } if (Text.Anchor == TextAnchor.MiddleRight) { rect2.xMin -= 300f; } Widgets.Label(rect2, label); GUI.color = Color.white; } }
private static Transferable <CacheTradeables> m__4(Tradeable tr) { return(tr); }
private static bool <AddAllTradeables> m__0(Tradeable x) { return(x.IsCurrency); }
public static void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index % 2 == 1) { GUI.DrawTexture(rect, TradeUI.TradeAlternativeBGTex); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0) { Rect rect2 = new Rect((float)(width - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Text.Anchor = TextAnchor.MiddleRight; Rect rect3 = rect2; rect3.xMin += 5f; rect3.xMax -= 5f; Widgets.Label(rect3, num.ToStringCached()); TooltipHandler.TipRegion(rect2, "TraderCount".Translate()); Rect rect4 = new Rect((float)(rect2.x - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleRight; TradeUI.DrawPrice(rect4, trad, TradeAction.PlayerBuys); } width = (float)(width - 175.0); Rect rect5 = new Rect((float)(width - 240.0), 0f, 240f, rect.height); if (trad.TraderWillTrade) { bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1.0 && trad.IsCurrency; TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader), flash, null); } else { TradeUI.DrawWillNotTradeIndication(rect, trad); } width = (float)(width - 240.0); int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect6 = new Rect((float)(width - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; TradeUI.DrawPrice(rect6, trad, TradeAction.PlayerSells); Rect rect7 = new Rect((float)(rect6.x - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, num2.ToStringCached()); TooltipHandler.TipRegion(rect7, "ColonyCount".Translate()); } width = (float)(width - 175.0); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, (!trad.TraderWillTrade) ? TradeUI.NoTradeColor : Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private static int <CacheTradeables> m__8(Tradeable tr) { return(tr.AnyThing.HitPoints); }
public static void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0 && trad.IsThing) { Rect rect2 = new Rect(width - 75f, 0f, 75f, rect.height); if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Text.Anchor = TextAnchor.MiddleRight; Rect rect3 = rect2; rect3.xMin += 5f; rect3.xMax -= 5f; Widgets.Label(rect3, num.ToStringCached()); TooltipHandler.TipRegionByKey(rect2, "TraderCount"); Rect rect4 = new Rect(rect2.x - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleRight; DrawPrice(rect4, trad, TradeAction.PlayerBuys); } width -= 175f; Rect rect5 = new Rect(width - 240f, 0f, 240f, rect.height); if (trad.TraderWillTrade) { bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1f && trad.IsCurrency; TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, trad.GetMinimumToTransfer(), trad.GetMaximumToTransfer(), flash); } else { DrawWillNotTradeIndication(rect5, trad); } width -= 240f; int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect6 = new Rect(width - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawPrice(rect6, trad, TradeAction.PlayerSells); Rect rect7 = new Rect(rect6.x - 75f, 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, num2.ToStringCached()); TooltipHandler.TipRegionByKey(rect7, "ColonyCount"); } width -= 175f; TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, trad.TraderWillTrade ? Color.white : NoTradeColor); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private static string <CacheTradeables> m__6(Tradeable tr) { return(tr.ThingDef.label); }
private static float <CacheTradeables> m__5(Tradeable tr) { return(TransferableUIUtility.DefaultListOrderPriority(tr)); }
private static bool <CacheTradeables> m__0(Tradeable x) { return(x.IsCurrency); }
private static int <CacheTradeables> m__2(Tradeable tr) { return((!tr.TraderWillTrade) ? -1 : 0); }
private static bool <CacheTradeables> m__1(Tradeable tr) { return(!tr.IsCurrency); }