Exemplo n.º 1
0
        private void DrawSkillSummaries(Rect rect)
        {
            rect.xMin += 10f;
            rect.xMax -= 10f;
            Widgets.DrawMenuSection(rect);
            rect      = rect.ContractedBy(17f);
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(rect.min, new Vector2(rect.width, 45f)), "TeamSkills".Translate());
            Text.Font   = GameFont.Small;
            rect.yMin  += 45f;
            rect        = rect.LeftPart(0.25f);
            rect.height = 27f;
            List <SkillDef> allDefsListForReading = DefDatabase <SkillDef> .AllDefsListForReading;

            if (this.SkillsPerColumn < 0)
            {
                this.SkillsPerColumn = Mathf.CeilToInt((float)((float)(from sd in allDefsListForReading
                                                                       where sd.pawnCreatorSummaryVisible
                                                                       select sd).Count() / 4.0));
            }
            int num = 0;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                SkillDef skillDef = allDefsListForReading[i];
                if (skillDef.pawnCreatorSummaryVisible)
                {
                    Rect r = rect;
                    r.x      = rect.x + rect.width * (float)(num / this.SkillsPerColumn);
                    r.y      = rect.y + rect.height * (float)(num % this.SkillsPerColumn);
                    r.height = 24f;
                    r.width -= 4f;
                    Pawn pawn = this.FindBestSkillOwner(skillDef);
                    SkillUI.DrawSkill(pawn.skills.GetSkill(skillDef), r.Rounded(), SkillUI.SkillDrawMode.Menu, pawn.Name.ToString());
                    num++;
                }
            }
        }
Exemplo n.º 2
0
        public string FullDescriptionFor(Pawn p)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(this.baseDesc.Formatted(p.Named("PAWN")).AdjustedFor(p, "PAWN"));
            stringBuilder.AppendLine();
            stringBuilder.AppendLine();
            List <SkillDef> allDefsListForReading = DefDatabase <SkillDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                SkillDef skillDef = allDefsListForReading[i];
                if (this.skillGainsResolved.ContainsKey(skillDef))
                {
                    stringBuilder.AppendLine(skillDef.skillLabel.CapitalizeFirst() + ":   " + this.skillGainsResolved[skillDef].ToString("+##;-##"));
                }
            }
            stringBuilder.AppendLine();
            foreach (WorkTypeDef current in this.DisabledWorkTypes)
            {
                stringBuilder.AppendLine(current.gerundLabel.CapitalizeFirst() + " " + "DisabledLower".Translate());
            }
            foreach (WorkGiverDef current2 in this.DisabledWorkGivers)
            {
                stringBuilder.AppendLine(string.Concat(new string[]
                {
                    current2.workType.gerundLabel.CapitalizeFirst(),
                    ": ",
                    current2.LabelCap,
                    " ",
                    "DisabledLower".Translate()
                }));
            }
            string str = stringBuilder.ToString().TrimEndNewlines();

            return(Find.ActiveLanguageWorker.PostProcessed(str));
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            JobDriver curDriver = p.jobs.curDriver;

            if (curDriver == null)
            {
                return(ThoughtState.Inactive);
            }
            Pawn_SkillTracker skills = p.skills;

            if (skills == null)
            {
                return(ThoughtState.Inactive);
            }
            SkillDef activeSkill = curDriver.ActiveSkill;

            if (activeSkill == null)
            {
                return(ThoughtState.Inactive);
            }
            SkillRecord skill = p.skills.GetSkill(curDriver.ActiveSkill);

            if (skill == null)
            {
                return(ThoughtState.Inactive);
            }
            if (skill.passion == Passion.Minor)
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            if (skill.passion == Passion.Major)
            {
                return(ThoughtState.ActiveAtStage(1));
            }
            return(ThoughtState.Inactive);
        }
 public void Learn(SkillDef sDef, float xp, bool direct = false)
 {
     GetSkill(sDef).Learn(xp, direct);
 }
Exemplo n.º 5
0
 private static float <DrawSkillsOf> m__0(SkillDef sd)
 {
     return(sd.listOrder);
 }
Exemplo n.º 6
0
 public SkillRecord(Pawn pawn, SkillDef def)
 {
     this.pawn = pawn;
     this.def  = def;
 }
Exemplo n.º 7
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     this.skill = DefDatabase <SkillDef> .GetRandom();
 }
