Example #1
0
        public static void PawnKindsWeaponUsage()
        {
            List <TableDataGetter <PawnKindDef> > list = new List <TableDataGetter <PawnKindDef> >();

            list.Add(new TableDataGetter <PawnKindDef>("defName", (PawnKindDef x) => x.defName));
            list.Add(new TableDataGetter <PawnKindDef>("avg $", (PawnKindDef x) => x.weaponMoney.Average.ToString()));
            list.Add(new TableDataGetter <PawnKindDef>("min $", (PawnKindDef x) => x.weaponMoney.min.ToString()));
            list.Add(new TableDataGetter <PawnKindDef>("max $", (PawnKindDef x) => x.weaponMoney.max.ToString()));
            list.Add(new TableDataGetter <PawnKindDef>("points", (PawnKindDef x) => x.combatPower.ToString()));
            list.AddRange(from w in DefDatabase <ThingDef> .AllDefs
                          where w.IsWeapon && !w.weaponTags.NullOrEmpty()
                          orderby w.IsMeleeWeapon descending, w.techLevel, w.BaseMarketValue
                          select new TableDataGetter <PawnKindDef>(w.label.Shorten() + "\n$" + w.BaseMarketValue.ToString("F0"), delegate(PawnKindDef k)
            {
                if (k.weaponTags != null && w.weaponTags.Any((string z) => k.weaponTags.Contains(z)))
                {
                    float num = PawnWeaponGenerator.CheapestNonDerpPriceFor(w);
                    if (k.weaponMoney.max < num)
                    {
                        return("-");
                    }
                    if (k.weaponMoney.min > num)
                    {
                        return("✓");
                    }
                    return((1f - (num - k.weaponMoney.min) / (k.weaponMoney.max - k.weaponMoney.min)).ToStringPercent("F0"));
                }
                return(string.Empty);
            }));
            DebugTables.MakeTablesDialog(from x in DefDatabase <PawnKindDef> .AllDefs
                                         where (int)x.RaceProps.intelligence >= 1
                                         orderby(x.defaultFactionType == null) ? 2147483647 : ((int)x.defaultFactionType.techLevel), x.combatPower
                                         select x, list.ToArray());
        }
        public override IEnumerable <string> ConfigErrors()
        {
            foreach (string item in base.ConfigErrors())
            {
                yield return(item);
            }
            if (backstoryFilters != null && backstoryFiltersOverride != null)
            {
                yield return("both backstoryCategories and backstoryCategoriesOverride are defined");
            }
            if (race == null)
            {
                yield return("no race");
            }
            if (baseRecruitDifficulty > 1.0001f)
            {
                yield return(defName + " recruitDifficulty is greater than 1. 1 means impossible to recruit.");
            }
            if (combatPower < 0f)
            {
                yield return(defName + " has no combatPower.");
            }
            if (weaponMoney != FloatRange.Zero)
            {
                float num = 999999f;
                int   j;
                for (j = 0; j < weaponTags.Count; j++)
                {
                    IEnumerable <ThingDef> source = DefDatabase <ThingDef> .AllDefs.Where((ThingDef d) => d.weaponTags != null && d.weaponTags.Contains(weaponTags[j]));

                    if (source.Any())
                    {
                        num = Mathf.Min(num, source.Min((ThingDef d) => PawnWeaponGenerator.CheapestNonDerpPriceFor(d)));
                    }
                }
                if (num < 999999f && num > weaponMoney.min)
                {
                    yield return("Cheapest weapon with one of my weaponTags costs " + num + " but weaponMoney min is " + weaponMoney.min + ", so could end up weaponless.");
                }
            }
            if (!RaceProps.Humanlike && lifeStages.Count != RaceProps.lifeStageAges.Count)
            {
                yield return("PawnKindDef defines " + lifeStages.Count + " lifeStages while race def defines " + RaceProps.lifeStageAges.Count);
            }
            if (apparelRequired != null)
            {
                for (int i = 0; i < apparelRequired.Count; i++)
                {
                    for (int k = i + 1; k < apparelRequired.Count; k++)
                    {
                        if (!ApparelUtility.CanWearTogether(apparelRequired[i], apparelRequired[k], race.race.body))
                        {
                            yield return(string.Concat("required apparel can't be worn together (", apparelRequired[i], ", ", apparelRequired[k], ")"));
                        }
                    }
                }
            }
            if (alternateGraphics == null)
            {
                yield break;
            }
            foreach (AlternateGraphic alternateGraphic in alternateGraphics)
            {
                if (alternateGraphic.Weight < 0f)
                {
                    yield return("alternate graphic has negative weight.");
                }
            }
        }
 public override IEnumerable <string> ConfigErrors()
 {
     foreach (string err in this.< ConfigErrors > __BaseCallProxy0())
     {
         yield return(err);
     }
     if (this.race == null)
     {
         yield return("no race");
     }
     else if (this.RaceProps.Humanlike && this.backstoryCategory.NullOrEmpty())
     {
         yield return("Humanlike needs backstoryCategory.");
     }
     if (this.baseRecruitDifficulty > 1.0001f)
     {
         yield return(this.defName + " recruitDifficulty is greater than 1. 1 means impossible to recruit.");
     }
     if (this.combatPower < 0f)
     {
         yield return(this.defName + " has no combatPower.");
     }
     if (this.weaponMoney != FloatRange.Zero)
     {
         float minCost = 999999f;
         int   i;
         for (i = 0; i < this.weaponTags.Count; i++)
         {
             IEnumerable <ThingDef> source = from d in DefDatabase <ThingDef> .AllDefs
                                             where d.weaponTags != null && d.weaponTags.Contains(this.weaponTags[i])
                                             select d;
             if (source.Any <ThingDef>())
             {
                 minCost = Mathf.Min(minCost, source.Min((ThingDef d) => PawnWeaponGenerator.CheapestNonDerpPriceFor(d)));
             }
         }
         if (minCost > this.weaponMoney.min)
         {
             yield return(string.Concat(new object[]
             {
                 "Cheapest weapon with one of my weaponTags costs ",
                 minCost,
                 " but weaponMoney min is ",
                 this.weaponMoney.min,
                 ", so could end up weaponless."
             }));
         }
     }
     if (!this.RaceProps.Humanlike && this.lifeStages.Count != this.RaceProps.lifeStageAges.Count)
     {
         yield return(string.Concat(new object[]
         {
             "PawnKindDef defines ",
             this.lifeStages.Count,
             " lifeStages while race def defines ",
             this.RaceProps.lifeStageAges.Count
         }));
     }
     if (this.apparelRequired != null)
     {
         for (int k = 0; k < this.apparelRequired.Count; k++)
         {
             for (int j = k + 1; j < this.apparelRequired.Count; j++)
             {
                 if (!ApparelUtility.CanWearTogether(this.apparelRequired[k], this.apparelRequired[j], this.race.race.body))
                 {
                     yield return(string.Concat(new object[]
                     {
                         "required apparel can't be worn together (",
                         this.apparelRequired[k],
                         ", ",
                         this.apparelRequired[j],
                         ")"
                     }));
                 }
             }
         }
     }
     yield break;
 }