Esempio n. 1
0
        private static IEnumerable <Widgets.DropdownMenuElement <Pawn> > GeneratePawnRestrictionOptions(this ResearchProjectDef tech, bool completed)
        {
            SkillDef skill = SkillDefOf.Intellectual;

            using (IEnumerator <Pawn> enumerator = tech.SortedPawns().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Pawn          pawn      = enumerator.Current;
                    CompKnowledge techComp  = pawn.TryGetComp <CompKnowledge>();
                    bool          known     = tech.IsKnownBy(pawn);
                    WorkTypeDef   workGiver = (completed || known) ? TechDefOf.HR_Learn : WorkTypeDefOf.Research;
                    string        header    = known ? TechStrings.headerWrite : completed ? TechStrings.headerRead : TechStrings.headerResearch;
                    if (techComp != null && (techComp.homework.NullOrEmpty() || !techComp.homework.Contains(tech)))
                    {
                        if (pawn.WorkTypeIsDisabled(workGiver))
                        {
                            yield return(new Widgets.DropdownMenuElement <Pawn>
                            {
                                option = new FloatMenuOption(string.Format("{0}: {1} ({2})", header, pawn.LabelShortCap, "WillNever".Translate(workGiver.verb)), null, MenuOptionPriority.DisabledOption, null, null, 0f, null, null),
                                payload = pawn
                            });
                        }
                        else if (!pawn.workSettings.WorkIsActive(workGiver))
                        {
                            yield return(new Widgets.DropdownMenuElement <Pawn>
                            {
                                option = new FloatMenuOption(string.Format("{0}: {1} ({2})", header, pawn.LabelShortCap, "NotAssigned".Translate()), delegate()
                                {
                                    techComp.AssignBranch(tech);
                                }, MenuOptionPriority.VeryLow, null, null, 0f, null, null),
                                payload = pawn
                            });
                        }
                        else
                        {
                            yield return(new Widgets.DropdownMenuElement <Pawn>
                            {
                                option = new FloatMenuOption(string.Format("{0}: {1} ({2} {3})", new object[]
                                {
                                    header,
                                    pawn.LabelShortCap,
                                    pawn.skills.GetSkill(skill).Level,
                                    skill.label
                                }),
                                                             delegate() { techComp.AssignBranch(tech); },
                                                             MenuOptionPriority.Default, null, null, 0f, null, null),
                                payload = pawn
                            });
                        }
                    }
                }
            }
            yield break;
        }