diff --git a/1.3/Assemblies/Rimworld-Animations-Patch.dll b/1.3/Assemblies/Rimworld-Animations-Patch.dll index d07b122..e9b46a6 100644 Binary files a/1.3/Assemblies/Rimworld-Animations-Patch.dll and b/1.3/Assemblies/Rimworld-Animations-Patch.dll differ diff --git a/1.3/Assemblies/Rimworld-Animations-Patch.pdb b/1.3/Assemblies/Rimworld-Animations-Patch.pdb index c299208..8e6f46a 100644 Binary files a/1.3/Assemblies/Rimworld-Animations-Patch.pdb and b/1.3/Assemblies/Rimworld-Animations-Patch.pdb differ diff --git a/About/About.xml b/About/About.xml index 3fff182..ed51e74 100644 --- a/About/About.xml +++ b/About/About.xml @@ -55,8 +55,13 @@ Here's a brief overview of whats included in this mod A full list of changes can be found in the main discussion thread on the forum -Known conflicts +Known issues +- This mod requires that you run RimWorld Animations v 1.2.8 or later, otherwise animations will result in errors +- If you plan to use this mod's apparel cropping feature and the Sized Apparel mod, you must turn off texture caching or graphical glitches will occur (this can be done by adding Vanilla Expanded Framework to your mod list and enabling its 'Disable Texture Caching' setting) +- Using Dubs Apparel Tweaks or the Show Hair mod may result in hair rendering over hats during animations - To avoid certain graphical issues, Dubs Apparel Tweaks should be loaded before this mod while Babies and Children should be loaded after (if you choose to use them). This will mean that you will not be able to run this mod with Dubs Apparel Tweaks and Babies and Children running at the same time +- Using Speak Up and Dirty Talk results in warning messages being posted in the log. This does not seem to be causing problems in their function, however. This issue will be monitored +- This mod tweaks pretty much every animation involving humans, so it isn't currently compatible with the Tory's VoicePatch mod (unsupported animations will have no voices played) - This mod will result in graphical errors when using Pawnmorpher's 'Pawn scaling' setting diff --git a/About/Changelog_v1.2.2.txt b/About/Changelog_v1.2.3.txt similarity index 96% rename from About/Changelog_v1.2.2.txt rename to About/Changelog_v1.2.3.txt index 152dd7d..535962c 100644 --- a/About/Changelog_v1.2.2.txt +++ b/About/Changelog_v1.2.3.txt @@ -1,3 +1,8 @@ +Change lob v 1.2.3 +- Fix: Fixed a bug which would cause body parts to vanish while a pawn is in a biosculpter pod +- Fix: Fixed a bug which would cause body parts to show while sleeping in a bed +- Fix: Added additional safeguards to help prevent rare errors when equipping certain apparel and when closing the settings menu while in game + Change log v 1.2.2 - Fix: Fix for portraits appearing blank when using the 'crop apparel' feature - Fix: Underwear counts as covering private parts when determining basic nudity diff --git a/Languages/English/Keyed/SettingsKeys.xml b/Languages/English/Keyed/SettingsKeys.xml index bb64b25..5aa3f9c 100644 --- a/Languages/English/Keyed/SettingsKeys.xml +++ b/Languages/English/Keyed/SettingsKeys.xml @@ -35,7 +35,7 @@ Auto-scale animation offsets based on body size Turning this setting on may help when using alien races which are much larger or smaller than regular humans. Add animated hands to animations - Requires RimNudeWorld. + Requires RimNudeWorld. This feature can be performance intense. If you have large colonies (50+ colonist), you may wish to turn this off. Redraw hair in pawn portraits Helps prevent bodyparts from rendering over long hair in portraits. Disable this feature if you find two sets of hair appearing on your pawns or hair is being rendered over headgear. diff --git a/Source/.vs/Rimworld-Animations-Patch/v16/.suo b/Source/.vs/Rimworld-Animations-Patch/v16/.suo index e7c996d..3cf7175 100644 Binary files a/Source/.vs/Rimworld-Animations-Patch/v16/.suo and b/Source/.vs/Rimworld-Animations-Patch/v16/.suo differ diff --git a/Source/Scripts/Comps/CompPawnSexData.cs b/Source/Scripts/Comps/CompPawnSexData.cs index 4eab434..61a1fb5 100644 --- a/Source/Scripts/Comps/CompPawnSexData.cs +++ b/Source/Scripts/Comps/CompPawnSexData.cs @@ -28,7 +28,7 @@ namespace Rimworld_Animations_Patch if (pawn == null) { pawn = parent as Pawn; } - if (pawn == null || pawn.Map != Find.CurrentMap || bodyAddon == null) return null; + if (pawn == null || (pawn.Map != Find.CurrentMap && pawn.holdingOwner == null) || bodyAddon == null) return null; if (isPortrait) { @@ -56,10 +56,10 @@ namespace Rimworld_Animations_Patch public void UpdateBodyAddonVisibility() { foreach (KeyValuePair kvp in bodyAddonData) - { kvp.Value.UpdateVisibility(); } + { kvp.Value?.UpdateVisibility(); } foreach (KeyValuePair kvp in bodyAddonDataPortraits) - { kvp.Value.UpdateVisibility(); } + { kvp.Value?.UpdateVisibility(); } } public void UpdateHands() diff --git a/Source/Scripts/Defs/BodyAddonData.cs b/Source/Scripts/Defs/BodyAddonData.cs index 9f4c844..3b20c08 100644 --- a/Source/Scripts/Defs/BodyAddonData.cs +++ b/Source/Scripts/Defs/BodyAddonData.cs @@ -21,6 +21,7 @@ namespace Rimworld_Animations_Patch private string bodyType; private PawnRenderFlags renderFlags; private bool canDraw = false; + private bool bodyPartMissing = false; public BodyAddonData(Pawn pawn, AlienPartGenerator.BodyAddon bodyAddon, bool isPortrait = false) { @@ -107,42 +108,53 @@ namespace Rimworld_Animations_Patch public bool CanDraw() { - return pawn.Drawer.renderer.graphics.apparelGraphics.Any() == false || canDraw; + return bodyPartMissing == false && SitutationalVisibiltyCheck() && (pawn.Drawer.renderer.graphics.apparelGraphics.Any() == false || canDraw); + } + + public bool SitutationalVisibiltyCheck() + { + if (pawn == null || bodyAddon == null) return false; + + if (pawn.CurrentBed()?.def.building.bed_showSleeperBody == false && bodyAddon.drawnInBed == false) + { return false; } + + if (bodyAddon.backstoryRequirement.NullOrEmpty() == false && pawn.story?.AllBackstories?.Any((Backstory x) => x.identifier == bodyAddon.backstoryRequirement) == false) + { return false; } + + if (bodyAddon.drawnDesiccated == false && pawn.Corpse?.GetRotStage() == RotStage.Dessicated) + { return false; } + + if (pawn.gender == Gender.Female && bodyAddon.drawForFemale == false || pawn.gender == Gender.Male && bodyAddon.drawForMale == false) + { return false; } + + if (bodyAddon.bodyTypeRequirement.NullOrEmpty() == false && pawn.story?.bodyType.ToString() != bodyAddon.bodyTypeRequirement) + { return false; } + + if ((pawn.GetPosture() == PawnPosture.LayingOnGroundNormal || pawn.GetPosture() == PawnPosture.LayingOnGroundFaceUp) && bodyAddon.drawnOnGround == false) + { return false; } + + return true; } public void UpdateVisibility() - { + { + if (pawn == null || bodyAddon == null) return; + canDraw = true; - if (pawn.CurrentBed()?.def.building.bed_showSleeperBody == false && bodyAddon.drawnInBed == false) - {canDraw = false; return; } - - if (bodyAddon.backstoryRequirement.NullOrEmpty() == false && pawn.story.AllBackstories.Any((Backstory x) => x.identifier == bodyAddon.backstoryRequirement) == false) - { canDraw = false; return; } - - if (bodyAddon.drawnDesiccated == false && pawn?.Corpse?.GetRotStage() == RotStage.Dessicated) - { canDraw = false; return; } - - if (pawn.health.hediffSet.GetNotMissingParts().Contains(bodyPartRecord) == false) - { canDraw = false; return; } - - if (pawn.gender == Gender.Female && bodyAddon.drawForFemale == false || pawn.gender == Gender.Male && bodyAddon.drawForMale == false) - { canDraw = false; return; } - - if (bodyAddon.bodyTypeRequirement.NullOrEmpty() == false && pawn.story.bodyType.ToString() != bodyAddon.bodyTypeRequirement) - { canDraw = false; return; } - - if ((pawn.GetPosture() == PawnPosture.LayingOnGroundNormal || pawn.GetPosture() == PawnPosture.LayingOnGroundFaceUp) && bodyAddon.drawnOnGround == false) - { canDraw = false; return; } + if (pawn.health?.hediffSet?.GetNotMissingParts()?.Contains(bodyPartRecord) == false) + { bodyPartMissing = true; return; } foreach (Apparel apparel in pawn.apparel.WornApparel) { - CompApparelVisibility comp = apparel.TryGetComp(); + CompApparelVisibility comp = apparel?.TryGetComp(); + if (comp == null) continue; + LoadRimNudeData(comp); if (comp.isBeingWorn == false) continue; - if (bodyAddon.bodyPart == "Genitals" || bodyAddon.bodyPart == "Anus" || bodyAddon.bodyPart == "Chest" || bodyAddon.hediffGraphics?.Any(x => x.path.ToLower().Contains("belly")) == true) + if (bodyAddon.bodyPart == "Genitals" || bodyAddon.bodyPart == "Anus" || bodyAddon.bodyPart == "Chest" || bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && x.path.ToLower().Contains("belly")) == true) { if ((bodyAddon.bodyPart == "Genitals" || bodyAddon.bodyPart == "Anus") && comp.coversGroin) { canDraw = false; return; }; @@ -150,16 +162,16 @@ namespace Rimworld_Animations_Patch if (bodyAddon.bodyPart == "Chest" && comp.coversChest) { canDraw = false; return; }; - if (bodyAddon.hediffGraphics?.Any(x => x.path.ToLower().Contains("belly")) == true && comp.coversBelly) + if (bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && x.path.ToLower().Contains("belly")) == true && comp.coversBelly) { canDraw = false; return; } } else { - if (bodyAddon.hiddenUnderApparelFor?.Any(x => apparel.def.apparel.hatRenderedFrontOfFace == false && apparel.def.apparel.bodyPartGroups.Contains(x)) == true) + if (bodyAddon.hiddenUnderApparelFor?.Any(x => apparel?.def.apparel?.hatRenderedFrontOfFace == false && 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) + if (bodyAddon.hiddenUnderApparelTag?.Any(x => apparel?.def.apparel?.hatRenderedFrontOfFace == false && apparel.def.apparel?.tags?.Contains(x) == true) == true) { canDraw = false; return; }; } } @@ -167,12 +179,12 @@ namespace Rimworld_Animations_Patch public void LoadRimNudeData(CompApparelVisibility comp) { - if (comp == null || comp.rimNudeDataStatus == RimNudeDataStatus.Unavailable) + if (comp?.rimNudeDataStatus == RimNudeDataStatus.Unavailable) { return; } - if (comp.rimNudeDataStatus == RimNudeDataStatus.NotLoaded) + if (comp?.rimNudeDataStatus == RimNudeDataStatus.NotLoaded) { - RimNudeData rimNudeData = ApparelSettings.GetRimNudeData(comp.apparel); + RimNudeData rimNudeData = ApparelSettings.GetRimNudeData(comp?.apparel); if (rimNudeData == null) { diff --git a/Source/Scripts/Patches/HarmonyPatch_PawnRenderer.cs b/Source/Scripts/Patches/HarmonyPatch_PawnRenderer.cs index 26b9f7b..a166f84 100644 --- a/Source/Scripts/Patches/HarmonyPatch_PawnRenderer.cs +++ b/Source/Scripts/Patches/HarmonyPatch_PawnRenderer.cs @@ -94,6 +94,8 @@ namespace Rimworld_Animations_Patch } } } + + __instance.pawn.TryGetComp()?.UpdateBodyAddonVisibility(); } } } \ No newline at end of file diff --git a/Source/Scripts/Patches/HarmonyPatch_Rimworld_Animations.cs b/Source/Scripts/Patches/HarmonyPatch_Rimworld_Animations.cs index a9af498..77cd9e4 100644 --- a/Source/Scripts/Patches/HarmonyPatch_Rimworld_Animations.cs +++ b/Source/Scripts/Patches/HarmonyPatch_Rimworld_Animations.cs @@ -109,7 +109,7 @@ namespace Rimworld_Animations_Patch public static bool Prefix_DrawAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation) { if (!(pawn.def is ThingDef_AlienRace alienProps) || renderFlags.FlagSet(PawnRenderFlags.Invisible)) return false; - + // Try to draw apparel thrown on ground if (ApparelSettings.clothesThrownOnGround) { ApparelAnimationUtility.TryToDrawApparelOnFloor(pawn); } @@ -142,7 +142,7 @@ namespace Rimworld_Animations_Patch // Can draw? bool canDraw = addonGraphic.path.ToLower().Contains("featureless") == false && bodyAddonDatum.CanDraw(); bool drawHand = BasicSettings.showHands && handsAvailableCount > 0 && renderFlags.FlagSet(PawnRenderFlags.Portrait) == false; - + if (canDraw == false && drawHand == false) { continue; } diff --git a/Source/Scripts/Settings/ApparelSettings.cs b/Source/Scripts/Settings/ApparelSettings.cs index 48e8041..904d566 100644 --- a/Source/Scripts/Settings/ApparelSettings.cs +++ b/Source/Scripts/Settings/ApparelSettings.cs @@ -86,7 +86,9 @@ namespace Rimworld_Animations_Patch { foreach (Pawn pawn in Current.Game.CurrentMap.mapPawns.AllPawns) { - pawn.Drawer.renderer.graphics.ResolveAllGraphics(); + if (pawn == null) continue; + + pawn.Drawer?.renderer?.graphics?.ResolveAllGraphics(); pawn.TryGetComp()?.UpdateBodyAddonVisibility(); PortraitsCache.SetDirty(pawn); diff --git a/Source/Scripts/Settings/BasicSettings.cs b/Source/Scripts/Settings/BasicSettings.cs index be7a99c..a8c24df 100644 --- a/Source/Scripts/Settings/BasicSettings.cs +++ b/Source/Scripts/Settings/BasicSettings.cs @@ -78,7 +78,10 @@ namespace Rimworld_Animations_Patch { foreach (Pawn pawn in Current.Game.CurrentMap.mapPawns.AllPawns) { - pawn.Drawer.renderer.graphics.ResolveAllGraphics(); + if (pawn == null) continue; + + pawn.Drawer?.renderer?.graphics?.ResolveAllGraphics(); + PortraitsCache.SetDirty(pawn); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn); } diff --git a/Source/obj/Debug/Rimworld-Animations-Patch.csprojAssemblyReference.cache b/Source/obj/Debug/Rimworld-Animations-Patch.csprojAssemblyReference.cache index 4cd5302..55969fa 100644 Binary files a/Source/obj/Debug/Rimworld-Animations-Patch.csprojAssemblyReference.cache and b/Source/obj/Debug/Rimworld-Animations-Patch.csprojAssemblyReference.cache differ diff --git a/Source/obj/Debug/Rimworld-Animations-Patch.dll b/Source/obj/Debug/Rimworld-Animations-Patch.dll index d07b122..e9b46a6 100644 Binary files a/Source/obj/Debug/Rimworld-Animations-Patch.dll and b/Source/obj/Debug/Rimworld-Animations-Patch.dll differ diff --git a/Source/obj/Debug/Rimworld-Animations-Patch.pdb b/Source/obj/Debug/Rimworld-Animations-Patch.pdb index c299208..8e6f46a 100644 Binary files a/Source/obj/Debug/Rimworld-Animations-Patch.pdb and b/Source/obj/Debug/Rimworld-Animations-Patch.pdb differ