예제 #1
0
        public static bool Prefix(SkillDef def, object __instance, ref Verse.Pawn ___pawn)
        {
            var  IsSkillDisabled = AccessTools.Method(PatchPrepareCarefullyBase.cp, "IsSkillDisabled");
            bool f = (bool)IsSkillDisabled.Invoke(__instance, new[] { def });

            if (f)
            {
                //if (__instance.IsSkillDisabled(def))
                return(false);
            }

            var cur = AccessTools.Field(PatchPrepareCarefullyBase.cp, "currentPassions");
            Dictionary <SkillDef, Passion> currentPassions = cur.GetValue(__instance) as Dictionary <SkillDef, Passion>;
            int passion = (int)currentPassions[def];

            //int passion = (int)__instance.currentPassions[def];
            passion = PatchPrepareCarefullyBase.DecreasePassion(passion, ___pawn, def);
            ___pawn.skills.GetSkill(def).passion = (Passion)passion;

            var CopySkillsAndPassionsToPawn = AccessTools.Method(PatchPrepareCarefullyBase.cp, "CopySkillsAndPassionsToPawn");

            CopySkillsAndPassionsToPawn.Invoke(__instance, null);
            // __instance.CopySkillsAndPassionsToPawn();
            return(false);
        }
예제 #2
0
        public static bool Prefix(SkillRecord record, UpdateSkillPassionHandler ___SkillPassionUpdated)
        {
            Verse.Pawn pawn = AccessTools.Field(typeof(SkillRecord), "pawn").GetValue(record) as Verse.Pawn;
            if (pawn == null)
            {
                Log.Error("Failed to retrieve pawn in Patch_DecreasePassion_Prefix1, using original function");
                return(true);
            }
            int passion = (int)record.passion;

            passion = PatchPrepareCarefullyBase.DecreasePassion(passion, pawn, record.def);
            ___SkillPassionUpdated(record.def, (Passion)passion);
            return(false);
        }