Exemple #1
0
        private static bool Prefix(Pawn pawn, SkillDef skilldef)
        {
            System.Random random = new System.Random();
            int           num    = random.Next(1, 11);
            SkillRecord   sr     = pawn.skills.GetSkill(skilldef);
            bool          flag   = sr.Level > num;

            if (flag)
            {
                int betterPassion = InterestBase.GetBetterPassion((int)sr.passion);
                sr.passion = (Passion)betterPassion;

                int num2 = 0;
                List <SkillRecord> list = new List <SkillRecord>();
                foreach (SkillRecord skillRecord in pawn.skills.skills)
                {
                    bool flag4 = skillRecord.passion > Passion.None && skillRecord.def != skilldef;
                    if (flag4)
                    {
                        num2++;
                        list.Add(skillRecord);
                    }
                }
                bool flag5 = sqp_mod.settings.passion_cap && num2 > 4;
                if (flag5)
                {
                    num = random.Next(0, num2);
                    SkillRecord skillRecord2 = list[num];
                    skillRecord2.passion = (Passion)InterestBase.GetWorsePassion((int)skillRecord2.passion);
                }
            }
            return(false);
        }
        private static void Postfix(ref string __result, SkillRecord sk)
        {
            int           passionNum = (int)sk.passion;
            StringBuilder rebuild    = new StringBuilder(__result);
            StringBuilder toFind     = new StringBuilder();

            toFind.Append("Passion".Translate() + ": ");

            switch (passionNum)
            {
            case 0:
                toFind.Append("PassionNone".Translate(0.35f.ToStringPercent("F0")));
                break;

            case 1:
                toFind.Append("PassionMinor".Translate(1f.ToStringPercent("F0")));
                break;

            case 2:
                toFind.Append("PassionMajor".Translate(1.5f.ToStringPercent("F0")));
                break;
            }
            var toAdd = InterestBase.GetSkillDescription(sk);

            rebuild.Replace(toFind.ToString(), toAdd.ToString());
            __result = rebuild.ToString();
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            SkillDef active = InterestBase.GetActiveSkill(p);

            if (active == null)
            {
                return(ThoughtState.Inactive);
            }

            SkillRecord skill = p.skills.GetSkill(active);

            if (skill == null)
            {
                return(ThoughtState.Inactive);
            }
            int passion = (int)skill.passion;

            // these could return -1 but passion won't be -1
            var minor = InterestBase.interestList.FindIndex(x => x.defName == "DMinorPassion");

            if (passion == minor)
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            var major = InterestBase.interestList.FindIndex(x => x.defName == "DMajorPassion");

            if (passion == major)
            {
                return(ThoughtState.ActiveAtStage(1));
            }
            return(ThoughtState.Inactive);
        }
        private static void Postfix(Pawn pawn, Pawn mother1, Pawn father1, bool GenerateRandom, bool __state)
        {
            if (__state)
            {
                return;
            }

            InterestBase.Inherit(pawn, mother1, father1, GenerateRandom);
        }
Exemple #5
0
        private static void Postfix(ref Pawn __result, SkillDef skill)
        {
            Pawn        pawn        = Find.GameInitData.startingAndOptionalPawns[0];
            SkillRecord skillRecord = pawn.skills.GetSkill(skill);

            for (int i = 1; i < Find.GameInitData.startingPawnCount; i++)
            {
                SkillRecord skill2        = Find.GameInitData.startingAndOptionalPawns[i].skills.GetSkill(skill);
                var         passionValue1 = InterestBase.GetValue((int)skillRecord.passion);
                var         passionValue2 = InterestBase.GetValue((int)skill2.passion);
                if (skillRecord.TotallyDisabled || skill2.Level > skillRecord.Level || (skill2.Level == skillRecord.Level && passionValue2 > passionValue1))
                {
                    pawn        = Find.GameInitData.startingAndOptionalPawns[i];
                    skillRecord = skill2;
                }
            }
            __result = pawn;
        }
Exemple #6
0
        private static bool Prefix(ref float __result, bool direct, Passion ___passion, SkillRecord __instance, Pawn ___pawn)
        {
            if (DebugSettings.fastLearning)
            {
                __result = 200f;
                return(false);
            }
            float num = InterestBase.LearnRateFactor(___passion);

            if (!direct)
            {
                num *= ___pawn.GetStatValue(StatDefOf.GlobalLearningFactor, true);
                if (__instance.LearningSaturatedToday)
                {
                    num *= 0.2f;
                }
            }
            __result = num;
            return(false);
        }
        private static void Postfix(ref float __result, Pawn pawn, InspirationDef ___def)
        {
            float num = 1f;

            if (pawn.skills != null && ___def.associatedSkills != null)
            {
                for (int i = 0; i < ___def.associatedSkills.Count; i++)
                {
                    SkillDef skillDef = ___def.associatedSkills[i];
                    for (int j = 0; j < pawn.skills.skills.Count; j++)
                    {
                        SkillRecord skillRecord = pawn.skills.skills[j];
                        if (skillDef == skillRecord.def)
                        {
                            int s = (int)pawn.skills.skills[j].passion;
                            num = Mathf.Max(num, InterestBase.GetInspirationFactor(s));
                        }
                    }
                }
            }
            __result = ___def.baseCommonality * num;
        }
 private static void Postfix(Pawn pawn)
 {
     InterestBase.GenerateInterests(pawn);
 }