private static void VerbProperties_GetDamageFactorForPostfix(VerbProperties __instance, Tool tool, Pawn attacker, HediffComp_VerbGiver hediffCompSource, ref float __result)
 {
     if (tool == null && __instance.linkedBodyPartsGroup != null)
     {
         float damageFactor = PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(attacker.health.hediffSet, __instance.linkedBodyPartsGroup);
         if (__instance.ensureLinkedBodyPartsGroupAlwaysUsable)
         {
             return;
         }
         else if (damageFactor == 0f)
         {
             __result = 0f;
             return;
         }
     }
     return;
 }
Exemple #2
0
        private static void DoDebugOptions(Rect rightRect, Pawn pawn)
        {
            Widgets.CheckboxLabeled(new Rect(rightRect.x, rightRect.y - 25f, 110f, 30f), "Dev: AllDiffs", ref showAllHediffs);
            Widgets.CheckboxLabeled(new Rect(rightRect.x + 115f, rightRect.y - 25f, 120f, 30f), "DiffsDebugInfo", ref showHediffsDebugInfo);
            if (!Widgets.ButtonText(new Rect(rightRect.x + 240f, rightRect.y - 27f, 115f, 25f), "Debug info"))
            {
                return;
            }
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            list.Add(new FloatMenuOption("Parts hit chance (this part or any child node)", delegate
            {
                StringBuilder stringBuilder13 = new StringBuilder();
                foreach (BodyPartRecord item2 in pawn.RaceProps.body.AllParts.OrderByDescending((BodyPartRecord x) => x.coverageAbsWithChildren))
                {
                    stringBuilder13.AppendLine(item2.LabelCap + " " + item2.coverageAbsWithChildren.ToStringPercent());
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder13.ToString()));
            }));
            list.Add(new FloatMenuOption("Parts hit chance (exactly this part)", delegate
            {
                StringBuilder stringBuilder12 = new StringBuilder();
                float num2 = 0f;
                foreach (BodyPartRecord item3 in pawn.RaceProps.body.AllParts.OrderByDescending((BodyPartRecord x) => x.coverageAbs))
                {
                    stringBuilder12.AppendLine(item3.LabelCap + " " + item3.coverageAbs.ToStringPercent());
                    num2 += item3.coverageAbs;
                }
                stringBuilder12.AppendLine();
                stringBuilder12.AppendLine("Total " + num2.ToStringPercent());
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder12.ToString()));
            }));
            list.Add(new FloatMenuOption("Per-part efficiency", delegate
            {
                StringBuilder stringBuilder11 = new StringBuilder();
                foreach (BodyPartRecord allPart in pawn.RaceProps.body.AllParts)
                {
                    stringBuilder11.AppendLine(allPart.LabelCap + " " + PawnCapacityUtility.CalculatePartEfficiency(pawn.health.hediffSet, allPart).ToStringPercent());
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder11.ToString()));
            }));
            list.Add(new FloatMenuOption("BodyPartGroup efficiency (of only natural parts)", delegate
            {
                StringBuilder stringBuilder10 = new StringBuilder();
                foreach (BodyPartGroupDef item4 in DefDatabase <BodyPartGroupDef> .AllDefs.Where((BodyPartGroupDef x) => pawn.RaceProps.body.AllParts.Any((BodyPartRecord y) => y.groups.Contains(x))))
                {
                    stringBuilder10.AppendLine(item4.LabelCap + " " + PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(pawn.health.hediffSet, item4).ToStringPercent());
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder10.ToString()));
            }));
            list.Add(new FloatMenuOption("IsSolid", delegate
            {
                StringBuilder stringBuilder9 = new StringBuilder();
                foreach (BodyPartRecord notMissingPart in pawn.health.hediffSet.GetNotMissingParts())
                {
                    stringBuilder9.AppendLine(notMissingPart.LabelCap + " " + notMissingPart.def.IsSolid(notMissingPart, pawn.health.hediffSet.hediffs));
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder9.ToString()));
            }));
            list.Add(new FloatMenuOption("IsSkinCovered", delegate
            {
                StringBuilder stringBuilder8 = new StringBuilder();
                foreach (BodyPartRecord notMissingPart2 in pawn.health.hediffSet.GetNotMissingParts())
                {
                    stringBuilder8.AppendLine(notMissingPart2.LabelCap + " " + notMissingPart2.def.IsSkinCovered(notMissingPart2, pawn.health.hediffSet));
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder8.ToString()));
            }));
            list.Add(new FloatMenuOption("Immunities", delegate
            {
                StringBuilder stringBuilder7 = new StringBuilder();
                foreach (HediffDef item5 in DefDatabase <HediffDef> .AllDefsListForReading)
                {
                    ImmunityRecord immunityRecord = pawn.health.immunity.GetImmunityRecord(item5);
                    if (immunityRecord != null)
                    {
                        stringBuilder7.AppendLine(string.Concat("Hediff: ", immunityRecord.hediffDef, ", Source: ", immunityRecord.source, ", Immunity: ", immunityRecord.immunity));
                    }
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder7.ToString()));
            }));
            list.Add(new FloatMenuOption("does have added parts", delegate
            {
                StringBuilder stringBuilder6 = new StringBuilder();
                foreach (BodyPartRecord notMissingPart3 in pawn.health.hediffSet.GetNotMissingParts())
                {
                    stringBuilder6.AppendLine(notMissingPart3.LabelCap + " " + pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(notMissingPart3));
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder6.ToString()));
            }));
            list.Add(new FloatMenuOption("GetNotMissingParts", delegate
            {
                StringBuilder stringBuilder5 = new StringBuilder();
                foreach (BodyPartRecord notMissingPart4 in pawn.health.hediffSet.GetNotMissingParts())
                {
                    stringBuilder5.AppendLine(notMissingPart4.LabelCap);
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder5.ToString()));
            }));
            list.Add(new FloatMenuOption("GetCoverageOfNotMissingNaturalParts", delegate
            {
                StringBuilder stringBuilder4 = new StringBuilder();
                foreach (BodyPartRecord item6 in pawn.RaceProps.body.AllParts.OrderByDescending((BodyPartRecord x) => pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(x)))
                {
                    stringBuilder4.AppendLine(item6.LabelCap + ": " + pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(item6).ToStringPercent());
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder4.ToString()));
            }));
            list.Add(new FloatMenuOption("parts nutrition (assuming adult)", delegate
            {
                StringBuilder stringBuilder3 = new StringBuilder();
                float totalCorpseNutrition   = StatDefOf.Nutrition.Worker.GetValueAbstract(pawn.RaceProps.corpseDef);
                foreach (BodyPartRecord item7 in pawn.RaceProps.body.AllParts.OrderByDescending((BodyPartRecord x) => FoodUtility.GetBodyPartNutrition(totalCorpseNutrition, pawn, x)))
                {
                    stringBuilder3.AppendLine(item7.LabelCap + ": " + FoodUtility.GetBodyPartNutrition(totalCorpseNutrition, pawn, item7));
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder3.ToString()));
            }));
            list.Add(new FloatMenuOption("HediffGiver_Birthday chance at age", delegate
            {
                List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                HediffGiver_Birthday hLocal  = default(HediffGiver_Birthday);
                foreach (HediffGiverSetDef hediffGiverSet in pawn.RaceProps.hediffGiverSets)
                {
                    foreach (HediffGiver_Birthday item8 in hediffGiverSet.hediffGivers.OfType <HediffGiver_Birthday>())
                    {
                        hLocal = item8;
                        FloatMenuOption item = new FloatMenuOption(hediffGiverSet.defName + " - " + item8.hediff.defName, delegate
                        {
                            StringBuilder stringBuilder2 = new StringBuilder();
                            stringBuilder2.AppendLine("% of pawns which will have at least 1 " + hLocal.hediff.label + " at age X:");
                            stringBuilder2.AppendLine();
                            for (int j = 1; (float)j < pawn.RaceProps.lifeExpectancy + 20f; j++)
                            {
                                stringBuilder2.AppendLine(j + ": " + hLocal.DebugChanceToHaveAtAge(pawn, j).ToStringPercent());
                            }
                            Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder2.ToString()));
                        });
                        list2.Add(item);
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list2));
            }));
            list.Add(new FloatMenuOption("HediffGiver_Birthday count at age", delegate
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("Average hediffs count (from HediffGiver_Birthday) at age X:");
                stringBuilder.AppendLine();
                for (int i = 1; (float)i < pawn.RaceProps.lifeExpectancy + 20f; i++)
                {
                    float num = 0f;
                    foreach (HediffGiverSetDef hediffGiverSet2 in pawn.RaceProps.hediffGiverSets)
                    {
                        foreach (HediffGiver_Birthday item9 in hediffGiverSet2.hediffGivers.OfType <HediffGiver_Birthday>())
                        {
                            num += item9.DebugChanceToHaveAtAge(pawn, i);
                        }
                    }
                    stringBuilder.AppendLine(i + ": " + num.ToStringDecimalIfSmall());
                }
                Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString()));
            }));
            Find.WindowStack.Add(new FloatMenu(list));
        }
