Example #1
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);
                 }
             }
         }
     }
 }
Example #2
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());
                 }
             }
         }
     }
 }