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