Пример #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   workType = (completed || known) ? TechDefOf.HR_Learn : WorkTypeDefOf.Research;
                    string        header   = TechStrings.GetTask(pawn, tech);
                    if (techComp != null && (techComp.homework.NullOrEmpty() || !techComp.homework.Contains(tech)))
                    {
                        if (pawn.WorkTypeIsDisabled(workType))
                        {
                            yield return(new Widgets.DropdownMenuElement <Pawn>
                            {
                                option = new FloatMenuOption(string.Format("{0}: {1} ({2})", header, pawn.LabelShortCap, "WillNever".Translate(workType.labelShort.ToLower())), null, MenuOptionPriority.DisabledOption, null, null, 0f, null, null),
                                payload = pawn
                            });
                        }
                        else if (!pawn.workSettings.WorkIsActive(workType))
                        {
                            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;
        }
Пример #2
0
        public static bool DrawQueue_Prefix(object __instance, Rect canvas)
        {
            if (AltRPal)
            {
                canvas.xMax += 130f + 2 * Margin; //keep an eye on his MainTabWindow_ResearchTree.DrawTopBar method for changes to this number
                canvas       = canvas.ExpandedBy(Margin);
            }
            float   padding   = 12f;
            float   spacing   = Find.ColonistBar.SpaceBetweenColonistsHorizontal;
            float   height    = canvas.height;
            float   startPos  = canvas.xMax - height - padding;
            Vector2 size      = new Vector2(height + spacing, height - padding);
            Vector2 innerSize = new Vector2(height - padding, height - padding);
            IEnumerable <object> expertiseDisplay = new object[] { };
            bool displayActive = false;

            using (IEnumerator <Pawn> enumerator = Find.ColonistBar.GetColonistsInOrder().Where(x => x.TechBound()).AsEnumerable().Reverse().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Vector2 position = new Vector2(startPos, canvas.y);
                    Rect    box      = new Rect(position, size);
                    Rect    innerBox = new Rect(position.x + spacing, position.y, size.x - spacing - 2 * padding, size.y);
                    Pawn    pawn     = enumerator.Current;
                    GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, Rot4.South, cameraZoom: 1.4f));
                    CompKnowledge techComp = pawn.TryGetComp <CompKnowledge>();
                    if (Mouse.IsOver(innerBox))
                    {
                        DeInterest();
                        ReflectKnowledge(__instance, techComp, out expertiseDisplay);
                        displayActive = true;
                    }
                    if (!techComp.homework.NullOrEmpty())
                    {
                        StringBuilder homeworkSummary = new StringBuilder();
                        homeworkSummary.AppendLine("AssignedTo".Translate(pawn));
                        foreach (var tech in techComp.homework)
                        {
                            homeworkSummary.AppendLine("- " + TechStrings.GetTask(pawn, tech) + " " + tech.label);
                        }
                        TooltipHandler.TipRegionByKey(box, homeworkSummary.ToString());
                    }
                    Vector2 pos = new Vector2(box.center.x, box.yMax);
                    GenMapUI.DrawPawnLabel(pawn, pos, 1f, box.width, null, GameFont.Tiny, false, true);
                    startPos -= height;
                }
            }
            if (AltRPal)
            {
                if (displayActive)
                {
                    UpdateMatches(expertiseDisplay);
                    expertiseDisplayed = true;
                }
                else if (expertiseDisplayed)
                {
                    ToggleSearch(false);
                    expertiseDisplayed = false;
                }
            }
            return(false);
        }