Example #1
0
        private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts, Pawn forPawn)
        {
            List <FloatMenuOption> list = null;
            Vector3 vector = new Vector3(-9999f, -9999f, -9999f);

            return(FloatMenuMap.StillValid(opt, curOpts, forPawn, ref list, ref vector));
        }
        public static void MakeAllowedAreaListFloatMenu(Action <Area> selAction, bool addNullAreaOption, bool addManageOption, Map map)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            if (addNullAreaOption)
            {
                list.Add(new FloatMenuOption("NoAreaAllowed".Translate(), delegate()
                {
                    selAction(null);
                }, MenuOptionPriority.High, null, null, 0f, null, null));
            }
            foreach (Area localArea2 in from a in map.areaManager.AllAreas
                     where a.AssignableAsAllowed()
                     select a)
            {
                Area            localArea = localArea2;
                FloatMenuOption item      = new FloatMenuOption(localArea.Label, delegate()
                {
                    selAction(localArea);
                }, MenuOptionPriority.Default, delegate()
                {
                    localArea.MarkForDraw();
                }, null, 0f, null, null);
                list.Add(item);
            }
            if (addManageOption)
            {
                list.Add(new FloatMenuOption("ManageAreas".Translate(), delegate()
                {
                    Find.WindowStack.Add(new Dialog_ManageAreas(map));
                }, MenuOptionPriority.Low, null, null, 0f, null, null));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
        public static void ThingsExistingList()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (ThingRequestGroup localRg2 in Enum.GetValues(typeof(ThingRequestGroup)))
            {
                ThingRequestGroup localRg = localRg2;
                FloatMenuOption   item    = new FloatMenuOption(localRg.ToString(), delegate
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    List <Thing> list2          = Find.CurrentMap.listerThings.ThingsInGroup(localRg);
                    stringBuilder.AppendLine(string.Concat(new object[]
                    {
                        "Global things in group ",
                        localRg,
                        " (count ",
                        list2.Count,
                        ")"
                    }));
                    Log.Message(DebugLogsUtility.ThingListToUniqueCountString(list2), false);
                }, MenuOptionPriority.Default, null, null, 0f, null, null);
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #4
0
 private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts)
 {
     if (opt.revalidateClickTarget == null)
     {
         for (int i = 0; i < curOpts.Count; i++)
         {
             if (FloatMenuMap.OptionsMatch(opt, curOpts[i]))
             {
                 return(true);
             }
         }
     }
     else
     {
         if (!opt.revalidateClickTarget.Spawned)
         {
             return(false);
         }
         List <FloatMenuOption> list = FloatMenuMakerMap.ChoicesAtFor(opt.revalidateClickTarget.Position.ToVector3Shifted(), Find.Selector.SingleSelectedThing as Pawn);
         for (int j = 0; j < list.Count; j++)
         {
             if (FloatMenuMap.OptionsMatch(opt, list[j]))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #5
0
        private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts, Caravan forCaravan)
        {
            List <FloatMenuOption> cachedChoices = null;
            Vector2 cachedChoicesForPos          = new Vector2(-9999f, -9999f);

            return(StillValid(opt, curOpts, forCaravan, ref cachedChoices, ref cachedChoicesForPos));
        }
Example #6
0
 private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts)
 {
     if (opt.revalidateWorldClickTarget == null)
     {
         for (int i = 0; i < curOpts.Count; i++)
         {
             if (FloatMenuWorld.OptionsMatch(opt, curOpts[i]))
             {
                 return(true);
             }
         }
     }
     else
     {
         if (!opt.revalidateWorldClickTarget.Spawned)
         {
             return(false);
         }
         Vector2 mousePos = opt.revalidateWorldClickTarget.ScreenPos();
         mousePos.y = (float)UI.screenHeight - mousePos.y;
         List <FloatMenuOption> list = FloatMenuMakerWorld.ChoicesAtFor(mousePos, (Caravan)Find.WorldSelector.SingleSelectedObject);
         for (int j = 0; j < list.Count; j++)
         {
             if (FloatMenuWorld.OptionsMatch(opt, list[j]))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts, Pawn forPawn)
 {
     if (opt.revalidateClickTarget == null)
     {
         for (int i = 0; i < curOpts.Count; i++)
         {
             if (OptionsMatch(opt, curOpts[i]))
             {
                 return(true);
             }
         }
     }
     else
     {
         if (!opt.revalidateClickTarget.Spawned)
         {
             return(false);
         }
         Vector3 key = opt.revalidateClickTarget.Position.ToVector3Shifted();
         if (!cachedChoices.TryGetValue(key, out var value))
         {
             List <FloatMenuOption> list = FloatMenuMakerMap.ChoicesAtFor(key, forPawn);
             cachedChoices.Add(key, list);
             value = list;
         }
         for (int j = 0; j < value.Count; j++)
         {
             if (OptionsMatch(opt, value[j]))
             {
                 return(!value[j].Disabled);
             }
         }
     }
     return(false);
 }
Example #8
0
        public static void ThingsExistingList()
        {
            List <FloatMenuOption> list       = new List <FloatMenuOption>();
            IEnumerator            enumerator = Enum.GetValues(typeof(ThingRequestGroup)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ThingRequestGroup thingRequestGroup = (ThingRequestGroup)enumerator.Current;
                    ThingRequestGroup localRg           = thingRequestGroup;
                    FloatMenuOption   item = new FloatMenuOption(localRg.ToString(), delegate
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        List <Thing> list2          = Find.CurrentMap.listerThings.ThingsInGroup(localRg);
                        stringBuilder.AppendLine("Global things in group " + localRg + " (count " + list2.Count + ")");
                        Log.Message(DebugLogsUtility.ThingListToUniqueCountString(list2));
                    });
                    list.Add(item);
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn)
        {
            using (IEnumerator <FloatMenuOption> enumerator = base.GetFloatMenuOptions(selPawn).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    FloatMenuOption o2 = enumerator.Current;
                    yield return(o2);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (this.comps != null)
            {
                for (int i = 0; i < this.comps.Count; i++)
                {
                    using (IEnumerator <FloatMenuOption> enumerator2 = this.comps[i].CompFloatMenuOptions(selPawn).GetEnumerator())
                    {
                        if (enumerator2.MoveNext())
                        {
                            FloatMenuOption o = enumerator2.Current;
                            yield return(o);

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
            }
            yield break;
IL_01ab:
            /*Error near IL_01ac: Unexpected return in MoveNext()*/;
        }
Example #10
0
        public static void NamesFromRulepack()
        {
            IEnumerable <RulePackDef> first = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.factionNameMaker);

            IEnumerable <RulePackDef> second = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.settlementNameMaker);

            IEnumerable <RulePackDef> second2 = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.playerInitialSettlementNameMaker);

            IEnumerable <RulePackDef> second3 = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.pawnNameMaker);

            IOrderedEnumerable <RulePackDef> orderedEnumerable = from d in (from d in Enumerable.Concat(second: DefDatabase <RulePackDef> .AllDefsListForReading.Where((RulePackDef d) => d.defName.Contains("Namer")), first: first.Concat(second).Concat(second2).Concat(second3))
                                                                            where d != null
                                                                            select d).Distinct()
                                                                 orderby d.defName
                                                                 select d;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (RulePackDef item2 in orderedEnumerable)
            {
                RulePackDef     localNamer = item2;
                FloatMenuOption item       = new FloatMenuOption(localNamer.defName, delegate
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Testing RulePack " + localNamer.defName + " as a name generator:");
                    for (int i = 0; i < 200; i++)
                    {
                        string testPawnNameSymbol = (i % 2 == 0) ? "Smithee" : null;
                        stringBuilder.AppendLine(NameGenerator.GenerateName(localNamer, null, appendNumberIfNameUsed: false, localNamer.FirstRuleKeyword, testPawnNameSymbol));
                    }
                    Log.Message(stringBuilder.ToString());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #11
0
        private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts, Caravan forCaravan)
        {
            List <FloatMenuOption> list = null;
            Vector2 vector = new Vector2(-9999f, -9999f);

            return(FloatMenuWorld.StillValid(opt, curOpts, forCaravan, ref list, ref vector));
        }
Example #12
0
 private static bool OptionsMatch(FloatMenuOption a, FloatMenuOption b)
 {
     if (a.Label == b.Label)
     {
         return(true);
     }
     return(false);
 }
Example #13
0
        public override void PreOptionChosen(FloatMenuOption opt)
        {
            base.PreOptionChosen(opt);
            Pawn pawn = Find.Selector.SingleSelectedThing as Pawn;

            if (!opt.Disabled && (pawn == null || !FloatMenuMap.StillValid(opt, FloatMenuMakerMap.ChoicesAtFor(this.clickPos, pawn), pawn)))
            {
                opt.Disabled = true;
            }
        }
Example #14
0
        public override void PreOptionChosen(FloatMenuOption opt)
        {
            base.PreOptionChosen(opt);
            Caravan caravan = Find.WorldSelector.SingleSelectedObject as Caravan;

            if (!opt.Disabled && (caravan == null || !FloatMenuWorld.StillValid(opt, FloatMenuMakerWorld.ChoicesAtFor(this.clickPos, caravan), caravan)))
            {
                opt.Disabled = true;
            }
        }
Example #15
0
 public override void DoWindowContents(Rect rect)
 {
     if (this.needSelection && Find.Selector.SingleSelectedThing == null)
     {
         Find.WindowStack.TryRemove(this, true);
     }
     else
     {
         this.UpdateBaseColor();
         bool usingScrollbar = this.UsingScrollbar;
         GUI.color = this.baseColor;
         Text.Font = GameFont.Small;
         Vector2 zero          = Vector2.zero;
         float   maxViewHeight = this.MaxViewHeight;
         float   columnWidth   = this.ColumnWidth;
         if (usingScrollbar)
         {
             rect.width -= 10f;
             Widgets.BeginScrollView(rect, ref this.scrollPosition, new Rect(0f, 0f, this.TotalWidth - 16f, this.TotalViewHeight), true);
         }
         for (int i = 0; i < this.options.Count; i++)
         {
             FloatMenuOption floatMenuOption = this.options[i];
             float           requiredHeight  = floatMenuOption.RequiredHeight;
             if (zero.y + requiredHeight + -1f > maxViewHeight)
             {
                 zero.y  = 0f;
                 zero.x += columnWidth + -1f;
             }
             Rect rect2 = new Rect(zero.x, zero.y, columnWidth, requiredHeight);
             zero.y += requiredHeight + -1f;
             bool flag = floatMenuOption.DoGUI(rect2, this.givesColonistOrders, this);
             if (flag)
             {
                 Find.WindowStack.TryRemove(this, true);
                 break;
             }
         }
         if (usingScrollbar)
         {
             Widgets.EndScrollView();
         }
         if (Event.current.type == EventType.MouseDown)
         {
             Event.current.Use();
             this.Close(true);
         }
         GUI.color = Color.white;
     }
 }
Example #16
0
        public static void ArtDescsSpecificTale()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (TaleDef item2 in DefDatabase <TaleDef> .AllDefs.OrderBy((TaleDef def) => def.defName))
            {
                TaleDef         localDef = item2;
                FloatMenuOption item     = new FloatMenuOption(localDef.defName, delegate
                {
                    LogSpecificTale(localDef, 40);
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #17
0
        public static void TraderStockGeneration()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (TraderKindDef current in DefDatabase <TraderKindDef> .AllDefs)
            {
                TraderKindDef   localDef = current;
                FloatMenuOption item     = new FloatMenuOption(localDef.defName, delegate
                {
                    Log.Message(((ThingSetMaker_TraderStock)ThingSetMakerDefOf.TraderStock.root).GenerationDataFor(localDef), false);
                }, MenuOptionPriority.Default, null, null, 0f, null, null);
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
        public static void TraderStockGeneration()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (TraderKindDef allDef in DefDatabase <TraderKindDef> .AllDefs)
            {
                TraderKindDef   localDef = allDef;
                FloatMenuOption item     = new FloatMenuOption(localDef.defName, delegate
                {
                    Log.Message(((ThingSetMaker_TraderStock)ThingSetMakerDefOf.TraderStock.root).DebugGenerationDataFor(localDef));
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #19
0
        private void OpenPackageEditor()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();
            FloatMenuOption        item = new FloatMenuOption("SoundDefs", delegate
            {
                Find.WindowStack.Add(new EditWindow_PackageEditor <SoundDef>("SoundDefs"));
            });

            list.Add(item);
            item = new FloatMenuOption("HairDefs", delegate
            {
                Find.WindowStack.Add(new EditWindow_PackageEditor <HairDef>("HairDefs"));
            });
            list.Add(item);
            Find.WindowStack.Add(new FloatMenu(list));
        }
        public static void PawnWorkDisablesSampled()
        {
            IOrderedEnumerable <PawnKindDef> orderedEnumerable = from k in DefDatabase <PawnKindDef> .AllDefs
                                                                 where k.RaceProps.Humanlike
                                                                 orderby k.combatPower
                                                                 select k;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (PawnKindDef item2 in orderedEnumerable)
            {
                PawnKindDef     kind = item2;
                Faction         fac  = FactionUtility.DefaultFactionFrom(kind.defaultFactionType);
                FloatMenuOption item = new FloatMenuOption(kind.defName + " (" + kind.combatPower + ")", delegate
                {
                    Dictionary <WorkTags, int> dictionary = new Dictionary <WorkTags, int>();
                    for (int i = 0; i < 1000; i++)
                    {
                        Pawn pawn = PawnGenerator.GeneratePawn(kind, fac);
                        WorkTags combinedDisabledWorkTags = pawn.CombinedDisabledWorkTags;
                        foreach (WorkTags value in Enum.GetValues(typeof(WorkTags)))
                        {
                            if (!dictionary.ContainsKey(value))
                            {
                                dictionary.Add(value, 0);
                            }
                            if ((combinedDisabledWorkTags & value) != 0)
                            {
                                dictionary[value]++;
                            }
                        }
                        pawn.Destroy();
                    }
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Sampled " + 1000 + "x " + kind.defName + ":");
                    stringBuilder.AppendLine("Worktags disabled");
                    foreach (WorkTags value2 in Enum.GetValues(typeof(WorkTags)))
                    {
                        int num = dictionary[value2];
                        stringBuilder.AppendLine("  " + value2.ToString() + "    " + num + " (" + ((float)num / 1000f).ToStringPercent() + ")");
                    }
                    Log.Message(stringBuilder.ToString().TrimEndNewlines());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #21
0
        public static void RecruitDifficultiesSampled()
        {
            IOrderedEnumerable <PawnKindDef> orderedEnumerable = from k in DefDatabase <PawnKindDef> .AllDefs
                                                                 where k.RaceProps.Humanlike
                                                                 orderby k.combatPower
                                                                 select k;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (PawnKindDef item2 in orderedEnumerable)
            {
                PawnKindDef kind = item2;
                Faction     fac  = FactionUtility.DefaultFactionFrom(kind.defaultFactionType);
                if (kind == PawnKindDefOf.WildMan)
                {
                    fac = null;
                }
                FloatMenuOption item = new FloatMenuOption(kind.defName + " (" + kind.baseRecruitDifficulty.ToStringPercent() + ")", delegate
                {
                    Dictionary <int, int> dictionary = new Dictionary <int, int>();
                    for (int i = 0; i < 21; i++)
                    {
                        dictionary.Add(i, 0);
                    }
                    for (int j = 0; j < 300; j++)
                    {
                        Pawn pawn = PawnGenerator.GeneratePawn(kind, fac);
                        float num = pawn.RecruitDifficulty(Faction.OfPlayer);
                        int num2  = Mathf.RoundToInt(num * 20f);
                        Dictionary <int, int> dictionary2;
                        int key;
                        (dictionary2 = dictionary)[key = num2] = dictionary2[key] + 1;
                        pawn.Destroy();
                    }
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Sampled " + 300 + "x " + kind.defName + ":");
                    for (int l = 0; l < 21; l++)
                    {
                        int num3 = dictionary[l];
                        stringBuilder.AppendLine("  " + (l * 5).ToString() + "    " + num3 + " (" + ((float)num3 / 300f).ToStringPercent() + ")");
                    }
                    Log.Message(stringBuilder.ToString().TrimEndNewlines());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
        public static void ThingsExistingList()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (ThingRequestGroup value in Enum.GetValues(typeof(ThingRequestGroup)))
            {
                ThingRequestGroup localRg = value;
                FloatMenuOption   item    = new FloatMenuOption(localRg.ToString(), delegate
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    List <Thing> list2          = Find.CurrentMap.listerThings.ThingsInGroup(localRg);
                    stringBuilder.AppendLine("Global things in group " + localRg + " (count " + list2.Count + ")");
                    Log.Message(DebugLogsUtility.ThingListToUniqueCountString(list2));
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #23
0
        private static void SetFactionRelations()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (Faction item2 in Find.FactionManager.AllFactionsVisibleInViewOrder)
            {
                Faction localFac = item2;
                foreach (FactionRelationKind value in Enum.GetValues(typeof(FactionRelationKind)))
                {
                    FactionRelationKind localRk = value;
                    FloatMenuOption     item    = new FloatMenuOption(string.Concat(localFac, " - ", localRk), delegate
                    {
                        localFac.TrySetRelationKind(Faction.OfPlayer, localRk);
                    });
                    list.Add(item);
                }
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #24
0
        public static void NamesFromRulepack()
        {
            IEnumerable <RulePackDef> first = from f in DefDatabase <FactionDef> .AllDefsListForReading
                                              select f.factionNameMaker;
            IEnumerable <RulePackDef> second = from f in DefDatabase <FactionDef> .AllDefsListForReading
                                               select f.settlementNameMaker;
            IEnumerable <RulePackDef> second2 = from f in DefDatabase <FactionDef> .AllDefsListForReading
                                                select f.playerInitialSettlementNameMaker;
            IEnumerable <RulePackDef> second3 = from f in DefDatabase <FactionDef> .AllDefsListForReading
                                                select f.pawnNameMaker;
            IEnumerable <RulePackDef> second4 = from d in DefDatabase <RulePackDef> .AllDefsListForReading
                                                where d.defName.Contains("Namer")
                                                select d;
            IOrderedEnumerable <RulePackDef> orderedEnumerable = from d in (from d in first.Concat(second).Concat(second2).Concat(second3)
                                                                            .Concat(second4)
                                                                            where d != null
                                                                            select d).Distinct()
                                                                 orderby d.defName
                                                                 select d;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (RulePackDef item2 in orderedEnumerable)
            {
                RulePackDef     localNamer = item2;
                FloatMenuOption item       = new FloatMenuOption(localNamer.defName, delegate
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Testing RulePack " + localNamer.defName + " as  a name generator:");
                    for (int i = 0; i < 200; i++)
                    {
                        string text = (i % 2 != 0) ? null : "Smithee";
                        StringBuilder stringBuilder2 = stringBuilder;
                        RulePackDef rootPack         = localNamer;
                        string testPawnNameSymbol    = text;
                        stringBuilder2.AppendLine(NameGenerator.GenerateName(rootPack, null, appendNumberIfNameUsed: false, null, testPawnNameSymbol));
                    }
                    Log.Message(stringBuilder.ToString());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #25
0
 private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts, Caravan forCaravan, ref List <FloatMenuOption> cachedChoices, ref Vector2 cachedChoicesForPos)
 {
     if (opt.revalidateWorldClickTarget == null)
     {
         for (int i = 0; i < curOpts.Count; i++)
         {
             if (FloatMenuWorld.OptionsMatch(opt, curOpts[i]))
             {
                 return(true);
             }
         }
     }
     else
     {
         if (!opt.revalidateWorldClickTarget.Spawned)
         {
             return(false);
         }
         Vector2 vector = opt.revalidateWorldClickTarget.ScreenPos();
         vector.y = (float)UI.screenHeight - vector.y;
         List <FloatMenuOption> list;
         if (vector == cachedChoicesForPos)
         {
             list = cachedChoices;
         }
         else
         {
             cachedChoices       = FloatMenuMakerWorld.ChoicesAtFor(vector, forCaravan);
             cachedChoicesForPos = vector;
             list = cachedChoices;
         }
         for (int j = 0; j < list.Count; j++)
         {
             if (FloatMenuWorld.OptionsMatch(opt, list[j]))
             {
                 return(!list[j].Disabled);
             }
         }
     }
     return(false);
 }
Example #26
0
 private static bool StillValid(FloatMenuOption opt, List <FloatMenuOption> curOpts, Pawn forPawn, ref List <FloatMenuOption> cachedChoices, ref Vector3 cachedChoicesForPos)
 {
     if (opt.revalidateClickTarget == null)
     {
         for (int i = 0; i < curOpts.Count; i++)
         {
             if (FloatMenuMap.OptionsMatch(opt, curOpts[i]))
             {
                 return(true);
             }
         }
     }
     else
     {
         if (!opt.revalidateClickTarget.Spawned)
         {
             return(false);
         }
         Vector3 vector = opt.revalidateClickTarget.Position.ToVector3Shifted();
         List <FloatMenuOption> list;
         if (vector == cachedChoicesForPos)
         {
             list = cachedChoices;
         }
         else
         {
             cachedChoices       = FloatMenuMakerMap.ChoicesAtFor(vector, forPawn);
             cachedChoicesForPos = vector;
             list = cachedChoices;
         }
         for (int j = 0; j < list.Count; j++)
         {
             if (FloatMenuMap.OptionsMatch(opt, list[j]))
             {
                 return(!list[j].Disabled);
             }
         }
     }
     return(false);
 }
Example #27
0
        public static void ListSolidBackstories()
        {
            IEnumerable <string>   enumerable = SolidBioDatabase.allBios.SelectMany((PawnBio bio) => bio.adulthood.spawnCategories).Distinct();
            List <FloatMenuOption> list       = new List <FloatMenuOption>();

            foreach (string item2 in enumerable)
            {
                string          catInner = item2;
                FloatMenuOption item     = new FloatMenuOption(catInner, delegate
                {
                    IEnumerable <PawnBio> enumerable2 = SolidBioDatabase.allBios.Where((PawnBio b) => b.adulthood.spawnCategories.Contains(catInner));
                    StringBuilder stringBuilder       = new StringBuilder();
                    stringBuilder.AppendLine("Backstories with category: " + catInner + " (" + enumerable2.Count() + ")");
                    foreach (PawnBio item3 in enumerable2)
                    {
                        stringBuilder.AppendLine(item3.ToString());
                    }
                    Log.Message(stringBuilder.ToString());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #28
0
        public static void PawnWorkDisablesSampled()
        {
            IOrderedEnumerable <PawnKindDef> orderedEnumerable = from k in DefDatabase <PawnKindDef> .AllDefs
                                                                 where k.RaceProps.Humanlike
                                                                 orderby k.combatPower
                                                                 select k;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (PawnKindDef item2 in orderedEnumerable)
            {
                PawnKindDef     kind = item2;
                Faction         fac  = FactionUtility.DefaultFactionFrom(kind.defaultFactionType);
                FloatMenuOption item = new FloatMenuOption(kind.defName + " (" + kind.combatPower + ")", delegate
                {
                    Dictionary <WorkTags, int> dictionary = new Dictionary <WorkTags, int>();
                    for (int i = 0; i < 1000; i++)
                    {
                        Pawn pawn = PawnGenerator.GeneratePawn(kind, fac);
                        WorkTags combinedDisabledWorkTags = pawn.story.CombinedDisabledWorkTags;
                        IEnumerator enumerator2           = Enum.GetValues(typeof(WorkTags)).GetEnumerator();
                        try
                        {
                            while (enumerator2.MoveNext())
                            {
                                WorkTags workTags = (WorkTags)enumerator2.Current;
                                if (!dictionary.ContainsKey(workTags))
                                {
                                    dictionary.Add(workTags, 0);
                                }
                                if ((combinedDisabledWorkTags & workTags) != 0)
                                {
                                    Dictionary <WorkTags, int> dictionary2;
                                    WorkTags key;
                                    (dictionary2 = dictionary)[key = workTags] = dictionary2[key] + 1;
                                }
                            }
                        }
                        finally
                        {
                            IDisposable disposable;
                            if ((disposable = (enumerator2 as IDisposable)) != null)
                            {
                                disposable.Dispose();
                            }
                        }
                        pawn.Destroy();
                    }
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Sampled " + 1000 + "x " + kind.defName + ":");
                    stringBuilder.AppendLine("Worktags disabled");
                    IEnumerator enumerator3 = Enum.GetValues(typeof(WorkTags)).GetEnumerator();
                    try
                    {
                        while (enumerator3.MoveNext())
                        {
                            WorkTags key2 = (WorkTags)enumerator3.Current;
                            int num       = dictionary[key2];
                            stringBuilder.AppendLine("  " + key2.ToString() + "    " + num + " (" + ((float)num / 1000f).ToStringPercent() + ")");
                        }
                    }
                    finally
                    {
                        IDisposable disposable2;
                        if ((disposable2 = (enumerator3 as IDisposable)) != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                    Log.Message(stringBuilder.ToString().TrimEndNewlines());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #29
0
        public static void PawnKindGearSampled()
        {
            IOrderedEnumerable <PawnKindDef> orderedEnumerable = from k in DefDatabase <PawnKindDef> .AllDefs
                                                                 where k.RaceProps.ToolUser
                                                                 orderby k.combatPower
                                                                 select k;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (PawnKindDef item2 in orderedEnumerable)
            {
                Faction         fac  = FactionUtility.DefaultFactionFrom(item2.defaultFactionType);
                PawnKindDef     kind = item2;
                FloatMenuOption item = new FloatMenuOption(kind.defName + " (" + kind.combatPower + ")", delegate
                {
                    DefMap <ThingDef, int> weapons  = new DefMap <ThingDef, int>();
                    DefMap <ThingDef, int> apparel  = new DefMap <ThingDef, int>();
                    DefMap <HediffDef, int> hediffs = new DefMap <HediffDef, int>();
                    for (int i = 0; i < 400; i++)
                    {
                        Pawn pawn = PawnGenerator.GeneratePawn(kind, fac);
                        if (pawn.equipment.Primary != null)
                        {
                            DefMap <ThingDef, int> defMap;
                            ThingDef def;
                            (defMap = weapons)[def = pawn.equipment.Primary.def] = defMap[def] + 1;
                        }
                        foreach (Hediff hediff in pawn.health.hediffSet.hediffs)
                        {
                            DefMap <HediffDef, int> defMap2;
                            HediffDef def2;
                            (defMap2 = hediffs)[def2 = hediff.def] = defMap2[def2] + 1;
                        }
                        foreach (Apparel item3 in pawn.apparel.WornApparel)
                        {
                            DefMap <ThingDef, int> defMap;
                            ThingDef def3;
                            (defMap = apparel)[def3 = item3.def] = defMap[def3] + 1;
                        }
                        pawn.Destroy();
                    }
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Sampled " + 400 + "x " + kind.defName + ":");
                    stringBuilder.AppendLine("Weapons");
                    foreach (ThingDef item4 in from t in DefDatabase <ThingDef> .AllDefs
                             orderby weapons[t] descending
                             select t)
                    {
                        int num = weapons[item4];
                        if (num > 0)
                        {
                            stringBuilder.AppendLine("  " + item4.defName + "    " + ((float)num / 400f).ToStringPercent());
                        }
                    }
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("Apparel");
                    foreach (ThingDef item5 in from t in DefDatabase <ThingDef> .AllDefs
                             orderby apparel[t] descending
                             select t)
                    {
                        int num2 = apparel[item5];
                        if (num2 > 0)
                        {
                            stringBuilder.AppendLine("  " + item5.defName + "    " + ((float)num2 / 400f).ToStringPercent());
                        }
                    }
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("Tech hediffs");
                    foreach (HediffDef item6 in from h in DefDatabase <HediffDef> .AllDefs
                             where h.spawnThingOnRemoved != null
                             orderby hediffs[h] descending
                             select h)
                    {
                        int num3 = hediffs[item6];
                        if (num3 > 0)
                        {
                            stringBuilder.AppendLine("  " + item6.defName + "    " + ((float)num3 / 400f).ToStringPercent());
                        }
                    }
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("Addiction hediffs");
                    foreach (HediffDef item7 in from h in DefDatabase <HediffDef> .AllDefs
                             where h.IsAddiction
                             orderby hediffs[h] descending
                             select h)
                    {
                        int num4 = hediffs[item7];
                        if (num4 > 0)
                        {
                            stringBuilder.AppendLine("  " + item7.defName + "    " + ((float)num4 / 400f).ToStringPercent());
                        }
                    }
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("Other hediffs");
                    foreach (HediffDef item8 in from h in DefDatabase <HediffDef> .AllDefs
                             where h.spawnThingOnRemoved == null && !h.IsAddiction
                             orderby hediffs[h] descending
                             select h)
                    {
                        int num5 = hediffs[item8];
                        if (num5 > 0)
                        {
                            stringBuilder.AppendLine("  " + item8.defName + "    " + ((float)num5 / 400f).ToStringPercent());
                        }
                    }
                    Log.Message(stringBuilder.ToString().TrimEndNewlines());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Example #30
0
 private static bool OptionsMatch(FloatMenuOption a, FloatMenuOption b)
 {
     return(a.Label == b.Label);
 }