Exemplo n.º 8
0
        private IEnumerable <Widgets.DropdownMenuElement <Pawn> > GeneratePawnRestrictionOptions()
        {
            yield return(new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("AnyWorker".Translate(), delegate()
                {
                    this.bill.pawnRestriction = null;
                }, MenuOptionPriority.Default, null, null, 0f, null, null),
                payload = null
            });

            SkillDef           workSkill = this.bill.recipe.workSkill;
            IEnumerable <Pawn> pawns     = PawnsFinder.AllMaps_FreeColonists;

            pawns = from pawn in pawns
                    orderby pawn.LabelShortCap
                    select pawn;

            if (workSkill != null)
            {
                pawns = from pawn in pawns
                        orderby pawn.skills.GetSkill(this.bill.recipe.workSkill).Level descending
                        select pawn;
            }
            WorkGiverDef workGiver = this.bill.billStack.billGiver.GetWorkgiver();

            if (workGiver == null)
            {
                Log.ErrorOnce("Generating pawn restrictions for a BillGiver without a Workgiver", 96455148, false);
                yield break;
            }
            pawns = from pawn in pawns
                    orderby pawn.workSettings.WorkIsActive(workGiver.workType) descending
                    select pawn;

            pawns = from pawn in pawns
                    orderby pawn.story.WorkTypeIsDisabled(workGiver.workType)
                    select pawn;

            using (IEnumerator <Pawn> enumerator = pawns.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Pawn pawn = enumerator.Current;
                    if (pawn.story.WorkTypeIsDisabled(workGiver.workType))
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "WillNever".Translate(new object[]
                            {
                                workGiver.verb
                            })), null, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else if (this.bill.recipe.workSkill != null && !pawn.workSettings.WorkIsActive(workGiver.workType))
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1} {2}, {3})", new object[]
                            {
                                pawn.LabelShortCap,
                                pawn.skills.GetSkill(this.bill.recipe.workSkill).Level,
                                this.bill.recipe.workSkill.label,
                                "NotAssigned".Translate()
                            }), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else if (!pawn.workSettings.WorkIsActive(workGiver.workType))
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "NotAssigned".Translate()), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else if (this.bill.recipe.workSkill != null)
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1} {2})", pawn.LabelShortCap, pawn.skills.GetSkill(this.bill.recipe.workSkill).Level, this.bill.recipe.workSkill.label), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0}", pawn.LabelShortCap), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                }
            }
            yield break;
        }
Exemplo n.º 9
0
        private IEnumerable <Widgets.DropdownMenuElement <Pawn> > GeneratePawnRestrictionOptions()
        {
            Widgets.DropdownMenuElement <Pawn> dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("AnyWorker".Translate(), delegate
                {
                    bill.pawnRestriction = null;
                }),
                payload = null
            };
            yield return(dropdownMenuElement);

            SkillDef           workSkill             = bill.recipe.workSkill;
            IEnumerable <Pawn> allMaps_FreeColonists = PawnsFinder.AllMaps_FreeColonists;

            allMaps_FreeColonists = allMaps_FreeColonists.OrderBy((Pawn pawn) => pawn.LabelShortCap);
            if (workSkill != null)
            {
                allMaps_FreeColonists = allMaps_FreeColonists.OrderByDescending((Pawn pawn) => pawn.skills.GetSkill(bill.recipe.workSkill).Level);
            }
            WorkGiverDef workGiver = bill.billStack.billGiver.GetWorkgiver();

            if (workGiver == null)
            {
                Log.ErrorOnce("Generating pawn restrictions for a BillGiver without a Workgiver", 96455148);
                yield break;
            }
            allMaps_FreeColonists = allMaps_FreeColonists.OrderByDescending((Pawn pawn) => pawn.workSettings.WorkIsActive(workGiver.workType));
            allMaps_FreeColonists = allMaps_FreeColonists.OrderBy((Pawn pawn) => pawn.WorkTypeIsDisabled(workGiver.workType));
            foreach (Pawn pawn2 in allMaps_FreeColonists)
            {
                if (pawn2.WorkTypeIsDisabled(workGiver.workType))
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option  = new FloatMenuOption(string.Format("{0} ({1})", pawn2.LabelShortCap, "WillNever".Translate(workGiver.verb)), null),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else if (bill.recipe.workSkill != null && !pawn2.workSettings.WorkIsActive(workGiver.workType))
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption(string.Format("{0} ({1} {2}, {3})", pawn2.LabelShortCap, pawn2.skills.GetSkill(bill.recipe.workSkill).Level, bill.recipe.workSkill.label, "NotAssigned".Translate()), delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else if (!pawn2.workSettings.WorkIsActive(workGiver.workType))
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption(string.Format("{0} ({1})", pawn2.LabelShortCap, "NotAssigned".Translate()), delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else if (bill.recipe.workSkill != null)
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption($"{pawn2.LabelShortCap} ({pawn2.skills.GetSkill(bill.recipe.workSkill).Level} {bill.recipe.workSkill.label})", delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption($"{pawn2.LabelShortCap}", delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
            }
        }