Exemple #1
0
        static HarmonyPatches()
        {
            if (AdeptusIntergrationUtility.enabled_SOS2)
            {
                SOSConstructPatch();
            }

            MethodInfo QuestGen_Pawns_ = AccessTools.TypeByName("RimWorld.QuestGen.QuestGen_Pawns").GetMethod("GeneratePawn", new Type[] { typeof(Quest), typeof(PawnKindDef), typeof(Faction), typeof(bool), typeof(IEnumerable <TraitDef>), typeof(float), typeof(bool), typeof(Pawn), typeof(float), typeof(float), typeof(bool), typeof(bool) });

            if (QuestGen_Pawns_ != null)
            {
                QuestGen_Pawns_GeneratePawn_Patch();
            }
            if (AccessTools.GetMethodNames(typeof(PawnGraphicSet)).Contains("HeadMatAt_NewTemp"))
            {
                HarmonyPatches.HeadMatAt_NewTemp();
            }
            else
            {
                HarmonyPatches.HeadMatAt();
            }

            if (AccessTools.GetMethodNames(typeof(PawnGraphicSet)).Contains("HairMatAt_NewTemp"))
            {
                HarmonyPatches.HairMatAt_NewTemp();
            }
            else
            {
                HarmonyPatches.HairMatAt();
            }

            HarmonyPatches.CanEquip();

            if (AdeptusIntergrationUtility.enabled_FacialStuff)
            {
                //    HarmonyPatches.FacialStuffPatches();
            }
//            AMAMod.harmony.Patch(original: AccessTools.Constructor(typeof(Verse.PawnTextureAtlas)), transpiler: new HarmonyMethod(typeof(PawnTextureAtlas_Constructor_Name_Patch), nameof(PawnTextureAtlas_Constructor_Name_Patch.Transpiler)));

            /*
             * MethodInfo targetmethod1 = AccessTools.TypeByName("ResearchProjectDef.ConfigErrors").GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Instance).First().
             *  GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).
             *  MaxBy(mi => mi.GetMethodBody()?.GetILAsByteArray().Length ?? -1);
             */
            /*
             * if (AccessTools.GetMethodNames(typeof(PawnRenderer)).Contains("OverrideMaterialIfNeeded_NewTemp"))
             * {
             *  HarmonyPatches.OverrideMaterialIfNeeded_NewTemp();
             * }
             * else
             * {
             *  HarmonyPatches.OverrideMaterialIfNeeded();
             * }
             */
            //    AMAMod.harmony.Patch(AccessTools.Method(typeof(PawnApparelGenerator), "GenerateStartingApparelFor", null, null), null, new HarmonyMethod(typeof(PawnApparelGenerator_GenerateStartingApparelFor_FactionColors_Patch), "Postfix", null), null, null);
        }
Exemple #2
0
 public static void Prefix(Pawn_ApparelTracker __instance, Apparel apparel)
 {
     if (__instance.pawn is Pawn pawn)
     {
         apparel.BroadcastCompSignal(CompHediffApparel.RemoveHediffsFromPawnSignal);
         if (apparel.def.GetModExtensionFast <ApparelRestrictionDefExtension>() is ApparelRestrictionDefExtension ext)
         {
             if (!ext.BodytypeDefs.NullOrEmpty() && ext.forcedBodytype)
             {
                 OriginalBodyTracker tracker = Find.World.GetComponent <OriginalBodyTracker>();
                 if (tracker.ModifiedBody(pawn, out BodyTypeDef original))
                 {
                     HarmonyPatches.ChangeBodyType(pawn, original);
                     tracker.originalBody.Remove(pawn);
                 }
             }
         }
     }
 }
Exemple #3
0
 public static void Prefix(Pawn_ApparelTracker __instance, Apparel apparel)
 {
     if (apparel.Wearer is Pawn pawn)
     {
         apparel.BroadcastCompSignal(CompHediffApparel.AddHediffsToPawnSignal);
         if (apparel.def.GetModExtensionFast <ApparelRestrictionDefExtension>() is ApparelRestrictionDefExtension ext && pawn.story != null)
         {
             if (!ext.BodytypeDefs.NullOrEmpty() && ext.forcedBodytype && !ext.BodytypeDefs.Contains(pawn.story.bodyType))
             {
                 OriginalBodyTracker tracker = Find.World.GetComponent <OriginalBodyTracker>();
                 if (!tracker.ModifiedBody(pawn, out BodyTypeDef original))
                 {
                     tracker.originalBody.SetOrAdd(apparel.Wearer, apparel.Wearer.story.bodyType);
                     HarmonyPatches.ChangeBodyType(pawn, ext.BodytypeDefs.RandomElement());
                 }
             }
         }
     }
 }