Exemplo n.º 1
0
 internal static void DebugChosenList(Thing billGiver, List <ThingCount> p_chosen)
 {
     if (Prefs.DevMode && Controller.Settings.DebugMaster && Controller.Settings.DebugChosen)
     {
         var ignore = Controller.Settings.DebugIgnore;
         if (IsValidForComp(billGiver))
         {
             CompBestMix compBestMix = billGiver.TryGetComp <CompBestMix>();
             if ((compBestMix != null) && compBestMix.BMixDebug)
             {
                 if (p_chosen != null)
                 {
                     if (p_chosen.Count > 0)
                     {
                         Log.Message(billGiver.Label + ", " + "BestMix.Chosen".Translate() + ":", ignore);
                         foreach (ThingCount TC in p_chosen)
                         {
                             Thing thing = TC.Thing;
                             var   count = TC.Count;
                             Log.Message(thing.Label + " , " + count.ToString(), ignore);
                         }
                     }
                     else
                     {
                         Log.Message(billGiver.Label + ", " + "BestMix.NoChosen".Translate() + ":", ignore);
                     }
                 }
                 else
                 {
                     Log.Message(billGiver.Label + ", " + "BestMix.NullChosen".Translate() + ":", ignore);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 internal static void DebugFoundAll(Thing billGiver, bool foundAll)
 {
     if (Prefs.DevMode && Controller.Settings.DebugMaster && Controller.Settings.DebugFound)
     {
         var ignore = Controller.Settings.DebugIgnore;
         if (IsValidForComp(billGiver))
         {
             CompBestMix compBMix = billGiver.TryGetComp <CompBestMix>();
             if (compBMix != null)
             {
                 if (compBMix.BMixDebug)
                 {
                     var debugMsg = billGiver.Label;
                     if (foundAll)
                     {
                         debugMsg += ", " + "BestMix.FoundAll".Translate();
                     }
                     else
                     {
                         debugMsg += ", " + "BestMix.NotFoundAll".Translate();
                     }
                     Log.Message(debugMsg, ignore);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public static bool BMixFinishedStatus(bool foundAll, Thing billGiver, Bill bill)
 {
     if (foundAll)
     {
         if (billGiver is Pawn)
         {
             return(true);
         }
         if (IsValidForComp(billGiver))
         {
             //if (billGiver.TryGetComp<CompBestMix>().CurMode == "DIS")
             CompBestMix CBM = billGiver.TryGetComp <CompBestMix>();
             if (CBM != null)
             {
                 if (BMBillUtility.UseBMixMode(CBM, billGiver, bill) == "DIS")
                 {
                     return(true);
                 }
             }
             return(false);
         }
         else
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
 // Debug
 internal static void BMixDebugList(List <Thing> list, Thing billGiver, IntVec3 rootCell, Bill bill)
 {
     if (Prefs.DevMode && Controller.Settings.DebugMaster && Controller.Settings.DebugSort)
     {
         var ignore = Controller.Settings.DebugIgnore;
         if (IsValidForComp(billGiver))
         {
             CompBestMix compBMix = billGiver.TryGetComp <CompBestMix>();
             if (compBMix != null)
             {
                 if (compBMix.BMixDebug)
                 {
                     if (list.Count > 0)
                     {
                         for (var i = 0; i < list.Count; i++)
                         {
                             Thing thing    = list[i];
                             var   debugMsg = MakeDebugString(i, thing, billGiver, rootCell, bill, BMBillUtility.UseBMixMode(compBMix, billGiver, bill));
                             Log.Message(debugMsg, ignore);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
        public static string GetBillBMMode(Thing billGiver, Bill bill)
        {
            string mode = "NON";

            if (billGiver != null && (!(billGiver is Pawn p)))
            {
                CompBestMix CBM = billGiver.TryGetComp <CompBestMix>();
                if (CBM != null)
                {
                    string billID = bill?.GetUniqueLoadID();
                    if (billID != null)
                    {
                        if (CBM?.BillBMModes != null)
                        {
                            List <string> BillModes = CBM.BillBMModes;
                            if (BillModes.Count > 0)
                            {
                                foreach (string BillMode in BillModes)
                                {
                                    if (BillValuePart(BillMode) == billID)
                                    {
                                        mode = ModeValuePart(BillMode);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(mode);
        }
Exemplo n.º 6
0
 // Debug
 internal static void BMixDebugList(List <Thing> list, Thing billGiver, IntVec3 rootCell)
 {
     if ((Prefs.DevMode) && (Controller.Settings.DebugMaster) && (Controller.Settings.DebugSort))
     {
         bool ignore = (Controller.Settings.DebugIgnore);
         if (IsValidForComp(billGiver))
         {
             CompBestMix compBMix = billGiver.TryGetComp <CompBestMix>();
             if (compBMix != null)
             {
                 if (compBMix.BMixDebug)
                 {
                     if (list.Count > 0)
                     {
                         for (int i = 0; i < list.Count; i++)
                         {
                             Thing  thing    = list[i];
                             string debugMsg = MakeDebugString(i, thing, billGiver, rootCell, compBMix.CurMode);
                             Log.Message(debugMsg, ignore);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
        public static void SetBMixBillMode(CompBestMix CBM, Bill bill, string mode, bool set)
        {
            if ((CBM != null) && (bill != null))
            {
                string        billID  = bill.GetUniqueLoadID();
                List <string> newlist = new List <string>();
                if (CBM?.BillBMModes != null)
                {
                    List <string> current = CBM?.BillBMModes;
                    if (current.Count > 0)
                    {
                        foreach (string BillBMMode in current)
                        {
                            if (BillValuePart(BillBMMode) != billID)
                            {
                                newlist.AddDistinct(BillBMMode);
                            }
                        }
                    }
                    current.Clear();
                }
                newlist.AddDistinct(NewBillBMMode(billID, mode));

                CBM.BillBMModes = newlist;
                //newlist.Clear();
            }
        }
Exemplo n.º 8
0
        public static string UseBMixMode(CompBestMix compBM, Thing billGiver, Bill bill)
        {
            string mode = "DIS";

            if (compBM != null)
            {
                mode = compBM.CurMode; // defaults to bench Gizmo
                if (compBM?.BillBMModes != null)
                {
                    List <string> BillModeListing = compBM?.BillBMModes;
                    if (BillModeListing.Count > 0)
                    {
                        foreach (string BillMode in BillModeListing)
                        {
                            if (BillValuePart(BillMode) == bill.GetUniqueLoadID())
                            {
                                mode = ModeValuePart(BillMode);
                                if (mode == "NON")
                                {
                                    mode = compBM.CurMode;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            return(mode);
        }
Exemplo n.º 9
0
        public static void DoBillModeSelMenu(CompBestMix CBM, Bill bill)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            string text = "BestMix.DoNothing".Translate();

            list.Add(new FloatMenuOption(text, delegate
            {
                SetBMixBillMode(CBM, bill, "NON", true);
            },
                                         MenuOptionPriority.Default, null, null, 29f, null));

            foreach (string mode in BestMixUtility.BMixModes())
            {
                text = BestMixUtility.GetBMixModeDisplay(mode);
                list.Add(new FloatMenuOption(text, delegate
                {
                    SetBMixBillMode(CBM, bill, mode, true);
                },
                                             MenuOptionPriority.Default, null, null, 29f, null));
            }
            List <FloatMenuOption> sortedlist = list.OrderBy(bm => bm.Label).ToList();

            Find.WindowStack.Add(new FloatMenu(sortedlist));
        }
Exemplo n.º 10
0
 public void SetBMixMode(CompBestMix CBM, string GizmoSel, bool edit)
 {
     if (edit)
     {
         //MultiplayerSupport.MPLog("Gizmo mode:", GizmoSel);
         CBM.CurMode = GizmoSel;
     }
 }
Exemplo n.º 11
0
 public static void SetBillBMVal(Thing billGiver, Bill bill)
 {
     if (billGiver != null)
     {
         CompBestMix CBM = billGiver.TryGetComp <CompBestMix>();
         if (CBM != null)
         {
             DoBillModeSelMenu(CBM, bill);
         }
     }
 }
Exemplo n.º 12
0
        public static void CheckBillBMValues(CompBestMix CBM, Thing billGiver, List <string> BillModes)
        {
            if (BillModes != null)
            {
                if (BillModes.Count > 0)
                {
                    List <string> newBillModes = new List <string>();
                    List <string> billIDs      = new List <string>();
                    BillStack     billStack    = (billGiver as IBillGiver)?.BillStack;
                    if (billStack != null)
                    {
                        List <Bill> bills = billStack?.Bills;
                        if (bills.Count > 0)
                        {
                            foreach (Bill bill in bills)
                            {
                                string id = bill?.GetUniqueLoadID();
                                if (id != null)
                                {
                                    billIDs.AddDistinct <string>(id);
                                }
                            }
                        }
                    }

                    foreach (string BillMode in BillModes)
                    {
                        if ((billIDs.Contains(BillValuePart(BillMode))))
                        {
                            newBillModes.AddDistinct <string>(BillMode);
                        }
                    }

                    CBM.BillBMModes = newBillModes;
                    //newBillModes.Clear();
                    //billIDs.Clear();
                }
            }
            else
            {
                CBM.BillBMModes = new List <string>();
            }
        }
Exemplo n.º 13
0
        public static Comparison <Thing> GetBMixComparer(Thing billGiver, IntVec3 rootCell, Bill bill, out bool rnd)
        {
            rnd = false;
            var BMixMode       = "DIS";
            var BMixDebugBench = false;

            if (IsValidForComp(billGiver))
            {
                CompBestMix compBM = billGiver.TryGetComp <CompBestMix>();
                if (compBM != null)
                {
                    //BMixMode = compBM.CurMode;
                    BMixMode       = BMBillUtility.UseBMixMode(compBM, billGiver, bill);
                    BMixDebugBench = compBM.BMixDebug;
                }
            }

            Comparison <Thing> comparison = null;

            switch (BMixMode)
            {
            case "DIS":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (t1.Position - rootCell).LengthHorizontalSquared;
                    float value = (t2.Position - rootCell).LengthHorizontalSquared;
                    return(num.CompareTo(value));
                };
                break;

            case "DTR":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float        maxdtr = 72000000;
                    var          t1dtr  = maxdtr;
                    CompRottable t1comp = t1.TryGetComp <CompRottable>();
                    if (t1comp != null)
                    {
                        t1dtr = t1comp.TicksUntilRotAtCurrentTemp;
                    }
                    var          t2dtr  = maxdtr;
                    CompRottable t2comp = t2.TryGetComp <CompRottable>();
                    if (t2comp != null)
                    {
                        t2dtr = t2comp.TicksUntilRotAtCurrentTemp;
                    }
                    var num   = t1dtr;
                    var value = t2dtr;
                    return(num.CompareTo(value));
                };
                break;

            case "HPT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num = 0f;
                    if (t2.def.useHitPoints)
                    {
                        num = ((float)(t2.MaxHitPoints - t2.HitPoints)) / ((float)Math.Max(1, t2.MaxHitPoints));
                    }
                    var value = 0f;
                    if (t1.def.useHitPoints)
                    {
                        value = ((float)(t1.MaxHitPoints - t1.HitPoints)) / ((float)Math.Max(1, t1.MaxHitPoints));
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "RHP":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num = 0f;
                    if (t2.def.useHitPoints)
                    {
                        num = ((float)t2.HitPoints) / ((float)Math.Max(1, t2.MaxHitPoints));
                    }
                    var value = 0f;
                    if (t1.def.useHitPoints)
                    {
                        value = ((float)t1.HitPoints) / ((float)Math.Max(1, t1.MaxHitPoints));
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "VLC":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = 0f - t2.MarketValue;
                    var value = 0f - t1.MarketValue;
                    return(num.CompareTo(value));
                };
                break;

            case "VLE":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.MarketValue;
                    var value = t1.MarketValue;
                    return(num.CompareTo(value));
                };
                break;

            case "TMP":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.AmbientTemperature;
                    var value = t1.AmbientTemperature;
                    return(num.CompareTo(value));
                };
                break;

            case "FRZ":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = 0f - t2.AmbientTemperature;
                    var value = 0f - t1.AmbientTemperature;
                    return(num.CompareTo(value));
                };
                break;

            case "BIT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = ((float)t2.def.stackLimit) / ((float)Math.Max(1, t2.stackCount));
                    var value = ((float)t1.def.stackLimit) / ((float)Math.Max(1, t1.stackCount));
                    return(num.CompareTo(value));
                };
                break;

            case "MST":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = GetStockAmount(t2, billGiver, rootCell, bill);
                    var value = GetStockAmount(t1, billGiver, rootCell, bill);
                    return(num.CompareTo(value));
                };
                break;

            case "LST":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = GetStockAmount(t1, billGiver, rootCell, bill);
                    var value = GetStockAmount(t2, billGiver, rootCell, bill);
                    return(num.CompareTo(value));
                };
                break;

            case "RND":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = RNDFloat();
                    var value = RNDFloat();
                    return(num.CompareTo(value));
                };
                rnd = true;
                break;

            case "BTY":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num = t2.GetStatValue(StatDefOf.Beauty);
                    if ((t2.def?.stuffProps != null) && (t2.def?.stuffProps?.statOffsets != null))
                    {
                        if (t2.def.stuffProps.statOffsets.StatListContains(StatDefOf.Beauty))
                        {
                            num += t2.def.stuffProps.statOffsets.GetStatOffsetFromList(StatDefOf.Beauty);
                        }
                    }
                    var value = t1.GetStatValue(StatDefOf.Beauty);
                    if ((t1.def?.stuffProps != null) && (t1.def?.stuffProps?.statOffsets != null))
                    {
                        if (t1.def.stuffProps.statOffsets.StatListContains(StatDefOf.Beauty))
                        {
                            value += t1.def.stuffProps.statOffsets.GetStatOffsetFromList(StatDefOf.Beauty);
                        }
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "UGY":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num = 0f - t2.GetStatValue(StatDefOf.Beauty);
                    if ((t2.def?.stuffProps != null) && (t2.def?.stuffProps?.statOffsets != null))
                    {
                        if (t2.def.stuffProps.statOffsets.StatListContains(StatDefOf.Beauty))
                        {
                            num -= t2.def.stuffProps.statOffsets.GetStatOffsetFromList(StatDefOf.Beauty);
                        }
                    }
                    var value = 0f - t1.GetStatValue(StatDefOf.Beauty);
                    if ((t1.def?.stuffProps != null) && (t1.def?.stuffProps?.statOffsets != null))
                    {
                        if (t1.def.stuffProps.statOffsets.StatListContains(StatDefOf.Beauty))
                        {
                            value -= t1.def.stuffProps.statOffsets.GetStatOffsetFromList(StatDefOf.Beauty);
                        }
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "HVY":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.Mass);
                    var value = t1.GetStatValue(StatDefOf.Mass);
                    return(num.CompareTo(value));
                };
                break;

            case "LGT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = 0f - t2.GetStatValue(StatDefOf.Mass);
                    var value = 0f - t1.GetStatValue(StatDefOf.Mass);
                    return(num.CompareTo(value));
                };
                break;

            case "FLM":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.Flammability);
                    var value = t1.GetStatValue(StatDefOf.Flammability);
                    return(num.CompareTo(value));
                };
                break;

            case "PTB":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.StuffPower_Armor_Blunt);
                    var value = t1.GetStatValue(StatDefOf.StuffPower_Armor_Blunt);
                    return(num.CompareTo(value));
                };
                break;

            case "PTS":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.StuffPower_Armor_Sharp);
                    var value = t1.GetStatValue(StatDefOf.StuffPower_Armor_Sharp);
                    return(num.CompareTo(value));
                };
                break;

            case "PTH":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.StuffPower_Armor_Heat);
                    var value = t1.GetStatValue(StatDefOf.StuffPower_Armor_Heat);
                    return(num.CompareTo(value));
                };
                break;

            case "PTE":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var     num          = 0f;
                    var     value        = 0f;
                    StatDef protElectric = DefDatabase <StatDef> .GetNamed(ProtElectricStat, false);

                    if (protElectric != null)
                    {
                        num   = t2.GetStatValue(protElectric);
                        value = t1.GetStatValue(protElectric);
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "INH":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.StuffPower_Insulation_Heat);
                    var value = t1.GetStatValue(StatDefOf.StuffPower_Insulation_Heat);
                    return(num.CompareTo(value));
                };
                break;

            case "INC":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.StuffPower_Insulation_Cold);
                    var value = t1.GetStatValue(StatDefOf.StuffPower_Insulation_Cold);
                    return(num.CompareTo(value));
                };
                break;

            case "SOF":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var     num      = 0f;
                    var     value    = 0f;
                    StatDef softness = DefDatabase <StatDef> .GetNamed(SoftnessStat, false);

                    if (softness != null)
                    {
                        num   = t2.GetStatValue(softness);
                        value = t1.GetStatValue(softness);
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "WSP":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.SharpDamageMultiplier);
                    var value = t1.GetStatValue(StatDefOf.SharpDamageMultiplier);
                    return(num.CompareTo(value));
                };
                break;

            case "WBT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.BluntDamageMultiplier);
                    var value = t1.GetStatValue(StatDefOf.BluntDamageMultiplier);
                    return(num.CompareTo(value));
                };
                break;

            case "NUL":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = 0f - t2.GetStatValue(StatDefOf.Nutrition);
                    var value = 0f - t1.GetStatValue(StatDefOf.Nutrition);
                    return(num.CompareTo(value));
                };
                break;

            case "NUH":
                comparison = delegate(Thing t1, Thing t2)
                {
                    var num   = t2.GetStatValue(StatDefOf.Nutrition);
                    var value = t1.GetStatValue(StatDefOf.Nutrition);
                    return(num.CompareTo(value));
                };
                break;

            default:
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (t1.Position - rootCell).LengthHorizontalSquared;
                    float value = (t2.Position - rootCell).LengthHorizontalSquared;
                    return(num.CompareTo(value));
                };
                break;
            }

            return(comparison);
        }
Exemplo n.º 14
0
        public static bool BMixRegionIsInRange(Region r, Thing billGiver, Bill bill)
        {
            if (!Controller.Settings.IncludeRegionLimiter)
            {
                return(true);
            }

            if (!IsValidForComp(billGiver))
            {
                return(true);
            }

            CompBestMix compBMix = billGiver.TryGetComp <CompBestMix>();

            if (compBMix != null)
            {
                //if (compBMix.CurMode == "DIS")
                if (BMBillUtility.UseBMixMode(compBMix, billGiver, bill) == "DIS")
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }

            /*
             * List<IntVec3> cells = r?.Cells.ToList<IntVec3>();
             * if ((cells != null) && (cells.Count > 0))
             * {
             *  foreach (IntVec3 cell in cells)
             *  {
             *      if (((float)((cell - billGiver.Position).LengthHorizontalSquared)) < ((float)(bill.ingredientSearchRadius * bill.ingredientSearchRadius)))
             *      {
             *          return true;
             *      }
             *  }
             * }
             */

            // optimised to region corners
            Map map = billGiver?.Map;

            if (map != null)
            {
                RegionGrid regions = map?.regionGrid; // *
                if (regions != null)
                {
                    IntVec3 chkcell = IntVec3.Zero;
                    for (var i = 0; i < 4; i++)
                    {
                        switch (i)
                        {
                        case 0: chkcell = new IntVec3(r.extentsClose.minX, 0, r.extentsClose.minZ); break;

                        case 3: chkcell = new IntVec3(r.extentsClose.minX, 0, r.extentsClose.maxZ); break;

                        case 2: chkcell = new IntVec3(r.extentsClose.maxX, 0, r.extentsClose.minZ); break;

                        case 1: chkcell = new IntVec3(r.extentsClose.maxX, 0, r.extentsClose.maxZ); break;
                        }
                        //if (chkcell.GetRegion(map) == r)
                        if (regions.GetRegionAt_NoRebuild_InvalidAllowed(chkcell) == r) // * More direct check
                        {
                            var scaleToCell       = (float)(chkcell - billGiver.Position).LengthHorizontalSquared;
                            var scaleSearchRadius = (float)(bill.ingredientSearchRadius * bill.ingredientSearchRadius);
                            if (Controller.Settings.UseRadiusLimit)
                            {
                                var RadiusLimit = (float)Controller.Settings.RadiusLimit;
                                var scaleLimit  = RadiusLimit * RadiusLimit;
                                if (scaleLimit < scaleSearchRadius)
                                {
                                    scaleSearchRadius = scaleLimit;
                                }
                            }
                            if (scaleToCell <= scaleSearchRadius)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 15
0
        public static Comparison <Thing> GetBMixComparer(Thing billGiver, IntVec3 rootCell)
        {
            string BMixMode       = "DIS";
            bool   BMixDebugBench = false;

            if (IsValidForComp(billGiver))
            {
                CompBestMix compBM = billGiver.TryGetComp <CompBestMix>();
                if (compBM != null)
                {
                    BMixMode       = compBM.CurMode;
                    BMixDebugBench = compBM.BMixDebug;
                }
            }

            Comparison <Thing> comparison = null;

            switch (BMixMode)
            {
            case "DIS":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (t1.Position - rootCell).LengthHorizontalSquared;
                    float value = (t2.Position - rootCell).LengthHorizontalSquared;
                    return(num.CompareTo(value));
                };
                break;

            case "DTR":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float        maxdtr = 72000000;
                    float        t1dtr  = maxdtr;
                    CompRottable t1comp = t1.TryGetComp <CompRottable>();
                    if (t1comp != null)
                    {
                        t1dtr = t1comp.TicksUntilRotAtCurrentTemp;
                    }
                    float        t2dtr  = maxdtr;
                    CompRottable t2comp = t2.TryGetComp <CompRottable>();
                    if (t2comp != null)
                    {
                        t2dtr = t2comp.TicksUntilRotAtCurrentTemp;
                    }
                    float num   = (maxdtr - t2dtr);
                    float value = (maxdtr - t1dtr);
                    return(num.CompareTo(value));
                };
                break;

            case "HPT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num = 0f;
                    if (t2.def.useHitPoints)
                    {
                        num = (((float)(t2.MaxHitPoints - t2.HitPoints)) / ((float)(Math.Max(1, t2.MaxHitPoints))));
                    }
                    float value = 0f;
                    if (t1.def.useHitPoints)
                    {
                        value = (((float)(t1.MaxHitPoints - t1.HitPoints)) / ((float)(Math.Max(1, t1.MaxHitPoints))));
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "VLC":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (0f - t2.MarketValue);
                    float value = (0f - t1.MarketValue);
                    return(num.CompareTo(value));
                };
                break;

            case "VLE":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.MarketValue;
                    float value = t1.MarketValue;
                    return(num.CompareTo(value));
                };
                break;

            case "TMP":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.AmbientTemperature;
                    float value = t1.AmbientTemperature;
                    return(num.CompareTo(value));
                };
                break;

            case "FRZ":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (0f - t2.AmbientTemperature);
                    float value = (0f - t1.AmbientTemperature);
                    return(num.CompareTo(value));
                };
                break;

            case "BIT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (((float)(t2.def.stackLimit)) / ((float)(Math.Max(1, t2.stackCount))));
                    float value = (((float)(t1.def.stackLimit)) / ((float)(Math.Max(1, t1.stackCount))));
                    return(num.CompareTo(value));
                };
                break;

            case "RND":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = RNDFloat();
                    float value = RNDFloat();
                    return(num.CompareTo(value));
                };
                break;

            case "BTY":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.Beauty);
                    float value = t1.GetStatValue(StatDefOf.Beauty);
                    return(num.CompareTo(value));
                };
                break;

            case "UGY":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (0f - t1.GetStatValue(StatDefOf.Beauty));
                    float value = (0f - t2.GetStatValue(StatDefOf.Beauty));
                    return(num.CompareTo(value));
                };
                break;

            case "HVY":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.Mass);
                    float value = t1.GetStatValue(StatDefOf.Mass);
                    return(num.CompareTo(value));
                };
                break;

            case "LGT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (0f - t2.GetStatValue(StatDefOf.Mass));
                    float value = (0f - t1.GetStatValue(StatDefOf.Mass));
                    return(num.CompareTo(value));
                };
                break;

            case "FLM":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.Flammability);
                    float value = t1.GetStatValue(StatDefOf.Flammability);
                    return(num.CompareTo(value));
                };
                break;

            case "PTB":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.StuffPower_Armor_Blunt);
                    float value = t1.GetStatValue(StatDefOf.StuffPower_Armor_Blunt);
                    return(num.CompareTo(value));
                };
                break;

            case "PTS":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.StuffPower_Armor_Sharp);
                    float value = t1.GetStatValue(StatDefOf.StuffPower_Armor_Sharp);
                    return(num.CompareTo(value));
                };
                break;

            case "PTE":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float   num          = 0f;
                    float   value        = 0f;
                    StatDef protElectric = DefDatabase <StatDef> .GetNamed(ProtElectricStat, false);

                    if (protElectric != null)
                    {
                        num   = t2.GetStatValue(protElectric);
                        value = t1.GetStatValue(protElectric);
                    }
                    return(num.CompareTo(value));
                };
                break;

            case "INH":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.StuffPower_Insulation_Heat);
                    float value = t1.GetStatValue(StatDefOf.StuffPower_Insulation_Heat);
                    return(num.CompareTo(value));
                };
                break;

            case "INC":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.StuffPower_Insulation_Cold);
                    float value = t1.GetStatValue(StatDefOf.StuffPower_Insulation_Cold);
                    return(num.CompareTo(value));
                };
                break;

            case "WSP":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.SharpDamageMultiplier);
                    float value = t1.GetStatValue(StatDefOf.SharpDamageMultiplier);
                    return(num.CompareTo(value));
                };
                break;

            case "WBT":
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = t2.GetStatValue(StatDefOf.BluntDamageMultiplier);
                    float value = t1.GetStatValue(StatDefOf.BluntDamageMultiplier);
                    return(num.CompareTo(value));
                };
                break;

            default:
                comparison = delegate(Thing t1, Thing t2)
                {
                    float num   = (t1.Position - rootCell).LengthHorizontalSquared;
                    float value = (t2.Position - rootCell).LengthHorizontalSquared;
                    return(num.CompareTo(value));
                };
                break;
            }

            return(comparison);
        }