private static int <ThingsLabel> m__0(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs)
        {
            int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def);

            if (num != 0)
            {
                return(num);
            }
            return(lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue));
        }
Beispiel #2
0
        public static string ThingsLabel(List <ThingCount> things, string prefix = "  - ")
        {
            tmpThingsLabelElements.Clear();
            foreach (ThingCount thing in things)
            {
                LabelElement labelElement = (from elem in tmpThingsLabelElements
                                             where thing.Thing.def.stackLimit > 1 && elem.thingTemplate.def == thing.Thing.def && elem.thingTemplate.Stuff == thing.Thing.Stuff
                                             select elem).FirstOrDefault();
                if (labelElement != null)
                {
                    labelElement.count += thing.Count;
                }
                else
                {
                    tmpThingsLabelElements.Add(new LabelElement
                    {
                        thingTemplate = thing.Thing,
                        count         = thing.Count
                    });
                }
            }
            tmpThingsLabelElements.Sort(delegate(LabelElement lhs, LabelElement rhs)
            {
                int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def);
                if (num != 0)
                {
                    return(num);
                }
                return(lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue));
            });
            StringBuilder stringBuilder = new StringBuilder();

            foreach (LabelElement tmpThingsLabelElement in tmpThingsLabelElements)
            {
                string str = string.Empty;
                if (tmpThingsLabelElement.thingTemplate.ParentHolder is Pawn_ApparelTracker)
                {
                    str = " (" + "WornBy".Translate(((Pawn)tmpThingsLabelElement.thingTemplate.ParentHolder.ParentHolder).LabelShort, (Pawn)tmpThingsLabelElement.thingTemplate.ParentHolder.ParentHolder) + ")";
                }
                else if (tmpThingsLabelElement.thingTemplate.ParentHolder is Pawn_EquipmentTracker)
                {
                    str = " (" + "EquippedBy".Translate(((Pawn)tmpThingsLabelElement.thingTemplate.ParentHolder.ParentHolder).LabelShort, (Pawn)tmpThingsLabelElement.thingTemplate.ParentHolder.ParentHolder) + ")";
                }
                if (tmpThingsLabelElement.count == 1)
                {
                    stringBuilder.AppendLine(prefix + tmpThingsLabelElement.thingTemplate.LabelCap + str);
                }
                else
                {
                    stringBuilder.AppendLine(prefix + ThingLabel(tmpThingsLabelElement.thingTemplate.def, tmpThingsLabelElement.thingTemplate.Stuff, tmpThingsLabelElement.count).CapitalizeFirst() + str);
                }
            }
            tmpThingsLabelElements.Clear();
            return(stringBuilder.ToString().TrimEndNewlines());
        }
