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)); }
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)); } }