- Fixed a bug that was causing alien addons to not render when pawns were wearing apparel
This commit is contained in:
AbstractConcept 2023-02-07 22:08:58 -06:00
parent 9144029fec
commit 001121649b
11 changed files with 20 additions and 13 deletions

View File

@ -1,3 +1,6 @@
Change log v 2.0.3
- Fixed a bug that was causing alien addons to not render when pawns were wearing apparel
Change log v 2.0.2
- Implemented texture caching to reduce the performance hit induced by dynamically cropping apparel
- Dynamically cropping apparel is now compatible with Sized Apparel

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<version>2.0.2</version>
<version>2.0.3</version>
<downloadUri>https://gitgud.io/AbstractConcept/rimworld-animations-patch</downloadUri>
</Manifest>

View File

@ -138,8 +138,8 @@ namespace Rimworld_Animations_Patch
public void UpdateVisibility()
{
if (pawn == null || bodyAddon == null || bodyPartRecord == null) return;
canDraw = true;
if (pawn == null || bodyAddon == null || bodyPartRecord == null) return;
if (pawn.health?.hediffSet?.GetNotMissingParts()?.Contains(bodyPartRecord) == false)
{ bodyPartMissing = true; return; }
@ -151,6 +151,7 @@ namespace Rimworld_Animations_Patch
{
CompApparelVisibility comp = apparel?.TryGetComp<CompApparelVisibility>();
if (comp == null) continue;
LoadRimNudeData(comp);
if (comp.isBeingWorn == false) continue;
@ -158,7 +159,7 @@ namespace Rimworld_Animations_Patch
if (bodyAddon.bodyPart == PatchBodyPartDefOf.Genitals ||
bodyAddon.bodyPart == PatchBodyPartDefOf.Anus ||
bodyAddon.bodyPart == PatchBodyPartDefOf.Chest ||
bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && (x.path.Contains("belly") || x.path.Contains("Belly"))) == true)
bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && x.path.Contains("belly", StringComparison.OrdinalIgnoreCase)) == true)
{
if ((bodyAddon.bodyPart == PatchBodyPartDefOf.Genitals || bodyAddon.bodyPart == PatchBodyPartDefOf.Anus) && comp.coversGroin)
{ canDraw = false; return; };
@ -166,16 +167,19 @@ namespace Rimworld_Animations_Patch
if (bodyAddon.bodyPart == PatchBodyPartDefOf.Chest && comp.coversChest)
{ canDraw = false; return; };
if (bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && (x.path.Contains("belly") || x.path.Contains("Belly"))) == true && comp.coversBelly)
if (bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && x.path.Contains("belly", StringComparison.OrdinalIgnoreCase)) == true && comp.coversBelly)
{ canDraw = false; return; }
}
else if (apparel.def.apparel.hatRenderedFrontOfFace || apparel.def.apparel.hatRenderedAboveBody || apparel.def.apparel.hatRenderedBehindHead)
{ return; }
else
{
if (bodyAddon.hiddenUnderApparelFor?.Any(x => apparel?.def.apparel?.hatRenderedFrontOfFace == false && apparel.def.apparel?.bodyPartGroups?.Contains(x) == true) == true)
if (bodyAddon.hiddenUnderApparelFor?.Any(x => apparel.def.apparel.bodyPartGroups?.Contains(x) == true) == true)
{ canDraw = false; return; };
if (bodyAddon.hiddenUnderApparelTag?.Any(x => apparel?.def.apparel?.hatRenderedFrontOfFace == false && apparel.def.apparel?.tags?.Contains(x) == true) == true)
if (bodyAddon.hiddenUnderApparelTag?.Any(x => apparel.def.apparel.tags?.Contains(x) == true) == true)
{ canDraw = false; return; };
}
}

View File

@ -22,8 +22,8 @@ namespace Rimworld_Animations_Patch
{
if (LoadedModManager.RunningModsListForReading.Any(x => x.PackageIdPlayerFacing == "babies.and.children.continued.13"))
{
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(typeof(AnimationPatchUtility), "ShouldNotDrawAddonsForPawn"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_BabiesAndChildren), "Prefix_ShouldNotDrawAddonsForPawn")));
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(typeof(AnimationPatchUtility), "ShouldNotAnimatePawn"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_BabiesAndChildren), "Prefix_ShouldNotAnimatePawn")));
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(typeof(AnimationPatchUtility), "GetBodySize"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_BabiesAndChildren), "Prefix_GetBodySize")));
}
@ -33,7 +33,7 @@ namespace Rimworld_Animations_Patch
catch (TypeLoadException) { }
}
public static bool Prefix_ShouldNotDrawAddonsForPawn(ref bool __result, Pawn pawn)
public static bool ShouldNotAnimatePawn(ref bool __result, Pawn pawn)
{
__result = AgeStages.IsYoungerThan(pawn, AgeStages.Child, false);

View File

@ -121,7 +121,7 @@ namespace Rimworld_Animations_Patch
{ ApparelAnimationUtility.TryToDrawApparelOnFloor(pawn); }
// Exit clauses
if (BasicSettings.useLegacyAnimationSystem || AnimationPatchUtility.ShouldNotDrawAddonsForPawn(pawn) || sexDataComp == null)
if (BasicSettings.useLegacyAnimationSystem || AnimationPatchUtility.ShouldNotAnimatePawn(pawn) || sexDataComp == null)
{ return true; }
// Get available hands
@ -141,7 +141,7 @@ namespace Rimworld_Animations_Patch
if (bodyAddonDatum == null) continue;
// Can draw?
bool canDraw = addonGraphic.path.Contains("featureless") == false && addonGraphic.path.Contains("Featureless") == false && bodyAddonDatum.CanDraw();
bool canDraw = addonGraphic.path.Contains("featureless", StringComparison.OrdinalIgnoreCase) == false && bodyAddonDatum.CanDraw();
bool drawHand = BasicSettings.showHands && handsAvailableCount > 0 && renderFlags.FlagSet(PawnRenderFlags.Portrait) == false;
if (canDraw == false && drawHand == false)

View File

@ -173,9 +173,9 @@ namespace Rimworld_Animations_Patch
return anchor;
}
public static bool ShouldNotDrawAddonsForPawn(Pawn pawn)
public static bool ShouldNotAnimatePawn(Pawn pawn)
{
return false;
return pawn.ageTracker.CurLifeStage.developmentalStage == DevelopmentalStage.Baby || pawn.ageTracker.CurLifeStage.developmentalStage == DevelopmentalStage.Child;
}
public static float GetBodySize(Pawn pawn)