Exemple #3
0
 private static void DoDebugOptions(Rect rightRect, Pawn pawn)
 {
     Widgets.CheckboxLabeled(new Rect(rightRect.x, (float)(rightRect.y - 25.0), 110f, 30f), "Dev: AllDiffs", ref HealthCardUtility.showAllHediffs, false);
     Widgets.CheckboxLabeled(new Rect((float)(rightRect.x + 115.0), (float)(rightRect.y - 25.0), 120f, 30f), "DiffsDebugInfo", ref HealthCardUtility.showHediffsDebugInfo, false);
     if (Widgets.ButtonText(new Rect((float)(rightRect.x + 240.0), (float)(rightRect.y - 27.0), 115f, 25f), "Debug info", true, false, true))
     {
         List <FloatMenuOption> list = new List <FloatMenuOption>();
         list.Add(new FloatMenuOption("Parts hit chance (this part or any child node)", delegate
         {
             StringBuilder stringBuilder13 = new StringBuilder();
             foreach (BodyPartRecord item2 in from x in pawn.RaceProps.body.AllParts
                      orderby x.coverageAbsWithChildren descending
                      select x)
             {
                 stringBuilder13.AppendLine(item2.def.LabelCap + " " + item2.coverageAbsWithChildren.ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder13.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("Parts hit chance (exactly this part)", delegate
         {
             StringBuilder stringBuilder12 = new StringBuilder();
             float num9 = 0f;
             foreach (BodyPartRecord item3 in from x in pawn.RaceProps.body.AllParts
                      orderby x.coverageAbs descending
                      select x)
             {
                 stringBuilder12.AppendLine(item3.def.LabelCap + " " + item3.coverageAbs.ToStringPercent());
                 num9 += item3.coverageAbs;
             }
             stringBuilder12.AppendLine();
             stringBuilder12.AppendLine("Total " + num9.ToStringPercent());
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder12.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("Per-part efficiency", delegate
         {
             StringBuilder stringBuilder11 = new StringBuilder();
             foreach (BodyPartRecord allPart in pawn.RaceProps.body.AllParts)
             {
                 stringBuilder11.AppendLine(allPart.def.LabelCap + " " + PawnCapacityUtility.CalculatePartEfficiency(pawn.health.hediffSet, allPart, false, null).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder11.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("BodyPartGroup efficiency (of only natural parts)", delegate
         {
             StringBuilder stringBuilder10 = new StringBuilder();
             foreach (BodyPartGroupDef item4 in from x in DefDatabase <BodyPartGroupDef> .AllDefs
                      where pawn.RaceProps.body.AllParts.Any((BodyPartRecord y) => y.groups.Contains(x))
                      select x)
             {
                 stringBuilder10.AppendLine(item4.LabelCap + " " + PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(pawn.health.hediffSet, item4).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder10.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("IsSolid", delegate
         {
             StringBuilder stringBuilder9 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder9.AppendLine(notMissingPart.def.LabelCap + " " + notMissingPart.def.IsSolid(notMissingPart, pawn.health.hediffSet.hediffs));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder9.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("IsSkinCovered", delegate
         {
             StringBuilder stringBuilder8 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart2 in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder8.AppendLine(notMissingPart2.def.LabelCap + " " + notMissingPart2.def.IsSkinCovered(notMissingPart2, pawn.health.hediffSet));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder8.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("does have added parts", delegate
         {
             StringBuilder stringBuilder7 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart3 in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder7.AppendLine(notMissingPart3.def.LabelCap + " " + pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(notMissingPart3));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder7.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("GetNotMissingParts", delegate
         {
             StringBuilder stringBuilder6 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart4 in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder6.AppendLine(notMissingPart4.def.LabelCap);
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder6.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("GetCoverageOfNotMissingNaturalParts", delegate
         {
             StringBuilder stringBuilder5 = new StringBuilder();
             foreach (BodyPartRecord item5 in from x in pawn.RaceProps.body.AllParts
                      orderby pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(x) descending
                      select x)
             {
                 stringBuilder5.AppendLine(item5.def.LabelCap + ": " + pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(item5).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder5.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("parts nutrition", delegate
         {
             StringBuilder stringBuilder4 = new StringBuilder();
             foreach (BodyPartRecord item6 in from x in pawn.RaceProps.body.AllParts
                      orderby FoodUtility.GetBodyPartNutrition(pawn, x) descending
                      select x)
             {
                 stringBuilder4.AppendLine(item6.def.LabelCap + ": " + FoodUtility.GetBodyPartNutrition(pawn, item6));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder4.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("test old injury pain factor probability", delegate
         {
             StringBuilder stringBuilder3 = new StringBuilder();
             int num4   = 0;
             int num5   = 0;
             int num6   = 0;
             float num7 = 0f;
             int num8   = 10000;
             for (int i = 0; i < num8; i++)
             {
                 float randomPainFactor = OldInjuryUtility.GetRandomPainFactor();
                 if (randomPainFactor < 0.0)
                 {
                     Log.Error("Pain factor < 0");
                 }
                 if (randomPainFactor == 0.0)
                 {
                     num4++;
                 }
                 if (randomPainFactor < 1.0)
                 {
                     num5++;
                 }
                 if (randomPainFactor < 5.0)
                 {
                     num6++;
                 }
                 if (randomPainFactor > num7)
                 {
                     num7 = randomPainFactor;
                 }
             }
             stringBuilder3.AppendLine("total: " + num8);
             stringBuilder3.AppendLine("0: " + num4 + " (" + ((float)num4 / (float)num8).ToStringPercent() + ")");
             stringBuilder3.AppendLine("< 1: " + num5 + " (" + ((float)num5 / (float)num8).ToStringPercent() + ")");
             stringBuilder3.AppendLine("< 5: " + num6 + " (" + ((float)num6 / (float)num8).ToStringPercent() + ")");
             stringBuilder3.AppendLine("max: " + num7);
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder3.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         HediffGiver_Birthday hLocal;
         list.Add(new FloatMenuOption("HediffGiver_Birthday chance at age", delegate
         {
             List <FloatMenuOption> list2 = new List <FloatMenuOption>();
             foreach (HediffGiverSetDef hediffGiverSet in pawn.RaceProps.hediffGiverSets)
             {
                 foreach (HediffGiver_Birthday item7 in hediffGiverSet.hediffGivers.OfType <HediffGiver_Birthday>())
                 {
                     hLocal = item7;
                     FloatMenuOption item = new FloatMenuOption(hediffGiverSet.defName + " - " + item7.hediff.defName, delegate
                     {
                         StringBuilder stringBuilder2 = new StringBuilder();
                         stringBuilder2.AppendLine("% of pawns which will have at least 1 " + hLocal.hediff.label + " at age X:");
                         stringBuilder2.AppendLine();
                         int num3 = 1;
                         while ((float)num3 < pawn.RaceProps.lifeExpectancy + 20.0)
                         {
                             stringBuilder2.AppendLine(num3 + ": " + hLocal.DebugChanceToHaveAtAge(pawn, num3).ToStringPercent());
                             num3++;
                         }
                         Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder2.ToString(), null, null, null, null, null, false));
                     }, MenuOptionPriority.Default, null, null, 0f, null, null);
                     list2.Add(item);
                 }
             }
             Find.WindowStack.Add(new FloatMenu(list2));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("HediffGiver_Birthday count at age", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.AppendLine("Average hediffs count (from HediffGiver_Birthday) at age X:");
             stringBuilder.AppendLine();
             int num = 1;
             while ((float)num < pawn.RaceProps.lifeExpectancy + 20.0)
             {
                 float num2 = 0f;
                 foreach (HediffGiverSetDef hediffGiverSet2 in pawn.RaceProps.hediffGiverSets)
                 {
                     foreach (HediffGiver_Birthday item8 in hediffGiverSet2.hediffGivers.OfType <HediffGiver_Birthday>())
                     {
                         num2 += item8.DebugChanceToHaveAtAge(pawn, num);
                     }
                 }
                 stringBuilder.AppendLine(num + ": " + num2.ToStringDecimalIfSmall());
                 num++;
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         Find.WindowStack.Add(new FloatMenu(list));
     }
 }
Exemple #4
0
 private static void DoDebugOptions(Rect rightRect, Pawn pawn)
 {
     Widgets.CheckboxLabeled(new Rect(rightRect.x, rightRect.y - 25f, 110f, 30f), "Dev: AllDiffs", ref showAllHediffs);
     Widgets.CheckboxLabeled(new Rect(rightRect.x + 115f, rightRect.y - 25f, 120f, 30f), "DiffsDebugInfo", ref showHediffsDebugInfo);
     if (Widgets.ButtonText(new Rect(rightRect.x + 240f, rightRect.y - 27f, 115f, 25f), "Debug info"))
     {
         List <FloatMenuOption> list = new List <FloatMenuOption>();
         list.Add(new FloatMenuOption("Parts hit chance (this part or any child node)", delegate
         {
             StringBuilder stringBuilder13 = new StringBuilder();
             foreach (BodyPartRecord item2 in from x in pawn.RaceProps.body.AllParts
                      orderby x.coverageAbsWithChildren descending
                      select x)
             {
                 stringBuilder13.AppendLine(item2.LabelCap + " " + item2.coverageAbsWithChildren.ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder13.ToString()));
         }));
         list.Add(new FloatMenuOption("Parts hit chance (exactly this part)", delegate
         {
             StringBuilder stringBuilder12 = new StringBuilder();
             float num8 = 0f;
             foreach (BodyPartRecord item3 in from x in pawn.RaceProps.body.AllParts
                      orderby x.coverageAbs descending
                      select x)
             {
                 stringBuilder12.AppendLine(item3.LabelCap + " " + item3.coverageAbs.ToStringPercent());
                 num8 += item3.coverageAbs;
             }
             stringBuilder12.AppendLine();
             stringBuilder12.AppendLine("Total " + num8.ToStringPercent());
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder12.ToString()));
         }));
         list.Add(new FloatMenuOption("Per-part efficiency", delegate
         {
             StringBuilder stringBuilder11 = new StringBuilder();
             foreach (BodyPartRecord allPart in pawn.RaceProps.body.AllParts)
             {
                 stringBuilder11.AppendLine(allPart.LabelCap + " " + PawnCapacityUtility.CalculatePartEfficiency(pawn.health.hediffSet, allPart).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder11.ToString()));
         }));
         list.Add(new FloatMenuOption("BodyPartGroup efficiency (of only natural parts)", delegate
         {
             StringBuilder stringBuilder10 = new StringBuilder();
             foreach (BodyPartGroupDef item4 in from x in DefDatabase <BodyPartGroupDef> .AllDefs
                      where pawn.RaceProps.body.AllParts.Any((BodyPartRecord y) => y.groups.Contains(x))
                      select x)
             {
                 stringBuilder10.AppendLine(item4.LabelCap + " " + PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(pawn.health.hediffSet, item4).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder10.ToString()));
         }));
         list.Add(new FloatMenuOption("IsSolid", delegate
         {
             StringBuilder stringBuilder9 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart in pawn.health.hediffSet.GetNotMissingParts())
             {
                 stringBuilder9.AppendLine(notMissingPart.LabelCap + " " + notMissingPart.def.IsSolid(notMissingPart, pawn.health.hediffSet.hediffs));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder9.ToString()));
         }));
         list.Add(new FloatMenuOption("IsSkinCovered", delegate
         {
             StringBuilder stringBuilder8 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart2 in pawn.health.hediffSet.GetNotMissingParts())
             {
                 stringBuilder8.AppendLine(notMissingPart2.LabelCap + " " + notMissingPart2.def.IsSkinCovered(notMissingPart2, pawn.health.hediffSet));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder8.ToString()));
         }));
         list.Add(new FloatMenuOption("does have added parts", delegate
         {
             StringBuilder stringBuilder7 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart3 in pawn.health.hediffSet.GetNotMissingParts())
             {
                 stringBuilder7.AppendLine(notMissingPart3.LabelCap + " " + pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(notMissingPart3));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder7.ToString()));
         }));
         list.Add(new FloatMenuOption("GetNotMissingParts", delegate
         {
             StringBuilder stringBuilder6 = new StringBuilder();
             foreach (BodyPartRecord notMissingPart4 in pawn.health.hediffSet.GetNotMissingParts())
             {
                 stringBuilder6.AppendLine(notMissingPart4.LabelCap);
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder6.ToString()));
         }));
         list.Add(new FloatMenuOption("GetCoverageOfNotMissingNaturalParts", delegate
         {
             StringBuilder stringBuilder5 = new StringBuilder();
             foreach (BodyPartRecord item5 in from x in pawn.RaceProps.body.AllParts
                      orderby pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(x) descending
                      select x)
             {
                 stringBuilder5.AppendLine(item5.LabelCap + ": " + pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(item5).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder5.ToString()));
         }));
         list.Add(new FloatMenuOption("parts nutrition (assuming adult)", delegate
         {
             StringBuilder stringBuilder4 = new StringBuilder();
             float totalCorpseNutrition   = StatDefOf.Nutrition.Worker.GetValueAbstract(pawn.RaceProps.corpseDef);
             foreach (BodyPartRecord item6 in from x in pawn.RaceProps.body.AllParts
                      orderby FoodUtility.GetBodyPartNutrition(totalCorpseNutrition, pawn, x) descending
                      select x)
             {
                 stringBuilder4.AppendLine(item6.LabelCap + ": " + FoodUtility.GetBodyPartNutrition(totalCorpseNutrition, pawn, item6));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder4.ToString()));
         }));
         list.Add(new FloatMenuOption("test permanent injury pain factor probability", delegate
         {
             StringBuilder stringBuilder3 = new StringBuilder();
             int num2   = 0;
             int num3   = 0;
             int num4   = 0;
             float num5 = 0f;
             int num6   = 10000;
             for (int k = 0; k < num6; k++)
             {
                 float num7 = Mathf.Max(0f, Rand.ByCurve(HealthTuning.PermanentInjuryPainFactorRandomCurve));
                 if (num7 < 0f)
                 {
                     Log.Error("Pain factor < 0");
                 }
                 if (num7 == 0f)
                 {
                     num2++;
                 }
                 if (num7 < 1f)
                 {
                     num3++;
                 }
                 if (num7 < 5f)
                 {
                     num4++;
                 }
                 if (num7 > num5)
                 {
                     num5 = num7;
                 }
             }
             stringBuilder3.AppendLine("total: " + num6);
             stringBuilder3.AppendLine("0: " + num2 + " (" + ((float)num2 / (float)num6).ToStringPercent() + ")");
             stringBuilder3.AppendLine("< 1: " + num3 + " (" + ((float)num3 / (float)num6).ToStringPercent() + ")");
             stringBuilder3.AppendLine("< 5: " + num4 + " (" + ((float)num4 / (float)num6).ToStringPercent() + ")");
             stringBuilder3.AppendLine("max: " + num5);
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder3.ToString()));
         }));
         HediffGiver_Birthday hLocal;
         list.Add(new FloatMenuOption("HediffGiver_Birthday chance at age", delegate
         {
             List <FloatMenuOption> list2 = new List <FloatMenuOption>();
             foreach (HediffGiverSetDef hediffGiverSet in pawn.RaceProps.hediffGiverSets)
             {
                 foreach (HediffGiver_Birthday item7 in hediffGiverSet.hediffGivers.OfType <HediffGiver_Birthday>())
                 {
                     hLocal = item7;
                     FloatMenuOption item = new FloatMenuOption(hediffGiverSet.defName + " - " + item7.hediff.defName, delegate
                     {
                         StringBuilder stringBuilder2 = new StringBuilder();
                         stringBuilder2.AppendLine("% of pawns which will have at least 1 " + hLocal.hediff.label + " at age X:");
                         stringBuilder2.AppendLine();
                         for (int j = 1; (float)j < pawn.RaceProps.lifeExpectancy + 20f; j++)
                         {
                             stringBuilder2.AppendLine(j + ": " + hLocal.DebugChanceToHaveAtAge(pawn, j).ToStringPercent());
                         }
                         Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder2.ToString()));
                     });
                     list2.Add(item);
                 }
             }
             Find.WindowStack.Add(new FloatMenu(list2));
         }));
         list.Add(new FloatMenuOption("HediffGiver_Birthday count at age", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.AppendLine("Average hediffs count (from HediffGiver_Birthday) at age X:");
             stringBuilder.AppendLine();
             for (int i = 1; (float)i < pawn.RaceProps.lifeExpectancy + 20f; i++)
             {
                 float num = 0f;
                 foreach (HediffGiverSetDef hediffGiverSet2 in pawn.RaceProps.hediffGiverSets)
                 {
                     foreach (HediffGiver_Birthday item8 in hediffGiverSet2.hediffGivers.OfType <HediffGiver_Birthday>())
                     {
                         num += item8.DebugChanceToHaveAtAge(pawn, i);
                     }
                 }
                 stringBuilder.AppendLine(i + ": " + num.ToStringDecimalIfSmall());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString()));
         }));
         Find.WindowStack.Add(new FloatMenu(list));
     }
 }
Exemple #5
0
 private static void DoDebugOptions(Rect rightRect, Pawn pawn)
 {
     Widgets.CheckboxLabeled(new Rect(rightRect.x, rightRect.y - 25f, 110f, 30f), "Dev: AllDiffs", ref HealthCardUtility.showAllHediffs, false);
     Widgets.CheckboxLabeled(new Rect(rightRect.x + 115f, rightRect.y - 25f, 120f, 30f), "DiffsDebugInfo", ref HealthCardUtility.showHediffsDebugInfo, false);
     if (Widgets.ButtonText(new Rect(rightRect.x + 240f, rightRect.y - 27f, 115f, 25f), "Debug info", true, false, true))
     {
         List <FloatMenuOption> list = new List <FloatMenuOption>();
         list.Add(new FloatMenuOption("Parts hit chance (this part or any child node)", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in from x in pawn.RaceProps.body.AllParts
                      orderby x.coverageAbsWithChildren descending
                      select x)
             {
                 stringBuilder.AppendLine(current.def.LabelCap + " " + current.coverageAbsWithChildren.ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("Parts hit chance (exactly this part)", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             float num = 0f;
             foreach (BodyPartRecord current in from x in pawn.RaceProps.body.AllParts
                      orderby x.coverageAbs descending
                      select x)
             {
                 stringBuilder.AppendLine(current.def.LabelCap + " " + current.coverageAbs.ToStringPercent());
                 num += current.coverageAbs;
             }
             stringBuilder.AppendLine();
             stringBuilder.AppendLine("Total " + num.ToStringPercent());
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("Per-part efficiency", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in pawn.RaceProps.body.AllParts)
             {
                 stringBuilder.AppendLine(current.def.LabelCap + " " + PawnCapacityUtility.CalculatePartEfficiency(pawn.health.hediffSet, current, false, null).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("BodyPartGroup efficiency (of only natural parts)", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartGroupDef current in from x in DefDatabase <BodyPartGroupDef> .AllDefs
                      where pawn.RaceProps.body.AllParts.Any((BodyPartRecord y) => y.groups.Contains(x))
                      select x)
             {
                 stringBuilder.AppendLine(current.LabelCap + " " + PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(pawn.health.hediffSet, current).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("IsSolid", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder.AppendLine(current.def.LabelCap + " " + current.def.IsSolid(current, pawn.health.hediffSet.hediffs));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("IsSkinCovered", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder.AppendLine(current.def.LabelCap + " " + current.def.IsSkinCovered(current, pawn.health.hediffSet));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("does have added parts", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder.AppendLine(current.def.LabelCap + " " + pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(current));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("GetNotMissingParts", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined))
             {
                 stringBuilder.AppendLine(current.def.LabelCap);
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("GetCoverageOfNotMissingNaturalParts", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in from x in pawn.RaceProps.body.AllParts
                      orderby pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(x) descending
                      select x)
             {
                 stringBuilder.AppendLine(current.def.LabelCap + ": " + pawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(current).ToStringPercent());
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("parts nutrition", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (BodyPartRecord current in from x in pawn.RaceProps.body.AllParts
                      orderby FoodUtility.GetBodyPartNutrition(pawn, x) descending
                      select x)
             {
                 stringBuilder.AppendLine(current.def.LabelCap + ": " + FoodUtility.GetBodyPartNutrition(pawn, current));
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("test old injury pain factor probability", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             int num    = 0;
             int num2   = 0;
             int num3   = 0;
             float num4 = 0f;
             int num5   = 10000;
             for (int i = 0; i < num5; i++)
             {
                 float randomPainFactor = OldInjuryUtility.GetRandomPainFactor();
                 if (randomPainFactor < 0f)
                 {
                     Log.Error("Pain factor < 0");
                 }
                 if (randomPainFactor == 0f)
                 {
                     num++;
                 }
                 if (randomPainFactor < 1f)
                 {
                     num2++;
                 }
                 if (randomPainFactor < 5f)
                 {
                     num3++;
                 }
                 if (randomPainFactor > num4)
                 {
                     num4 = randomPainFactor;
                 }
             }
             stringBuilder.AppendLine("total: " + num5);
             stringBuilder.AppendLine(string.Concat(new object[]
             {
                 "0: ",
                 num,
                 " (",
                 ((float)num / (float)num5).ToStringPercent(),
                 ")"
             }));
             stringBuilder.AppendLine(string.Concat(new object[]
             {
                 "< 1: ",
                 num2,
                 " (",
                 ((float)num2 / (float)num5).ToStringPercent(),
                 ")"
             }));
             stringBuilder.AppendLine(string.Concat(new object[]
             {
                 "< 5: ",
                 num3,
                 " (",
                 ((float)num3 / (float)num5).ToStringPercent(),
                 ")"
             }));
             stringBuilder.AppendLine("max: " + num4);
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("HediffGiver_Birthday chance at age", delegate
         {
             List <FloatMenuOption> list2 = new List <FloatMenuOption>();
             foreach (HediffGiverSetDef current in pawn.RaceProps.hediffGiverSets)
             {
                 foreach (HediffGiver_Birthday current2 in current.hediffGivers.OfType <HediffGiver_Birthday>())
                 {
                     HediffGiver_Birthday hLocal = current2;
                     FloatMenuOption item        = new FloatMenuOption(current.defName + " - " + current2.hediff.defName, delegate
                     {
                         StringBuilder stringBuilder = new StringBuilder();
                         stringBuilder.AppendLine("% of pawns which will have at least 1 " + hLocal.hediff.label + " at age X:");
                         stringBuilder.AppendLine();
                         int num = 1;
                         while ((float)num < pawn.RaceProps.lifeExpectancy + 20f)
                         {
                             stringBuilder.AppendLine(num + ": " + hLocal.DebugChanceToHaveAtAge(pawn, num).ToStringPercent());
                             num++;
                         }
                         Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
                     }, MenuOptionPriority.Default, null, null, 0f, null, null);
                     list2.Add(item);
                 }
             }
             Find.WindowStack.Add(new FloatMenu(list2));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("HediffGiver_Birthday count at age", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.AppendLine("Average hediffs count (from HediffGiver_Birthday) at age X:");
             stringBuilder.AppendLine();
             int num = 1;
             while ((float)num < pawn.RaceProps.lifeExpectancy + 20f)
             {
                 float num2 = 0f;
                 foreach (HediffGiverSetDef current in pawn.RaceProps.hediffGiverSets)
                 {
                     foreach (HediffGiver_Birthday current2 in current.hediffGivers.OfType <HediffGiver_Birthday>())
                     {
                         num2 += current2.DebugChanceToHaveAtAge(pawn, num);
                     }
                 }
                 stringBuilder.AppendLine(num + ": " + num2.ToStringDecimalIfSmall());
                 num++;
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         Find.WindowStack.Add(new FloatMenu(list));
     }
 }