public static int Compare(ThingDef lhsTh, ThingDef rhsTh) { if (lhsTh.category != rhsTh.category) { return(lhsTh.category.CompareTo(rhsTh.category)); } var num = TransferableUIUtility.DefaultListOrderPriority(lhsTh); var num2 = TransferableUIUtility.DefaultListOrderPriority(rhsTh); if (num != num2) { return(num.CompareTo(num2)); } var num3 = 0; if (!lhsTh.thingCategories.NullOrEmpty()) { num3 = lhsTh.thingCategories[0].index; } var value = 0; if (!rhsTh.thingCategories.NullOrEmpty()) { value = rhsTh.thingCategories[0].index; } return(num3.CompareTo(value)); }
public virtual void Sort(TabComparer sort1, TabComparer sort2) { var itemsWithValue = items.Where(x => x.MarketValueAll >= 1f); if (sort1 is TabComparer_MarketValueAll && sort2 is TabComparer_None) { items = itemsWithValue .OrderByDescending(x => x, sort1) .ToList(); return; } // sort like trade window items = itemsWithValue .OrderBy(x => x, sort1) .ThenBy(x => x, sort2) .ThenBy(x => TransferableUIUtility.DefaultListOrderPriority(x.thing.def)) .ToList(); }
private void CacheItems() { CheckCreateSorters(); cachedItems.Clear(); List <Thing> list = CaravanInventoryUtility.AllInventoryItems(base.SelCaravan); int seed = 0; for (int i = 0; i < list.Count; i++) { TransferableImmutable transferableImmutable = TransferableUtility.TransferableMatching(list[i], cachedItems, TransferAsOneMode.Normal); if (transferableImmutable == null) { transferableImmutable = new TransferableImmutable(); cachedItems.Add(transferableImmutable); } transferableImmutable.things.Add(list[i]); seed = Gen.HashCombineInt(seed, list[i].GetHashCode()); } cachedItems = cachedItems.OrderBy((TransferableImmutable tr) => tr, sorter1.Comparer).ThenBy((TransferableImmutable tr) => tr, sorter2.Comparer).ThenBy((TransferableImmutable tr) => TransferableUIUtility.DefaultListOrderPriority(tr)) .ToList(); cachedItemsCount = list.Count; cachedItemsHash = seed; }
private static float <CacheItems> m__4(TransferableImmutable tr) { return(TransferableUIUtility.DefaultListOrderPriority(tr)); }
private void CacheTransferables() { transferablesCached = true; for (int i = 0; i < sections.Count; i++) { List <TransferableOneWay> cachedTransferables = sections[i].cachedTransferables; cachedTransferables.Clear(); cachedTransferables.AddRange(sections[i].transferables.OrderBy((TransferableOneWay tr) => tr, sorter1.Comparer).ThenBy((TransferableOneWay tr) => tr, sorter2.Comparer).ThenBy((TransferableOneWay tr) => TransferableUIUtility.DefaultListOrderPriority(tr)).ToList <TransferableOneWay>()); } }
private void CacheTradeables() { cachedCurrencyTradeable = TradeSession.deal.AllTradeables.FirstOrDefault((Tradeable x) => x.IsCurrency && (TradeSession.TradeCurrency != TradeCurrency.Favor || x.IsFavor)); cachedTradeables = (from tr in TradeSession.deal.AllTradeables where !tr.IsCurrency && (tr.TraderWillTrade || !TradeSession.trader.TraderKind.hideThingsNotWillingToTrade) select tr).OrderByDescending(delegate(Tradeable tr) { if (!tr.TraderWillTrade) { return(-1); } return(0); }).ThenBy((Tradeable tr) => tr, sorter1.Comparer).ThenBy((Tradeable tr) => tr, sorter2.Comparer).ThenBy((Tradeable tr) => TransferableUIUtility.DefaultListOrderPriority(tr)).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>(); }