This commit is contained in:
AbstractConcept 2022-10-01 21:14:35 -05:00
parent d18d422a94
commit fcf187c7dd
22 changed files with 184 additions and 41 deletions

View file

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using HarmonyLib;
using BabiesAndChildren;
using BabiesAndChildren.api;
namespace Rimworld_Animations_Patch
{
[StaticConstructorOnStartup]
public static class HarmonyPatch_BabiesAndChildren
{
static HarmonyPatch_BabiesAndChildren()
{
try
{
((Action)(() =>
{
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), "GetBodySize"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_BabiesAndChildren), "Prefix_GetBodySize")));
}
}))();
}
catch (TypeLoadException ex) { }
}
public static bool Prefix_ShouldNotDrawAddonsForPawn(ref bool __result, Pawn pawn)
{
__result = AgeStages.IsYoungerThan(pawn, AgeStages.Child, false);
return false;
}
public static bool Prefix_GetBodySize(ref float __result, Pawn pawn)
{
__result = pawn.ShouldBeScaled() ? ChildrenUtility.GetBodySize(pawn) : 1f;
return false;
}
}
}

View file

@ -12,7 +12,7 @@ using rjw;
namespace Rimworld_Animations_Patch
{
[StaticConstructorOnStartup]
/*[StaticConstructorOnStartup]
[HarmonyPatch(typeof(PawnRenderer), "RenderPawnInternal", new Type[]
{
typeof(Vector3),
@ -67,7 +67,7 @@ namespace Rimworld_Animations_Patch
}
}
}
}
}*/
[StaticConstructorOnStartup]
[HarmonyPatch(typeof(PawnGraphicSet), "ResolveAllGraphics")]

View file

@ -38,6 +38,4 @@ namespace Rimworld_Animations_Patch
__instance?.pawn?.TryGetComp<CompPawnSexData>()?.UpdateBodyAddonVisibility();
}
}
}

View file

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using HarmonyLib;
using RJW_Events;
namespace Rimworld_Animations_Patch
{
[StaticConstructorOnStartup]
public static class HarmonyPatch_RJWEvents
{
static HarmonyPatch_RJWEvents()
{
try
{
((Action)(() =>
{
if (LoadedModManager.RunningModsListForReading.Any(x => x.PackageIdPlayerFacing == "c0ffee.rjw.events"))
{
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(typeof(ThinkNode_ConditionalNude), "Satisfied"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_RJWEvents), "Postfix_ThinkNode_ConditionalNude_Satisfied")));
}
}))();
}
catch (TypeLoadException ex) { }
}
public static bool Postfix_ThinkNode_ConditionalNude_Satisfied(ref bool __result, Pawn pawn)
{
if (__result == false && pawn?.apparel?.WornApparel != null)
{
// If 'isBeingWorn' has a value, the apparel has already been checked if it should be discarded
if (pawn.apparel.WornApparel.Any(x => x.TryGetComp<CompApparelVisibility>() != null && x.TryGetComp<CompApparelVisibility>().isBeingWorn.HasValue))
{ __result = true; }
}
return false;
}
}
}

View file

@ -95,7 +95,6 @@ namespace Rimworld_Animations_Patch
DebugMode.Message("Running animation: " + anim.defName);
List<Pawn> pawnsToAnimate = pawn.GetAllSexParticipants();
Pawn Target = pawn.GetSexReceiver();
foreach (Pawn participant in pawnsToAnimate)
{
@ -109,7 +108,9 @@ 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;
if (AnimationPatchUtility.ShouldNotDrawAddonsForPawn(pawn))
{ return false; }
// Try to draw apparel thrown on ground
if (ApparelSettings.clothesThrownOnGround)
{ ApparelAnimationUtility.TryToDrawApparelOnFloor(pawn); }
@ -168,8 +169,22 @@ namespace Rimworld_Animations_Patch
bodyAddonAngle = bodyAddonAngle < 0f ? 360f - (bodyAddonAngle % 360) : bodyAddonAngle % 360f;
float combinedAngle = (bodyAngle + bodyAddonAngle) < 0f ? 360f + ((bodyAngle + bodyAddonAngle) % 360) : (bodyAngle + bodyAddonAngle) % 360f;
Vector3 bodyAddonPosition = vector + (bodyAddonDatum.alignsWithHead ? headOffset : Vector3.zero) + bodyAddonDatum.GetOffset(rotation).RotatedBy(angle: bodyAngle);
Vector3 vector_ = vector;
Vector3 headOffset_ = bodyAddonDatum.alignsWithHead ? headOffset : Vector3.zero;
Vector3 bodyAddonOffset_ = bodyAddonDatum.GetOffset(apparentRotation).RotatedBy(angle: bodyAngle);
if (pawn.ageTracker.Adult == false)
{
float bodySize = AnimationPatchUtility.GetBodySize(pawn);
addonGraphic.drawSize = new Vector2(1.5f * bodySize, 1.5f * bodySize); // Doesn't seem to be a need to scale by body part draw size (re: Orassians)
Vector2 multi = AnimationPatchUtility.GetRaceSpecificOffsetMultipliers(pawn, bodyAddon.bodyPart);
bodyAddonOffset_.x *= bodySize * multi.x;
bodyAddonOffset_.z *= bodySize * multi.y;
}
Vector3 bodyAddonPosition = vector_ + headOffset_ + bodyAddonOffset_;
// Draw the addon if visible
if (canDraw)
{

View file

@ -6,25 +6,9 @@ using System.Threading.Tasks;
using RimWorld;
using Verse;
using HarmonyLib;
using RJW_Events;
namespace Rimworld_Animations_Patch
{
[HarmonyPatch(typeof(ThinkNode_ConditionalNude), "Satisfied")]
public static class HarmonyPatch_ThinkNode_ConditionalNude
{
public static void Postfix(ref bool __result, Pawn pawn)
{
if (__result == false && pawn?.apparel?.WornApparel != null)
{
// If 'isBeingWorn' has a value, the apparel has already been checked if it should be discarded
if (pawn.apparel.WornApparel.Any(x => x.TryGetComp<CompApparelVisibility>() != null && x.TryGetComp<CompApparelVisibility>().isBeingWorn.HasValue))
{ __result = true; return; }
}
}
}
[HarmonyPatch(typeof(ThoughtWorker_Precept_GroinChestHairOrFaceUncovered), "HasUncoveredGroinChestHairOrFace")]
public static class HarmonyPatch_ThoughtWorker_Precept_GroinChestHairOrFaceUncovered
{