Exemplo n.º 1
0
        public static void OpenMasterSelectMenu(Pawn p)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
            {
                p.playerSettings.master = null;
            }, MenuOptionPriority.Default, null, null, 0f, null, null));
            foreach (Pawn item in PawnsFinder.AllMaps_FreeColonistsSpawned)
            {
                string text  = RelationsUtility.LabelWithBondInfo(item, p);
                int    level = item.skills.GetSkill(SkillDefOf.Animals).Level;
                int    num   = TrainableUtility.MinimumHandlingSkill(p);
                Action action;
                if (level >= num)
                {
                    Pawn localCol = item;
                    action = delegate
                    {
                        p.playerSettings.master = localCol;
                    };
                }
                else
                {
                    action = null;
                    text   = text + " (" + "SkillTooLow".Translate(SkillDefOf.Animals.LabelCap, level, num) + ")";
                }
                list.Add(new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Exemplo n.º 2
0
 public static string MasterString(Pawn pawn)
 {
     if (pawn.playerSettings.Master == null)
     {
         return("(" + "NoneLower".TranslateSimple() + ")");
     }
     return(RelationsUtility.LabelWithBondInfo(pawn.playerSettings.Master, pawn));
 }
        private static IEnumerable <Widgets.DropdownMenuElement <Pawn> > MasterSelectButton_GenerateMenu(Pawn p)
        {
            yield return(new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate()
                {
                    p.playerSettings.Master = null;
                }, MenuOptionPriority.Default, null, null, 0f, null, null),
                payload = null
            });

            using (IEnumerator <Pawn> enumerator = PawnsFinder.AllMaps_FreeColonistsSpawned.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Pawn   col      = enumerator.Current;
                    string lab      = RelationsUtility.LabelWithBondInfo(col, p);
                    Action action   = null;
                    int    level    = col.skills.GetSkill(SkillDefOf.Animals).Level;
                    int    minLevel = TrainableUtility.MinimumHandlingSkill(p);
                    if (level < minLevel)
                    {
                        action = null;
                        lab    = lab + " (" + "SkillTooLow".Translate(new object[]
                        {
                            SkillDefOf.Animals.LabelCap,
                            level,
                            minLevel
                        }) + ")";
                    }
                    else if (TrainableUtility.CanBeMaster(col, p, true))
                    {
                        action = delegate()
                        {
                            p.playerSettings.Master = col;
                        };
                    }
                    yield return(new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption(lab, action, MenuOptionPriority.Default, null, null, 0f, null, null),
                        payload = col
                    });
                }
            }
            yield break;
        }
Exemplo n.º 4
0
        private static IEnumerable <Widgets.DropdownMenuElement <Pawn> > MasterSelectButton_GenerateMenu(Pawn p)
        {
            Widgets.DropdownMenuElement <Pawn> dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
                {
                    p.playerSettings.Master = null;
                }),
                payload = null
            };
            yield return(dropdownMenuElement);

            foreach (Pawn col in PawnsFinder.AllMaps_FreeColonistsSpawned)
            {
                string text   = RelationsUtility.LabelWithBondInfo(col, p);
                Action action = null;
                if (CanBeMaster(col, p))
                {
                    action = delegate
                    {
                        p.playerSettings.Master = col;
                    };
                }
                else
                {
                    int level = col.skills.GetSkill(SkillDefOf.Animals).Level;
                    int num   = MinimumHandlingSkill(p);
                    if (level < num)
                    {
                        action = null;
                        text  += " (" + "SkillTooLow".Translate(SkillDefOf.Animals.LabelCap, level, num) + ")";
                    }
                }
                dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                {
                    option  = new FloatMenuOption(text, action),
                    payload = col
                };
                yield return(dropdownMenuElement);
            }
        }