Exemplo n.º 1
0
        public static int Compare(ThingDef lhsTh, ThingDef rhsTh)
        {
            if (lhsTh.category != rhsTh.category)
            {
                return(lhsTh.category.CompareTo(rhsTh.category));
            }
            float num  = TransferableUIUtility.DefaultListOrderPriority(lhsTh);
            float num2 = TransferableUIUtility.DefaultListOrderPriority(rhsTh);

            if (num != num2)
            {
                return(num.CompareTo(num2));
            }
            int num3 = 0;

            if (!lhsTh.thingCategories.NullOrEmpty <ThingCategoryDef>())
            {
                num3 = (int)lhsTh.thingCategories[0].index;
            }
            int value = 0;

            if (!rhsTh.thingCategories.NullOrEmpty <ThingCategoryDef>())
            {
                value = (int)rhsTh.thingCategories[0].index;
            }
            return(num3.CompareTo(value));
        }
 public static float DefaultListOrderPriority(Transferable transferable)
 {
     if (!transferable.HasAnyThing)
     {
         return(0f);
     }
     return(TransferableUIUtility.DefaultListOrderPriority(transferable.ThingDef));
 }
Exemplo n.º 3
0
        public static float DefaultListOrderPriority(Transferable transferable)
        {
            float result;

            if (!transferable.HasAnyThing)
            {
                result = 0f;
            }
            else
            {
                result = TransferableUIUtility.DefaultListOrderPriority(transferable.ThingDef);
            }
            return(result);
        }
 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());
     }
 }
Exemplo n.º 5
0
 private static float <CacheTradeables> m__5(Tradeable tr)
 {
     return(TransferableUIUtility.DefaultListOrderPriority(tr));
 }
Exemplo n.º 6
0
 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((Tradeable tr) => TransferableUIUtility.DefaultListOrderPriority(tr)).ThenBy((Tradeable tr) => tr.ThingDef.label).ThenBy(delegate(Tradeable tr)
     {
         QualityCategory qualityCategory;
         int result;
         if (tr.AnyThing.TryGetQuality(out qualityCategory))
         {
             result = (int)qualityCategory;
         }
         else
         {
             result = -1;
         }
         return(result);
     }).ThenBy((Tradeable tr) => tr.AnyThing.HitPoints).ToList <Tradeable>();
 }
Exemplo n.º 7
0
 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)
                                orderby(!tr.TraderWillTrade) ? (-1) : 0 descending
                                select tr).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((Tradeable tr) => tr.AnyThing.TryGetQuality(out var qc) ? ((int)qc) : (-1))
                               .ThenBy((Tradeable tr) => tr.AnyThing.HitPoints)
                               .ToList();
 }