using System; using System.Collections.Generic; using HarmonyLib; using RimWorld; using UnityEngine; using Verse; namespace Rimworld_Animations_Patch { [StaticConstructorOnStartup] [HarmonyPatch(typeof(ApparelGraphicRecordGetter), "TryGetGraphicApparel")] public static class HarmonyPatch_ApparelGraphicRecordGetter_TryGetGraphicApparel { static bool _checkedForSizedApparel; static bool _isRunningSizedApparel; // Not compatible with SizedApparel - running Graphic.Blit on the resized apparel will cause the pawn to turn invisible for one facing public static bool IsRunningSizedApparel { get { if (_checkedForSizedApparel == false) { _isRunningSizedApparel = LoadedModManager.RunningModsListForReading.Any(x => x.PackageIdPlayerFacing == "OTYOTY.SizedApparel"); _checkedForSizedApparel = true; } return _isRunningSizedApparel; } } [HarmonyAfter("SizedApparelforRJW")] public static void Postfix(ref bool __result, ref Apparel apparel, ref BodyTypeDef bodyType, ref ApparelGraphicRecord rec) { if (__result == false || apparel == null || bodyType == null || rec.graphic == null || apparel?.Wearer?.RaceProps?.Humanlike != true || ApparelSettings.cropApparel == false) return; if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.OnSkin && apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) && !apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs)) { ApparelTexture2DPack pack = ApparelSettingsUtility.GetCachedApparelTextures(rec.graphic, bodyType); if (pack == null) return; for (int i = 0; i < 3; i++) { if (pack.textures[i] == null) continue; rec.graphic.MatAt(new Rot4(i)).mainTexture = pack.textures[i]; } } } } } //"Masks/apparel_shirt_mask_" + bodyType.defName