示例#1
0
 private static void DrawDebugOptions(Rect rect, Pawn pawn)
 {
     GUI.BeginGroup(rect);
     Widgets.CheckboxLabeled(new Rect(0f, 0f, 145f, 22f), "Dev: AllRelations", ref SocialCardUtility.showAllRelations, false, null, null, false);
     if (Widgets.ButtonText(new Rect(150f, 0f, 115f, 22f), "Debug info", true, false, true))
     {
         List <FloatMenuOption> list = new List <FloatMenuOption>();
         list.Add(new FloatMenuOption("AttractionTo", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.AppendLine("My gender: " + pawn.gender);
             stringBuilder.AppendLine("My age: " + pawn.ageTracker.AgeBiologicalYears);
             stringBuilder.AppendLine();
             IOrderedEnumerable <Pawn> orderedEnumerable = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                           where x.def == pawn.def
                                                           orderby pawn.relations.SecondaryRomanceChanceFactor(x) descending
                                                           select x;
             foreach (Pawn current in orderedEnumerable)
             {
                 if (current != pawn)
                 {
                     stringBuilder.AppendLine(string.Concat(new object[]
                     {
                         current.LabelShort,
                         " (",
                         current.gender,
                         ", age: ",
                         current.ageTracker.AgeBiologicalYears,
                         ", compat: ",
                         pawn.relations.CompatibilityWith(current).ToString("F2"),
                         "): ",
                         pawn.relations.SecondaryRomanceChanceFactor(current).ToStringPercent("F0"),
                         "        [vs ",
                         current.relations.SecondaryRomanceChanceFactor(pawn).ToStringPercent("F0"),
                         "]"
                     }));
                 }
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false, null, null));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         list.Add(new FloatMenuOption("CompatibilityTo", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.AppendLine("My age: " + pawn.ageTracker.AgeBiologicalYears);
             stringBuilder.AppendLine();
             IOrderedEnumerable <Pawn> orderedEnumerable = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                           where x.def == pawn.def
                                                           orderby pawn.relations.CompatibilityWith(x) descending
                                                           select x;
             foreach (Pawn current in orderedEnumerable)
             {
                 if (current != pawn)
                 {
                     stringBuilder.AppendLine(string.Concat(new object[]
                     {
                         current.LabelShort,
                         " (",
                         current.KindLabel,
                         ", age: ",
                         current.ageTracker.AgeBiologicalYears,
                         "): ",
                         pawn.relations.CompatibilityWith(current).ToString("0.##")
                     }));
                 }
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false, null, null));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         if (pawn.RaceProps.Humanlike)
         {
             list.Add(new FloatMenuOption("Interaction chance", delegate
             {
                 StringBuilder stringBuilder = new StringBuilder();
                 stringBuilder.AppendLine("(selected pawn is the initiator)");
                 stringBuilder.AppendLine("(\"fight chance\" is the chance that the receiver will start social fight)");
                 stringBuilder.AppendLine("Interaction chance (real chance, not just weights):");
                 IOrderedEnumerable <Pawn> orderedEnumerable = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                               where x.RaceProps.Humanlike
                                                               orderby(x.Faction != null) ? x.Faction.loadID : -1
                                                               select x;
                 foreach (Pawn c in orderedEnumerable)
                 {
                     if (c != pawn)
                     {
                         stringBuilder.AppendLine();
                         stringBuilder.AppendLine(string.Concat(new object[]
                         {
                             c.LabelShort,
                             " (",
                             c.KindLabel,
                             ", ",
                             c.gender,
                             ", age: ",
                             c.ageTracker.AgeBiologicalYears,
                             ", compat: ",
                             pawn.relations.CompatibilityWith(c).ToString("F2"),
                             ", attr: ",
                             pawn.relations.SecondaryRomanceChanceFactor(c).ToStringPercent("F0"),
                             "):"
                         }));
                         List <InteractionDef> list2 = (from x in DefDatabase <InteractionDef> .AllDefs
                                                        where x.Worker.RandomSelectionWeight(pawn, c) > 0f
                                                        orderby x.Worker.RandomSelectionWeight(pawn, c) descending
                                                        select x).ToList <InteractionDef>();
                         float num = list2.Sum((InteractionDef x) => x.Worker.RandomSelectionWeight(pawn, c));
                         foreach (InteractionDef current in list2)
                         {
                             float f  = c.interactions.SocialFightChance(current, pawn);
                             float f2 = current.Worker.RandomSelectionWeight(pawn, c) / num;
                             stringBuilder.AppendLine(string.Concat(new string[]
                             {
                                 "  ",
                                 current.defName,
                                 ": ",
                                 f2.ToStringPercent(),
                                 " (fight chance: ",
                                 f.ToStringPercent("F2"),
                                 ")"
                             }));
                             if (current == InteractionDefOf.RomanceAttempt)
                             {
                                 stringBuilder.AppendLine("    success chance: " + ((InteractionWorker_RomanceAttempt)current.Worker).SuccessChance(pawn, c).ToStringPercent());
                             }
                             else if (current == InteractionDefOf.MarriageProposal)
                             {
                                 stringBuilder.AppendLine("    acceptance chance: " + ((InteractionWorker_MarriageProposal)current.Worker).AcceptanceChance(pawn, c).ToStringPercent());
                             }
                         }
                     }
                 }
                 Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false, null, null));
             }, MenuOptionPriority.Default, null, null, 0f, null, null));
             list.Add(new FloatMenuOption("Lovin' MTB", delegate
             {
                 StringBuilder stringBuilder = new StringBuilder();
                 stringBuilder.AppendLine("Lovin' MTB hours with pawn X.");
                 stringBuilder.AppendLine("Assuming both pawns are in bed and are partners.");
                 stringBuilder.AppendLine();
                 IOrderedEnumerable <Pawn> orderedEnumerable = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                               where x.def == pawn.def
                                                               orderby pawn.relations.SecondaryRomanceChanceFactor(x) descending
                                                               select x;
                 foreach (Pawn current in orderedEnumerable)
                 {
                     if (current != pawn)
                     {
                         stringBuilder.AppendLine(string.Concat(new object[]
                         {
                             current.LabelShort,
                             " (",
                             current.KindLabel,
                             ", age: ",
                             current.ageTracker.AgeBiologicalYears,
                             "): ",
                             LovePartnerRelationUtility.GetLovinMtbHours(pawn, current).ToString("F1"),
                             " h"
                         }));
                     }
                 }
                 Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false, null, null));
             }, MenuOptionPriority.Default, null, null, 0f, null, null));
         }
         list.Add(new FloatMenuOption("Test per pawns pair compatibility factor probability", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             int num     = 0;
             int num2    = 0;
             int num3    = 0;
             int num4    = 0;
             int num5    = 0;
             int num6    = 0;
             int num7    = 0;
             int num8    = 0;
             float num9  = -999999f;
             float num10 = 999999f;
             for (int i = 0; i < 10000; i++)
             {
                 int otherPawnID = Rand.RangeInclusive(0, 30000);
                 float num11     = pawn.relations.ConstantPerPawnsPairCompatibilityOffset(otherPawnID);
                 if (num11 < -3f)
                 {
                     num++;
                 }
                 else if (num11 < -2f)
                 {
                     num2++;
                 }
                 else if (num11 < -1f)
                 {
                     num3++;
                 }
                 else if (num11 < 0f)
                 {
                     num4++;
                 }
                 else if (num11 < 1f)
                 {
                     num5++;
                 }
                 else if (num11 < 2f)
                 {
                     num6++;
                 }
                 else if (num11 < 3f)
                 {
                     num7++;
                 }
                 else
                 {
                     num8++;
                 }
                 if (num11 > num9)
                 {
                     num9 = num11;
                 }
                 else if (num11 < num10)
                 {
                     num10 = num11;
                 }
             }
             stringBuilder.AppendLine("< -3: " + ((float)num / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< -2: " + ((float)num2 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< -1: " + ((float)num3 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 0: " + ((float)num4 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 1: " + ((float)num5 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 2: " + ((float)num6 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 3: " + ((float)num7 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("> 3: " + ((float)num8 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine();
             stringBuilder.AppendLine("trials: " + 10000);
             stringBuilder.AppendLine("min: " + num10);
             stringBuilder.AppendLine("max: " + num9);
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString(), null, null, null, null, null, false, null, null));
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
         Find.WindowStack.Add(new FloatMenu(list));
     }
     GUI.EndGroup();
 }
示例#2
0
 private static void DrawDebugOptions(Rect rect, Pawn pawn)
 {
     GUI.BeginGroup(rect);
     Widgets.CheckboxLabeled(new Rect(0f, 0f, 145f, 22f), "Dev: AllRelations", ref showAllRelations);
     if (Widgets.ButtonText(new Rect(150f, 0f, 115f, 22f), "Debug info"))
     {
         List <FloatMenuOption> list = new List <FloatMenuOption>();
         list.Add(new FloatMenuOption("AttractionTo", delegate
         {
             StringBuilder stringBuilder5 = new StringBuilder();
             stringBuilder5.AppendLine("My gender: " + pawn.gender);
             stringBuilder5.AppendLine("My age: " + pawn.ageTracker.AgeBiologicalYears);
             stringBuilder5.AppendLine();
             IOrderedEnumerable <Pawn> orderedEnumerable4 = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                            where x.def == pawn.def
                                                            orderby pawn.relations.SecondaryRomanceChanceFactor(x) descending
                                                            select x;
             foreach (Pawn item in orderedEnumerable4)
             {
                 if (item != pawn)
                 {
                     stringBuilder5.AppendLine(item.LabelShort + " (" + item.gender + ", age: " + item.ageTracker.AgeBiologicalYears + ", compat: " + pawn.relations.CompatibilityWith(item).ToString("F2") + "): " + pawn.relations.SecondaryRomanceChanceFactor(item).ToStringPercent("F0") + "        [vs " + item.relations.SecondaryRomanceChanceFactor(pawn).ToStringPercent("F0") + "]");
                 }
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder5.ToString()));
         }));
         list.Add(new FloatMenuOption("CompatibilityTo", delegate
         {
             StringBuilder stringBuilder4 = new StringBuilder();
             stringBuilder4.AppendLine("My age: " + pawn.ageTracker.AgeBiologicalYears);
             stringBuilder4.AppendLine();
             IOrderedEnumerable <Pawn> orderedEnumerable3 = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                            where x.def == pawn.def
                                                            orderby pawn.relations.CompatibilityWith(x) descending
                                                            select x;
             foreach (Pawn item2 in orderedEnumerable3)
             {
                 if (item2 != pawn)
                 {
                     stringBuilder4.AppendLine(item2.LabelShort + " (" + item2.KindLabel + ", age: " + item2.ageTracker.AgeBiologicalYears + "): " + pawn.relations.CompatibilityWith(item2).ToString("0.##"));
                 }
             }
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder4.ToString()));
         }));
         if (pawn.RaceProps.Humanlike)
         {
             list.Add(new FloatMenuOption("Interaction chance", delegate
             {
                 StringBuilder stringBuilder3 = new StringBuilder();
                 stringBuilder3.AppendLine("(selected pawn is the initiator)");
                 stringBuilder3.AppendLine("(\"fight chance\" is the chance that the receiver will start social fight)");
                 stringBuilder3.AppendLine("Interaction chance (real chance, not just weights):");
                 IOrderedEnumerable <Pawn> orderedEnumerable2 = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                                where x.RaceProps.Humanlike
                                                                orderby(x.Faction != null) ? x.Faction.loadID : (-1)
                                                                select x;
                 foreach (Pawn item3 in orderedEnumerable2)
                 {
                     if (item3 != pawn)
                     {
                         stringBuilder3.AppendLine();
                         stringBuilder3.AppendLine(item3.LabelShort + " (" + item3.KindLabel + ", " + item3.gender + ", age: " + item3.ageTracker.AgeBiologicalYears + ", compat: " + pawn.relations.CompatibilityWith(item3).ToString("F2") + ", attr: " + pawn.relations.SecondaryRomanceChanceFactor(item3).ToStringPercent("F0") + "):");
                         List <InteractionDef> list2 = (from x in DefDatabase <InteractionDef> .AllDefs
                                                        where x.Worker.RandomSelectionWeight(pawn, item3) > 0f
                                                        orderby x.Worker.RandomSelectionWeight(pawn, item3) descending
                                                        select x).ToList();
                         float num12 = list2.Sum((InteractionDef x) => x.Worker.RandomSelectionWeight(pawn, item3));
                         foreach (InteractionDef item4 in list2)
                         {
                             float f  = item3.interactions.SocialFightChance(item4, pawn);
                             float f2 = item4.Worker.RandomSelectionWeight(pawn, item3) / num12;
                             stringBuilder3.AppendLine("  " + item4.defName + ": " + f2.ToStringPercent() + " (fight chance: " + f.ToStringPercent("F2") + ")");
                             if (item4 == InteractionDefOf.RomanceAttempt)
                             {
                                 stringBuilder3.AppendLine("    success chance: " + ((InteractionWorker_RomanceAttempt)item4.Worker).SuccessChance(pawn, item3).ToStringPercent());
                             }
                             else if (item4 == InteractionDefOf.MarriageProposal)
                             {
                                 stringBuilder3.AppendLine("    acceptance chance: " + ((InteractionWorker_MarriageProposal)item4.Worker).AcceptanceChance(pawn, item3).ToStringPercent());
                             }
                         }
                     }
                 }
                 Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder3.ToString()));
             }));
             list.Add(new FloatMenuOption("Lovin' MTB", delegate
             {
                 StringBuilder stringBuilder2 = new StringBuilder();
                 stringBuilder2.AppendLine("Lovin' MTB hours with pawn X.");
                 stringBuilder2.AppendLine("Assuming both pawns are in bed and are partners.");
                 stringBuilder2.AppendLine();
                 IOrderedEnumerable <Pawn> orderedEnumerable = from x in pawn.Map.mapPawns.AllPawnsSpawned
                                                               where x.def == pawn.def
                                                               orderby pawn.relations.SecondaryRomanceChanceFactor(x) descending
                                                               select x;
                 foreach (Pawn item5 in orderedEnumerable)
                 {
                     if (item5 != pawn)
                     {
                         stringBuilder2.AppendLine(item5.LabelShort + " (" + item5.KindLabel + ", age: " + item5.ageTracker.AgeBiologicalYears + "): " + LovePartnerRelationUtility.GetLovinMtbHours(pawn, item5).ToString("F1") + " h");
                     }
                 }
                 Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder2.ToString()));
             }));
         }
         list.Add(new FloatMenuOption("Test per pawns pair compatibility factor probability", delegate
         {
             StringBuilder stringBuilder = new StringBuilder();
             int num     = 0;
             int num2    = 0;
             int num3    = 0;
             int num4    = 0;
             int num5    = 0;
             int num6    = 0;
             int num7    = 0;
             int num8    = 0;
             float num9  = -999999f;
             float num10 = 999999f;
             for (int i = 0; i < 10000; i++)
             {
                 int otherPawnID = Rand.RangeInclusive(0, 30000);
                 float num11     = pawn.relations.ConstantPerPawnsPairCompatibilityOffset(otherPawnID);
                 if (num11 < -3f)
                 {
                     num++;
                 }
                 else if (num11 < -2f)
                 {
                     num2++;
                 }
                 else if (num11 < -1f)
                 {
                     num3++;
                 }
                 else if (num11 < 0f)
                 {
                     num4++;
                 }
                 else if (num11 < 1f)
                 {
                     num5++;
                 }
                 else if (num11 < 2f)
                 {
                     num6++;
                 }
                 else if (num11 < 3f)
                 {
                     num7++;
                 }
                 else
                 {
                     num8++;
                 }
                 if (num11 > num9)
                 {
                     num9 = num11;
                 }
                 else if (num11 < num10)
                 {
                     num10 = num11;
                 }
             }
             stringBuilder.AppendLine("< -3: " + ((float)num / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< -2: " + ((float)num2 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< -1: " + ((float)num3 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 0: " + ((float)num4 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 1: " + ((float)num5 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 2: " + ((float)num6 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("< 3: " + ((float)num7 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine("> 3: " + ((float)num8 / 10000f).ToStringPercent("F2"));
             stringBuilder.AppendLine();
             stringBuilder.AppendLine("trials: " + 10000);
             stringBuilder.AppendLine("min: " + num10);
             stringBuilder.AppendLine("max: " + num9);
             Find.WindowStack.Add(new Dialog_MessageBox(stringBuilder.ToString()));
         }));
         Find.WindowStack.Add(new FloatMenu(list));
     }
     GUI.EndGroup();
 }