Beispiel #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.IncreasePassion(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);
        }
Beispiel #2
0
 public static void FillBackstorySlotShuffled(Verse.Pawn pawn, BackstorySlot slot, ref Backstory backstory, Backstory backstoryOtherSlot, List <BackstoryCategoryFilter> backstoryCategories, FactionDef factionType)
 {
     ReflectionCache.Instance.PawnBioAndNameGenerator_FillBackstorySlotShuffled.Invoke(null,
                                                                                       new object[] {
         pawn, slot, backstory, backstoryOtherSlot, backstoryCategories, factionType
     }
                                                                                       );
 }
Beispiel #3
0
 public static void PawnTick_Postfix(Verse.Pawn __instance)
 {
     if (__instance.Spawned && !__instance.NonHumanlikeOrWildMan() && __instance.story.traits.HasTrait(TraitDef.Named("HKR_SpawnInWorld")))
     {
         __instance.story.traits.allTraits.Remove(__instance.story.traits.GetTrait(TraitDef.Named("HKR_SpawnInWorld")));
         __instance.DeSpawn();
         Find.WorldPawns.PassToWorld(__instance, PawnDiscardDecideMode.KeepForever);
     }
 }
Beispiel #4
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);
        }
        public static int IncreasePassion(int passion, Verse.Pawn pawn, SkillDef def)
        {
            int oldPassion = passion;

            do
            {
                passion++;
                if (passion > InterestBase.interestList.Count - 1)
                {
                    passion = 0;
                }
                if (InterestBase.interestList[passion].IsValidForPawn(pawn, def))
                {
                    return(passion);
                }
            } while (passion != oldPassion);
            return(oldPassion);
        }
        static void Postfix(Verse.Pawn __instance, ref IEnumerable <Thing> __result, float efficiency)
        {
            int boneCount = GenMath.RoundRandom(__instance.GetStatValue(DefDatabase <StatDef> .GetNamed("BoneAmount", true), true) * BoneModSettings.boneFactor * efficiency);

            if (boneCount > 0)
            {
                List <Thing> NewList = new List <Thing>();
                foreach (Thing entry in __result)
                {
                    NewList.Add(entry);
                }
                Thing bones = ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("BoneItem"), null);
                bones.stackCount = boneCount;
                NewList.Add(bones);


                IEnumerable <Thing> output = NewList;
                __result = output;
            }
        }
        private static void Postfix(UnityEngine.Rect rect, Verse.Pawn colonist, Verse.Map pawnMap, bool highlight, bool reordering)
        {
            CompBadge cb = colonist.GetComp <CompBadge>();

            if (cb == null)
            {
                return;
            }

            float iwidth = ICON_WIDTH;

            switch (Settings.badgeSize)
            {
            case Settings.BadgeSize.Small:
                iwidth = iwidth - 10f;
                break;

            case Settings.BadgeSize.Large:
                iwidth = iwidth + 10f;
                break;
            }
            float iwidth_half   = iwidth / 2.0f;
            float ibottommargin = iwidth_half;

            // default position is Top, adjust starting from this
            if (cb.badges[0] != "")
            {
                Rect brect = new Rect(rect.x - iwidth_half, rect.y - iwidth_half, iwidth, iwidth);
                switch (Settings.badgePosition)
                {
                case Settings.BadgePosition.Bottom:
                    brect.y += rect.height - ibottommargin;
                    break;

                case Settings.BadgePosition.Right:
                    brect.x += rect.width;
                    break;
                }
                GUI.DrawTexture(brect, DefDatabase <BadgeDef> .GetNamed(cb.badges[0]).Symbol, ScaleMode.ScaleToFit);
            }

            if (cb.badges[1] != "")
            {
                Rect brect = new Rect(rect.xMax - iwidth_half, rect.y - iwidth_half, iwidth, iwidth);
                switch (Settings.badgePosition)
                {
                case Settings.BadgePosition.Bottom:
                    brect.y += rect.height - ibottommargin;
                    break;

                case Settings.BadgePosition.Left:
                    brect.x -= rect.width;
                    brect.y += rect.height - ibottommargin;
                    break;

                case Settings.BadgePosition.Right:
                    brect.y += rect.height - ibottommargin;
                    break;
                }
                GUI.DrawTexture(brect, DefDatabase <BadgeDef> .GetNamed(cb.badges[1]).Symbol, ScaleMode.ScaleToFit);
            }
        }
Beispiel #8
0
 public static List <BackstoryCategoryFilter> GetBackstoryCategoryFiltersFor(Verse.Pawn pawn, FactionDef faction)
 {
     return((List <BackstoryCategoryFilter>)ReflectionCache.Instance.PawnBioAndNameGenerator_GetBackstoryCategoryFiltersFor.Invoke(null,
                                                                                                                                   new object[] { pawn, faction }
                                                                                                                                   ));
 }
Beispiel #9
0
 public static void ClearCachedDisabledWorkTypesPermanent(Verse.Pawn pawn)
 {
     ReflectionCache.Instance.Pawn_CachedDisabledWorkTypesPermanent.SetValue(pawn, null);
 }
 public static int IncreasePassion(int passion, Verse.Pawn pawn, SkillDef def)
 {
     return(PatchPrepareCarefullyBase.IncreasePassion(passion, pawn, def));
 }