Beispiel #3
0
 public override int Compare(Transferable lhs, Transferable rhs)
 {
     return(TransferableComparer_Category.Compare(lhs.ThingDef, rhs.ThingDef));
 }
        public static string ThingsLabel(List <ThingCount> things, string prefix = "  - ")
        {
            GenLabel.tmpThingsLabelElements.Clear();
            using (List <ThingCount> .Enumerator enumerator = things.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ThingCount            thing        = enumerator.Current;
                    GenLabel.LabelElement labelElement = (from elem in GenLabel.tmpThingsLabelElements
                                                          where thing.Thing.def.stackLimit > 1 && elem.thingTemplate.def == thing.Thing.def && elem.thingTemplate.Stuff == thing.Thing.Stuff
                                                          select elem).FirstOrDefault <GenLabel.LabelElement>();
                    if (labelElement != null)
                    {
                        labelElement.count += thing.Count;
                    }
                    else
                    {
                        GenLabel.tmpThingsLabelElements.Add(new GenLabel.LabelElement
                        {
                            thingTemplate = thing.Thing,
                            count         = thing.Count
                        });
                    }
                }
            }
            GenLabel.tmpThingsLabelElements.Sort(delegate(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs)
            {
                int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def);
                if (num != 0)
                {
                    return(num);
                }
                return(lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue));
            });
            StringBuilder stringBuilder = new StringBuilder();

            foreach (GenLabel.LabelElement labelElement2 in GenLabel.tmpThingsLabelElements)
            {
                string str = string.Empty;
                if (labelElement2.thingTemplate.ParentHolder is Pawn_ApparelTracker)
                {
                    str = " (" + "WornBy".Translate(new object[]
                    {
                        ((Pawn)labelElement2.thingTemplate.ParentHolder.ParentHolder).LabelShort
                    }) + ")";
                }
                else if (labelElement2.thingTemplate.ParentHolder is Pawn_EquipmentTracker)
                {
                    str = " (" + "EquippedBy".Translate(new object[]
                    {
                        ((Pawn)labelElement2.thingTemplate.ParentHolder.ParentHolder).LabelShort
                    }) + ")";
                }
                if (labelElement2.count == 1)
                {
                    stringBuilder.AppendLine(prefix + labelElement2.thingTemplate.LabelCap + str);
                }
                else
                {
                    stringBuilder.AppendLine(prefix + GenLabel.ThingLabel(labelElement2.thingTemplate.def, labelElement2.thingTemplate.Stuff, labelElement2.count).CapitalizeFirst() + str);
                }
            }
            GenLabel.tmpThingsLabelElements.Clear();
            return(stringBuilder.ToString().TrimEndNewlines());
        }
Beispiel #5
0
        public static string ThingsLabel(List <Thing> things)
        {
            GenLabel.tmpThingsLabelElements.Clear();
            foreach (Thing thing in things)
            {
                GenLabel.LabelElement labelElement = (from elem in GenLabel.tmpThingsLabelElements
                                                      where thing.def.stackLimit > 1 && elem.thingTemplate.def == thing.def && elem.thingTemplate.Stuff == thing.Stuff
                                                      select elem).FirstOrDefault <GenLabel.LabelElement>();
                if (labelElement != null)
                {
                    labelElement.count += thing.stackCount;
                }
                else
                {
                    GenLabel.tmpThingsLabelElements.Add(new GenLabel.LabelElement
                    {
                        thingTemplate = thing,
                        count         = thing.stackCount
                    });
                }
            }
            GenLabel.tmpThingsLabelElements.Sort(delegate(GenLabel.LabelElement lhs, GenLabel.LabelElement rhs)
            {
                int num = TransferableComparer_Category.Compare(lhs.thingTemplate.def, rhs.thingTemplate.def);
                if (num != 0)
                {
                    return(num);
                }
                return(lhs.thingTemplate.MarketValue.CompareTo(rhs.thingTemplate.MarketValue));
            });
            StringBuilder stringBuilder = new StringBuilder();

            foreach (GenLabel.LabelElement current in GenLabel.tmpThingsLabelElements)
            {
                string str = string.Empty;
                if (current.thingTemplate.ParentHolder is Pawn_ApparelTracker)
                {
                    str = " (" + "WornBy".Translate(new object[]
                    {
                        (current.thingTemplate.ParentHolder.ParentHolder as Pawn).LabelShort
                    }) + ")";
                }
                else if (current.thingTemplate.ParentHolder is Pawn_EquipmentTracker)
                {
                    str = " (" + "EquippedBy".Translate(new object[]
                    {
                        (current.thingTemplate.ParentHolder.ParentHolder as Pawn).LabelShort
                    }) + ")";
                }
                if (current.count == 1)
                {
                    stringBuilder.AppendLine("  " + current.thingTemplate.LabelCap + str);
                }
                else
                {
                    stringBuilder.AppendLine("  " + GenLabel.ThingLabel(current.thingTemplate.def, current.thingTemplate.Stuff, current.count).CapitalizeFirst() + str);
                }
            }
            GenLabel.tmpThingsLabelElements.Clear();
            return(stringBuilder.ToString());
        }