mirror of
https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
synced 2024-08-15 00:43:27 +00:00
v 1.2.2
This commit is contained in:
parent
dab724fb50
commit
f089b94044
46 changed files with 2631 additions and 393 deletions
|
@ -31,6 +31,9 @@ namespace Rimworld_Animations_Patch
|
|||
graphic = GraphicMaskingUtility.ApplyGraphicWithMasks(graphic, graphicWithApparelMask, true);
|
||||
|
||||
//DebugMode.Message("Applying apparel mask: Masks/apparel_shirt_mask_" + bodyType.defName + " to " + apparel.def.defName + " (" + graphic.path + ")");
|
||||
|
||||
if (apparel.Wearer != null)
|
||||
{ PortraitsCache.SetDirty(apparel.Wearer); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Rimworld_Animations_Patch
|
|||
|
||||
if (comp != null)
|
||||
{
|
||||
comp.isBeingWorn = true;
|
||||
comp.isBeingWorn = null;
|
||||
comp.rimNudeDataStatus = RimNudeDataStatus.NotLoaded;
|
||||
}
|
||||
}
|
||||
|
|
43
Source/Scripts/Patches/HarmonyPatch_Pawn_ApparelTracker.cs
Normal file
43
Source/Scripts/Patches/HarmonyPatch_Pawn_ApparelTracker.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace Rimworld_Animations_Patch
|
||||
{
|
||||
[HarmonyPatch(typeof(Pawn_ApparelTracker), "HasBasicApparel")]
|
||||
public static class HarmonyPatch_Pawn_ApparelTracker_HasBasicApparel
|
||||
{
|
||||
public static void Postfix(Pawn_ApparelTracker __instance, ref bool hasPants, ref bool hasShirt)
|
||||
{
|
||||
if (__instance?.pawn?.apparel?.WornApparel == null || __instance.pawn.apparel.WornApparel.NullOrEmpty()) return;
|
||||
|
||||
if (hasPants == false)
|
||||
{
|
||||
if (__instance.pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.GenitalsBPG)))
|
||||
{ hasPants = true; }
|
||||
}
|
||||
|
||||
if (hasShirt == false)
|
||||
{
|
||||
if (__instance.pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.ChestBPG)))
|
||||
{ hasShirt = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Pawn_ApparelTracker), "Notify_ApparelChanged")]
|
||||
public static class HarmonyPatch_Pawn_ApparelTracker_Notify_ApparelChanged
|
||||
{
|
||||
public static void Postfix(Pawn_ApparelTracker __instance)
|
||||
{
|
||||
__instance?.pawn?.TryGetComp<CompPawnSexData>()?.UpdateBodyAddonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -16,29 +16,30 @@ namespace Rimworld_Animations_Patch
|
|||
{
|
||||
public static void Postfix(ref JobDriver_Sex __instance)
|
||||
{
|
||||
Pawn pawn = __instance.pawn;
|
||||
|
||||
// Sets ticks so that the orgasm meter starts empty, plus stop any running animations
|
||||
HarmonyPatch_JobDriver_Masturbate_setup_ticks.Postfix(ref __instance);
|
||||
|
||||
// Invite another for a threesome?
|
||||
if (RJWHookupSettings.QuickHookupsEnabled &&
|
||||
__instance is JobDriver_SexBaseInitiator &&
|
||||
__instance.pawn.GetAllSexParticipants().Count == 2 &&
|
||||
pawn.GetAllSexParticipants().Count == 2 &&
|
||||
(__instance is JobDriver_JoinInSex) == false &&
|
||||
Random.value < BasicSettings.chanceForOtherToJoinInSex)
|
||||
{
|
||||
DebugMode.Message("Find another to join in sex");
|
||||
|
||||
Pawn pawn = __instance.pawn;
|
||||
List<Pawn> candidates = new List<Pawn>();
|
||||
float radius = 4f;
|
||||
|
||||
foreach (Thing thing in GenRadial.RadialDistinctThingsAround(pawn.Position, pawn.Map, radius, true))
|
||||
{
|
||||
Pawn other = thing as Pawn;
|
||||
ThoughtDef thoughtDef = SexInteractionUtility.GetThoughtsAboutSexAct(other, __instance, out Precept precept);
|
||||
|
||||
// Find candidates to invite
|
||||
if (other != null && (int)SexInteractionUtility.CheckSexJobAgainstMorals(other, __instance, out Precept precept) <= 0 &&
|
||||
SexInteractionUtility.PawnCanInvitePasserbyForSex(other, pawn.GetAllSexParticipants()))
|
||||
if (other != null && thoughtDef?.hediff == null && SexInteractionUtility.InvitePasserbyForSex(other, pawn.GetAllSexParticipants()))
|
||||
{
|
||||
DebugMode.Message(other.NameShortColored + " is a potential candidate");
|
||||
candidates.Add(other);
|
||||
|
@ -436,7 +437,7 @@ namespace Rimworld_Animations_Patch
|
|||
{
|
||||
public static bool Prefix(Pawn pawn, bool keep_hat_on)
|
||||
{
|
||||
if (!xxx.is_human(pawn)) return false;
|
||||
if (pawn == null || !xxx.is_human(pawn)) return false;
|
||||
if (pawn.Map != Find.CurrentMap) return false;
|
||||
|
||||
pawn.Drawer.renderer.graphics.ClearCache();
|
||||
|
@ -448,10 +449,11 @@ namespace Rimworld_Animations_Patch
|
|||
{
|
||||
CompApparelVisibility comp = apparel.TryGetComp<CompApparelVisibility>();
|
||||
|
||||
if ((comp == null || comp.isBeingWorn) && ApparelGraphicRecordGetter.TryGetGraphicApparel(apparel, pawn.story.bodyType, out ApparelGraphicRecord item))
|
||||
if (comp != null && comp.isBeingWorn == true && ApparelGraphicRecordGetter.TryGetGraphicApparel(apparel, pawn.story.bodyType, out ApparelGraphicRecord item))
|
||||
{ pawn.Drawer.renderer.graphics.apparelGraphics.Add(item); }
|
||||
}
|
||||
|
||||
pawn?.TryGetComp<CompPawnSexData>()?.UpdateBodyAddonVisibility();
|
||||
GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn);
|
||||
|
||||
return false;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Rimworld_Animations_Patch
|
|||
[StaticConstructorOnStartup]
|
||||
public static class HarmonyPatch_RimNudeWorld
|
||||
{
|
||||
/*static HarmonyPatch_RimNudeWorld()
|
||||
static HarmonyPatch_RimNudeWorld()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace Rimworld_Animations_Patch
|
|||
if (LoadedModManager.RunningModsListForReading.Any(x => x.PackageIdPlayerFacing == "shauaputa.rimnudeworld"))
|
||||
{
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("RevealingApparel.HarmonyPatch_DrawAddons"), "Postfix"),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_RimNudeWorld), "Prefix_DrawAddons")));
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_RimNudeWorld), "Prefix_HarmonyPatch_DrawAddons")));
|
||||
}
|
||||
}))();
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ namespace Rimworld_Animations_Patch
|
|||
}
|
||||
|
||||
// Patch RimNudeWorld to override the revealing apparel feature; this task is handled by the new apparel settings system
|
||||
public static bool Prefix_DrawAddons()
|
||||
public static bool Prefix_HarmonyPatch_DrawAddons()
|
||||
{
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,19 +24,42 @@ namespace Rimworld_Animations_Patch
|
|||
postfix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Postfix_RerollAnimations")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("Rimworld_Animations.HarmonyPatch_AlienRace"), "Prefix_AnimateHeadAddons"),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Prefix_DrawAddons")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("BodyAddon"), "CanDrawAddon"),
|
||||
postfix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Postfix_CanDrawAddon")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("Rimworld_Animations.CompBodyAnimator"), "StartAnimation"),
|
||||
postfix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Postfix_StartAnimation")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("Rimworld_Animations.AnimationUtility"), "tryFindAnimation"),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Prefix_tryFindAnimation")));
|
||||
}
|
||||
|
||||
// Update hand count for all participants before finding an animation
|
||||
public static void Prefix_tryFindAnimation(ref List<Pawn> participants)
|
||||
{
|
||||
foreach (Pawn participant in participants)
|
||||
{
|
||||
CompPawnSexData comp = participant.TryGetComp<CompPawnSexData>();
|
||||
if (comp == null) return;
|
||||
|
||||
comp.UpdateHands();
|
||||
}
|
||||
}
|
||||
|
||||
// Update hand animation def on anim start
|
||||
public static void Postfix_StartAnimation(CompBodyAnimator __instance)
|
||||
{
|
||||
CompPawnSexData comp = __instance.pawn.TryGetComp<CompPawnSexData>();
|
||||
if (comp == null) return;
|
||||
|
||||
comp.handAnimationDef = DefDatabase<HandAnimationDef>.AllDefs.FirstOrDefault(x => x.animationDefName == __instance.pawn?.GetAnimationData()?.animationDef?.defName);
|
||||
}
|
||||
|
||||
// Extend the animation selector's body part check to include hands and whether the pawn is in bed or not
|
||||
public static void PostFix_AnimationUtility_GenitalCheckForPawn(ref bool __result, List<string> requiredGenitals, Pawn pawn, ref string failReason)
|
||||
{
|
||||
int handCount = 0;
|
||||
bool pawnInBed = pawn.IsInBed(out Building bed);
|
||||
int? handCount = pawn.TryGetComp<CompPawnSexData>()?.GetNumberOfHands();
|
||||
|
||||
if (handCount.HasValue == false)
|
||||
{ handCount = 0; }
|
||||
|
||||
var hands = pawn.health.hediffSet.GetNotMissingParts().Where(x => x.def.defName == "Hand");
|
||||
if (hands != null)
|
||||
{ handCount = hands.Count(); }
|
||||
bool pawnInBed = pawn.IsInBed(out Building bed);
|
||||
|
||||
if (requiredGenitals.NullOrEmpty())
|
||||
{ return; }
|
||||
|
@ -82,28 +105,6 @@ namespace Rimworld_Animations_Patch
|
|||
}
|
||||
}
|
||||
|
||||
// Determine if a body addon is covered by apparel
|
||||
public static bool BodyAddonCoveredByWornApparel(Pawn pawn, AlienPartGenerator.BodyAddon bodyAddon)
|
||||
{
|
||||
if (pawn?.apparel?.WornApparel == null || bodyAddon == null)
|
||||
{ return false; }
|
||||
|
||||
foreach (Apparel apparel in pawn.apparel.WornApparel)
|
||||
{
|
||||
if (ApparelAnimationUtility.PrivatePartCoveredByApparel(apparel, bodyAddon.bodyPart))
|
||||
{ return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Postfix_CanDrawAddon(AlienPartGenerator.BodyAddon __instance, ref bool __result, Pawn pawn)
|
||||
{
|
||||
if (__result == false) return;
|
||||
|
||||
__result = BodyAddonCoveredByWornApparel(pawn, __instance) == false;
|
||||
}
|
||||
|
||||
// Replacement patch for AlienRace to draw the body addons
|
||||
public static bool Prefix_DrawAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
|
||||
{
|
||||
|
@ -113,14 +114,15 @@ namespace Rimworld_Animations_Patch
|
|||
if (ApparelSettings.clothesThrownOnGround)
|
||||
{ ApparelAnimationUtility.TryToDrawApparelOnFloor(pawn); }
|
||||
|
||||
// Get components
|
||||
// Get actor components and body addons
|
||||
List<AlienPartGenerator.BodyAddon> bodyAddons = alienProps.alienRace.generalSettings.alienPartGenerator.bodyAddons.ToList();
|
||||
AlienPartGenerator.AlienComp alienComp = pawn.GetComp<AlienPartGenerator.AlienComp>();
|
||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||
CompBodyAnimator animatorComp = pawn.TryGetComp<CompBodyAnimator>();
|
||||
CompPawnSexData sexDataComp = pawn.TryGetComp<CompPawnSexData>();
|
||||
if (sexDataComp == null) return true;
|
||||
|
||||
// Get available hands
|
||||
var hands = pawn.health.hediffSet.GetNotMissingParts().Where(x => x.def.defName == "Hand");
|
||||
int handsAvailableCount = hands.Count();
|
||||
int handsAvailableCount = sexDataComp.GetNumberOfHands();
|
||||
|
||||
// Sort addons by their layer offset, otherwise body parts will actualy be layered according to their position in the list
|
||||
// Note that sorting the addons directly seems to mess up relations between lists need by AlienRace
|
||||
|
@ -131,129 +133,59 @@ namespace Rimworld_Animations_Patch
|
|||
{
|
||||
int i = idxBodyAddons[idx];
|
||||
|
||||
// Get body addon components
|
||||
AlienPartGenerator.BodyAddon bodyAddon = bodyAddons[i];
|
||||
Graphic addonGraphic = alienComp.addonGraphics[i];
|
||||
BodyAddonData bodyAddonDatum = sexDataComp.GetBodyAddonData(bodyAddon, renderFlags.FlagSet(PawnRenderFlags.Portrait));
|
||||
if (bodyAddonDatum == null) continue;
|
||||
|
||||
bool canDraw = addonGraphic.path.ToLower().Contains("featureless") == false && bodyAddon.CanDrawAddon(pawn);
|
||||
bool drawHand = !renderFlags.FlagSet(PawnRenderFlags.Portrait) && BasicSettings.showHands && handsAvailableCount > 0 && HandAnimationUtility.BodyPartIsBeingTouched(pawn, addonGraphic.path, out var handData);
|
||||
|
||||
// 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; }
|
||||
|
||||
BodyPartRecord bodyPartRecord = AnimationPatchUtility.GetBodyPartRecord(pawn, bodyAddon.bodyPart);
|
||||
bool alignWithHead = bodyAddon.alignWithHead || (bodyPartRecord != null && bodyPartRecord.IsInGroup(BodyPartGroupDefOf.FullHead));
|
||||
// Get body angle
|
||||
float bodyAngle = animatorComp?.isAnimating == true && renderFlags.FlagSet(PawnRenderFlags.Portrait) == false ? animatorComp.bodyAngle : quat.eulerAngles.y;
|
||||
bodyAngle = bodyAngle < 0f ? 360f + (bodyAngle % 360f) : bodyAngle % 360f;
|
||||
|
||||
// Get the apparent rotation and body addon angle
|
||||
Rot4 apparentRotation = rotation;
|
||||
if (!renderFlags.FlagSet(PawnRenderFlags.Portrait) && pawnAnimator != null && pawnAnimator.isAnimating)
|
||||
{ apparentRotation = alignWithHead ? pawnAnimator.headFacing : pawnAnimator.bodyFacing; }
|
||||
|
||||
AlienPartGenerator.RotationOffset defaultOffsets = bodyAddon.defaultOffsets.GetOffset(apparentRotation);
|
||||
Vector3 bodyTypeOffset = (defaultOffsets != null) ? defaultOffsets.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, alienComp.crownType) : Vector3.zero;
|
||||
AlienPartGenerator.RotationOffset offsets = bodyAddon.offsets.GetOffset(apparentRotation);
|
||||
Vector3 vector2 = bodyTypeOffset + ((offsets != null) ? offsets.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, alienComp.crownType) : Vector3.zero);
|
||||
|
||||
// Offset private parts so that they render over tattoos but under apparel (rendering under tatoos looks weird)
|
||||
if ((bodyPartRecord != null && (bodyPartRecord.IsInGroup(PatchBodyPartGroupDefOf.GenitalsBPG) || bodyPartRecord.IsInGroup(PatchBodyPartGroupDefOf.ChestBPG) || bodyPartRecord.IsInGroup(PatchBodyPartGroupDefOf.AnusBPG))) || addonGraphic.path.ToLower().Contains("belly"))
|
||||
{
|
||||
vector2.y = (vector2.y + 0.40f) / 1000f + 0.012f;
|
||||
|
||||
// Erected penises should be drawn over apparel
|
||||
if (pawn.RaceProps.Humanlike &&
|
||||
addonGraphic.path.ToLower().Contains("penis") &&
|
||||
addonGraphic.path.ToLower().Contains("flaccid") == false &&
|
||||
apparentRotation == Rot4.South)
|
||||
{ vector2.y += 0.010f; }
|
||||
}
|
||||
|
||||
// Otherwise use the standard offsets
|
||||
else
|
||||
{ vector2.y = 0.3f + vector2.y; }
|
||||
|
||||
if (!bodyAddon.inFrontOfBody)
|
||||
{ vector2.y *= -1f; }
|
||||
|
||||
float bodyAddonAngle = bodyAddon.angle;
|
||||
|
||||
if (apparentRotation == Rot4.North)
|
||||
if (renderFlags.FlagSet(PawnRenderFlags.Portrait) == false && animatorComp?.isAnimating == true)
|
||||
{
|
||||
if (bodyAddon.layerInvert)
|
||||
{ vector2.y = -vector2.y; }
|
||||
apparentRotation = bodyAddonDatum.alignsWithHead ? animatorComp.headFacing : animatorComp.bodyFacing;
|
||||
|
||||
bodyAddonAngle = 0f;
|
||||
if (animatorComp.controlGenitalAngle && addonGraphic.path.ToLower().Contains("penis"))
|
||||
{ bodyAddonAngle += AnimationSettings.controlGenitalRotation ? animatorComp.genitalAngle : 0f; }
|
||||
|
||||
if (bodyAddonDatum.alignsWithHead)
|
||||
{ bodyAngle = animatorComp.headAngle; }
|
||||
}
|
||||
|
||||
if (apparentRotation == Rot4.East)
|
||||
{
|
||||
bodyAddonAngle = -bodyAddonAngle;
|
||||
vector2.x = -vector2.x;
|
||||
}
|
||||
|
||||
Quaternion addonRotation = quat;
|
||||
Quaternion quatAdditional = Quaternion.identity;
|
||||
|
||||
float finalAngle = 0;
|
||||
|
||||
if (!renderFlags.FlagSet(PawnRenderFlags.Portrait) && pawnAnimator != null && pawnAnimator.isAnimating)
|
||||
{
|
||||
if (pawnAnimator.controlGenitalAngle && bodyAddon?.hediffGraphics != null && !bodyAddon.hediffGraphics.NullOrEmpty() && bodyAddon.hediffGraphics[0]?.path != null && (bodyAddon.hediffGraphics[0].path.Contains("Penis") || bodyAddon.hediffGraphics[0].path.Contains("penis")))
|
||||
{
|
||||
float bodyAngle = pawnAnimator.bodyAngle;
|
||||
addonRotation = Quaternion.AngleAxis(angle: bodyAngle, axis: Vector3.up);
|
||||
|
||||
float anglePenis = AnimationSettings.controlGenitalRotation ? pawnAnimator.genitalAngle : 0f;
|
||||
anglePenis = anglePenis < 0 ? 360 - (360 % anglePenis) : anglePenis;
|
||||
quatAdditional = Quaternion.AngleAxis(angle: anglePenis, axis: Vector3.up);
|
||||
|
||||
finalAngle = bodyAngle + anglePenis;
|
||||
}
|
||||
|
||||
else if (alignWithHead)
|
||||
{
|
||||
float headAngle = pawnAnimator.headAngle;
|
||||
headAngle = headAngle < 0 ? 360 - (360 % headAngle) : headAngle;
|
||||
addonRotation = Quaternion.AngleAxis(angle: headAngle, axis: Vector3.up);
|
||||
|
||||
finalAngle = pawnAnimator.bodyAngle + headAngle;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
float bodyAngle = pawnAnimator.bodyAngle;
|
||||
addonRotation = Quaternion.AngleAxis(angle: bodyAngle, axis: Vector3.up);
|
||||
|
||||
finalAngle = bodyAngle;
|
||||
}
|
||||
}
|
||||
|
||||
// Fixes 'leaning left' issue with Yayo's animations
|
||||
else if (!renderFlags.FlagSet(PawnRenderFlags.Portrait) && (pawnAnimator == null || pawnAnimator.isAnimating == false))
|
||||
{
|
||||
float bodyAngle = addonRotation.eulerAngles.y;
|
||||
bodyAngle = bodyAngle < 0 ? 360 - (360 % bodyAngle) : bodyAngle;
|
||||
addonRotation = Quaternion.AngleAxis(angle: bodyAngle, axis: Vector3.up);
|
||||
}
|
||||
|
||||
if (alignWithHead && bodyAddon.alignWithHead == false)
|
||||
{ vector2 -= pawn.Drawer.renderer.BaseHeadOffsetAt(apparentRotation); }
|
||||
|
||||
Vector3 finalPosition = vector + (alignWithHead ? headOffset : Vector3.zero) + vector2.RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: addonRotation)) * 2f * 57.29578f);
|
||||
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);
|
||||
|
||||
// Draw the addon if visible
|
||||
if (canDraw)
|
||||
{
|
||||
//DebugMode.Message("Drawing " + addonGraphic.path);
|
||||
|
||||
GenDraw.DrawMeshNowOrLater(mesh: addonGraphic.MeshAt(rot: apparentRotation),
|
||||
loc: finalPosition,
|
||||
quat: Quaternion.AngleAxis(angle: bodyAddonAngle, axis: Vector3.up) * quatAdditional * addonRotation,
|
||||
loc: bodyAddonPosition,
|
||||
quat: Mathf.Approximately(combinedAngle, 0f) ? quat : Quaternion.AngleAxis(angle: combinedAngle, axis: Vector3.up),
|
||||
mat: addonGraphic.MatAt(rot: apparentRotation),
|
||||
drawNow: renderFlags.FlagSet(PawnRenderFlags.DrawNow));
|
||||
}
|
||||
|
||||
// Draw hand over the body part if required
|
||||
if (drawHand)
|
||||
{
|
||||
if (HandAnimationUtility.TryToDrawHand(pawn, addonGraphic.path, finalPosition, finalAngle, rotation, renderFlags))
|
||||
{
|
||||
float finalAngle = 0;
|
||||
|
||||
if (HandAnimationUtility.TryToDrawHand(pawn, addonGraphic.path, bodyAddonPosition, finalAngle, rotation, renderFlags))
|
||||
{ handsAvailableCount--; }
|
||||
}
|
||||
}
|
||||
|
@ -263,8 +195,8 @@ namespace Rimworld_Animations_Patch
|
|||
{
|
||||
var methodInfo = AccessTools.Method(typeof(PawnRenderer), "DrawHeadHair", null, null);
|
||||
|
||||
Rot4 headFacing = pawnAnimator != null && pawnAnimator.isAnimating && !renderFlags.FlagSet(PawnRenderFlags.Portrait) ? pawnAnimator.headFacing : rotation;
|
||||
float headAngle = pawnAnimator != null && pawnAnimator.isAnimating && !renderFlags.FlagSet(PawnRenderFlags.Portrait) ? pawnAnimator.headAngle : quat.eulerAngles.y;
|
||||
Rot4 headFacing = animatorComp != null && animatorComp.isAnimating && !renderFlags.FlagSet(PawnRenderFlags.Portrait) ? animatorComp.headFacing : rotation;
|
||||
float headAngle = animatorComp != null && animatorComp.isAnimating && !renderFlags.FlagSet(PawnRenderFlags.Portrait) ? animatorComp.headAngle : quat.eulerAngles.y;
|
||||
RotDrawMode rotDrawMode = (RotDrawMode)AccessTools.Property(typeof(PawnRenderer), "CurRotDrawMode").GetValue(pawn.Drawer.renderer);
|
||||
|
||||
methodInfo.Invoke(pawn.Drawer.renderer, new object[] { vector + new Vector3(0f, YOffset_Head, 0f), headOffset, headAngle, headFacing, headFacing, rotDrawMode, renderFlags });
|
||||
|
@ -303,5 +235,5 @@ namespace Rimworld_Animations_Patch
|
|||
Hair = rootLoc + YOffset_OnHead; (~ 0.029)
|
||||
Hat (over hair) = rootLoc + YOffset_PostHead; (~ 0.031)
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
Source/Scripts/Patches/HarmonyPatch_ThoughtWorkers.cs
Normal file
123
Source/Scripts/Patches/HarmonyPatch_ThoughtWorkers.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
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
|
||||
{
|
||||
public static void Postfix(ref bool __result, Pawn p)
|
||||
{
|
||||
if (__result == false) return;
|
||||
|
||||
Pawn pawn = p;
|
||||
if (ApparelSettings.underwearSufficentForIdeos == false) return;
|
||||
|
||||
if (pawn?.apparel == null)
|
||||
{ __result = false; return; }
|
||||
|
||||
if (pawn.apparel.WornApparel.NullOrEmpty())
|
||||
{ __result = true; return; }
|
||||
|
||||
bool fullHeadCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.FullHead));
|
||||
bool groinCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) || x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.GenitalsBPG));
|
||||
bool chestCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) || x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.ChestBPG));
|
||||
bool faceCovered = fullHeadCovered || pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Eyes));
|
||||
bool hairCovered = fullHeadCovered || pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.UpperHead));
|
||||
|
||||
__result = !(groinCovered && chestCovered && faceCovered && hairCovered);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ThoughtWorker_Precept_GroinChestOrHairUncovered), "HasUncoveredGroinChestOrHair")]
|
||||
public static class HarmonyPatch_ThoughtWorker_Precept_GroinChestOrHairUncovered
|
||||
{
|
||||
public static void Postfix(ref bool __result, Pawn p)
|
||||
{
|
||||
if (__result == false) return;
|
||||
|
||||
Pawn pawn = p;
|
||||
if (ApparelSettings.underwearSufficentForIdeos == false) return;
|
||||
|
||||
if (pawn?.apparel == null)
|
||||
{ __result = false; return; }
|
||||
|
||||
if (pawn.apparel.WornApparel.NullOrEmpty())
|
||||
{ __result = true; return; }
|
||||
|
||||
bool fullHeadCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.FullHead));
|
||||
bool groinCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) || x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.GenitalsBPG));
|
||||
bool chestCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) || x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.ChestBPG));
|
||||
bool hairCovered = fullHeadCovered || pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.UpperHead));
|
||||
|
||||
__result = !(groinCovered && chestCovered && hairCovered);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ThoughtWorker_Precept_GroinOrChestUncovered), "HasUncoveredGroinOrChest")]
|
||||
public static class HarmonyPatch_ThoughtWorker_Precept_HasUncoveredGroinOrChest
|
||||
{
|
||||
public static void Postfix(ref bool __result, Pawn p)
|
||||
{
|
||||
if (__result == false) return;
|
||||
|
||||
Pawn pawn = p;
|
||||
if (ApparelSettings.underwearSufficentForIdeos == false) return;
|
||||
|
||||
if (pawn?.apparel == null)
|
||||
{ __result = false; return; }
|
||||
|
||||
if (pawn.apparel.WornApparel.NullOrEmpty())
|
||||
{ __result = true; return; }
|
||||
|
||||
bool groinCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) || x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.GenitalsBPG));
|
||||
bool chestCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) || x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.ChestBPG));
|
||||
|
||||
__result = !(groinCovered && chestCovered);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ThoughtWorker_Precept_GroinUncovered), "HasUncoveredGroin")]
|
||||
public static class HarmonyPatch_ThoughtWorker_Precept_GroinUncovered
|
||||
{
|
||||
public static void Postfix(ref bool __result, Pawn p)
|
||||
{
|
||||
if (__result == false) return;
|
||||
|
||||
Pawn pawn = p;
|
||||
if (ApparelSettings.underwearSufficentForIdeos == false) return;
|
||||
|
||||
if (pawn?.apparel == null)
|
||||
{ __result = false; return; }
|
||||
|
||||
if (pawn.apparel.WornApparel.NullOrEmpty())
|
||||
{ __result = true; return; }
|
||||
|
||||
bool groinCovered = pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) || x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.GenitalsBPG));
|
||||
|
||||
__result = !groinCovered;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue