Fast IsAnimating checks
This commit is contained in:
parent
6cffdfef95
commit
3743248e9a
|
@ -1,9 +1,5 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using rjw;
|
using rjw;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -13,6 +9,15 @@ using Verse.Sound;
|
||||||
namespace Rimworld_Animations {
|
namespace Rimworld_Animations {
|
||||||
public class CompBodyAnimator : ThingComp
|
public class CompBodyAnimator : ThingComp
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Cache of the currently animated pawns for the very fast isAnimating checks
|
||||||
|
/// </summary>
|
||||||
|
private static readonly HashSet<Pawn> animatingPawns = new HashSet<Pawn>();
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the <paramref name="pawn"/> is currently animated by this comp
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsAnimating(Pawn pawn) => animatingPawns.Contains(pawn);
|
||||||
|
|
||||||
public Pawn pawn => base.parent as Pawn;
|
public Pawn pawn => base.parent as Pawn;
|
||||||
public PawnGraphicSet Graphics;
|
public PawnGraphicSet Graphics;
|
||||||
|
|
||||||
|
@ -27,9 +32,11 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
if (value == true) {
|
if (value == true) {
|
||||||
SexUtility.DrawNude(pawn);
|
SexUtility.DrawNude(pawn);
|
||||||
|
animatingPawns.Add(pawn);
|
||||||
} else {
|
} else {
|
||||||
pawn.Drawer.renderer.graphics.ResolveAllGraphics();
|
pawn.Drawer.renderer.graphics.ResolveAllGraphics();
|
||||||
actorsInCurrentAnimation = null;
|
actorsInCurrentAnimation = null;
|
||||||
|
animatingPawns.Remove(pawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
PortraitsCache.SetDirty(pawn);
|
PortraitsCache.SetDirty(pawn);
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
using System;
|
using RimWorld;
|
||||||
using System.Collections.Generic;
|
|
||||||
using RimWorld;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Verse;
|
using Verse;
|
||||||
using Rimworld_Animations;
|
|
||||||
|
|
||||||
namespace Rimworld_Animations {
|
namespace Rimworld_Animations {
|
||||||
|
|
||||||
|
@ -17,9 +14,9 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
if (!flags.FlagSet(PawnRenderFlags.Portrait) && layer == PawnOverlayDrawer.OverlayLayer.Head)
|
if (!flags.FlagSet(PawnRenderFlags.Portrait) && layer == PawnOverlayDrawer.OverlayLayer.Head)
|
||||||
{
|
{
|
||||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
if (CompBodyAnimator.IsAnimating(pawn) && pawn.Drawer.renderer.graphics.headGraphic != null)
|
||||||
if (pawnAnimator != null && pawnAnimator.isAnimating && pawn.Drawer.renderer.graphics.headGraphic != null)
|
|
||||||
{
|
{
|
||||||
|
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
pawnRot = pawnAnimator.headFacing;
|
pawnRot = pawnAnimator.headFacing;
|
||||||
quat = Quaternion.AngleAxis(angle: pawnAnimator.headAngle, axis: Vector3.up);
|
quat = Quaternion.AngleAxis(angle: pawnAnimator.headAngle, axis: Vector3.up);
|
||||||
float y = drawLoc.y;
|
float y = drawLoc.y;
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Verse;
|
using Verse;
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -25,14 +21,13 @@ namespace Rimworld_Animations {
|
||||||
listingStandard.GapLine();
|
listingStandard.GapLine();
|
||||||
|
|
||||||
|
|
||||||
if (Find.Selector.SingleSelectedThing is Pawn) {
|
if (Find.Selector.SingleSelectedThing is Pawn curPawn) {
|
||||||
|
|
||||||
Pawn curPawn = Find.Selector.SingleSelectedThing as Pawn;
|
if (CompBodyAnimator.IsAnimating(curPawn)) {
|
||||||
|
|
||||||
if (curPawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
CompBodyAnimator compBodyAnimator = curPawn.TryGetComp<CompBodyAnimator>();
|
||||||
|
AnimationDef def = compBodyAnimator.CurrentAnimation;
|
||||||
AnimationDef def = curPawn.TryGetComp<CompBodyAnimator>().CurrentAnimation;
|
int ActorIndex = compBodyAnimator.ActorIndex;
|
||||||
int ActorIndex = curPawn.TryGetComp<CompBodyAnimator>().ActorIndex;
|
|
||||||
float offsetX = 0, offsetZ = 0, rotation = 0;
|
float offsetX = 0, offsetZ = 0, rotation = 0;
|
||||||
|
|
||||||
string bodyTypeDef = (curPawn.story?.bodyType != null) ? curPawn.story.bodyType.ToString() : "";
|
string bodyTypeDef = (curPawn.story?.bodyType != null) ? curPawn.story.bodyType.ToString() : "";
|
||||||
|
@ -57,8 +52,6 @@ namespace Rimworld_Animations {
|
||||||
listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets");
|
listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mirrored = curPawn.TryGetComp<CompBodyAnimator>().Mirror;
|
|
||||||
|
|
||||||
float.TryParse(listingStandard.TextEntryLabeled("X Offset: ", offsetX.ToString()), out offsetX);
|
float.TryParse(listingStandard.TextEntryLabeled("X Offset: ", offsetX.ToString()), out offsetX);
|
||||||
offsetX = listingStandard.Slider(offsetX, -2, 2);
|
offsetX = listingStandard.Slider(offsetX, -2, 2);
|
||||||
|
|
||||||
|
|
|
@ -23,17 +23,16 @@ namespace Rimworld_Animations {
|
||||||
}
|
}
|
||||||
}))();
|
}))();
|
||||||
}
|
}
|
||||||
catch (TypeLoadException ex) {
|
catch (TypeLoadException) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Prefix(ref Pawn ___pawn, ref Rot4 headFacing, ref Vector3 headOrigin, ref Quaternion quaternion, ref bool portrait) {
|
public static bool Prefix(Pawn ___pawn, ref Rot4 headFacing, ref Vector3 headOrigin, ref Quaternion quaternion, bool portrait) {
|
||||||
|
|
||||||
CompBodyAnimator bodyAnim = ___pawn.TryGetComp<CompBodyAnimator>();
|
if (!portrait && CompBodyAnimator.IsAnimating(___pawn)) {
|
||||||
|
|
||||||
if (bodyAnim != null && bodyAnim.isAnimating && !portrait) {
|
|
||||||
|
|
||||||
|
CompBodyAnimator bodyAnim = ___pawn.TryGetComp<CompBodyAnimator>();
|
||||||
headFacing = bodyAnim.headFacing;
|
headFacing = bodyAnim.headFacing;
|
||||||
headOrigin = new Vector3(bodyAnim.getPawnHeadPosition().x, headOrigin.y, bodyAnim.getPawnHeadPosition().z);
|
headOrigin = new Vector3(bodyAnim.getPawnHeadPosition().x, headOrigin.y, bodyAnim.getPawnHeadPosition().z);
|
||||||
quaternion = Quaternion.AngleAxis(bodyAnim.headAngle, Vector3.up);
|
quaternion = Quaternion.AngleAxis(bodyAnim.headAngle, Vector3.up);
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using rjw;
|
using rjw;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Verse;
|
|
||||||
|
|
||||||
namespace Rimworld_Animations
|
namespace Rimworld_Animations
|
||||||
{
|
{
|
||||||
|
@ -14,7 +8,7 @@ namespace Rimworld_Animations
|
||||||
{
|
{
|
||||||
public static bool Prefix(JobDriver_Sex __instance)
|
public static bool Prefix(JobDriver_Sex __instance)
|
||||||
{
|
{
|
||||||
if (__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating)
|
if (CompBodyAnimator.IsAnimating(__instance.pawn))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using Verse;
|
using Verse;
|
||||||
using rjw;
|
using rjw;
|
||||||
using System.Reflection.Emit;
|
|
||||||
using Verse.AI;
|
using Verse.AI;
|
||||||
|
|
||||||
namespace Rimworld_Animations
|
namespace Rimworld_Animations
|
||||||
|
@ -27,11 +23,7 @@ namespace Rimworld_Animations
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(JobDriver_JoinInBed), "MakeNewToils")]
|
[HarmonyPatch(typeof(JobDriver_JoinInBed), "MakeNewToils")]
|
||||||
|
@ -66,19 +58,13 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
toils[3].AddPreTickAction(() =>
|
toils[3].AddPreTickAction(() =>
|
||||||
{
|
{
|
||||||
if (!__instance.Partner.TryGetComp<CompBodyAnimator>().isAnimating)
|
if (!CompBodyAnimator.IsAnimating(__instance.Partner))
|
||||||
{
|
{
|
||||||
__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
__result = toils.AsEnumerable();
|
__result = toils.AsEnumerable();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using Verse;
|
using Verse;
|
||||||
|
@ -158,10 +156,12 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
public static void Postfix(ref JobDriver_SexBaseInitiator __instance) {
|
public static void Postfix(ref JobDriver_SexBaseInitiator __instance) {
|
||||||
|
|
||||||
if ((__instance.Target as Pawn)?.jobs?.curDriver is JobDriver_SexBaseReciever) {
|
Pawn reciever = __instance.Target as Pawn;
|
||||||
if (__instance.pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
|
||||||
|
|
||||||
List<Pawn> parteners = ((__instance.Target as Pawn)?.jobs.curDriver as JobDriver_SexBaseReciever).parteners;
|
if (reciever?.jobs?.curDriver is JobDriver_SexBaseReciever recieverJobDriver) {
|
||||||
|
if (CompBodyAnimator.IsAnimating(__instance.pawn)) {
|
||||||
|
|
||||||
|
List<Pawn> parteners = recieverJobDriver.parteners;
|
||||||
|
|
||||||
for (int i = 0; i < parteners.Count; i++) {
|
for (int i = 0; i < parteners.Count; i++) {
|
||||||
|
|
||||||
|
@ -173,13 +173,13 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
__instance.Target.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
__instance.Target.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||||
|
|
||||||
if (xxx.is_human((__instance.Target as Pawn))) {
|
if (xxx.is_human(reciever)) {
|
||||||
(__instance.Target as Pawn)?.Drawer.renderer.graphics.ResolveApparelGraphics();
|
reciever?.Drawer.renderer.graphics.ResolveApparelGraphics();
|
||||||
PortraitsCache.SetDirty((__instance.Target as Pawn));
|
PortraitsCache.SetDirty(reciever);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((__instance.Target as Pawn)?.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Remove(__instance.pawn);
|
recieverJobDriver?.parteners.Remove(__instance.pawn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using HarmonyLib;
|
/*using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -19,4 +19,4 @@ namespace Rimworld_Animations
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
|
@ -5,7 +5,6 @@ using HarmonyLib;
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using Verse;
|
using Verse;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Reflection;
|
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
|
||||||
namespace Rimworld_Animations {
|
namespace Rimworld_Animations {
|
||||||
|
@ -31,12 +30,10 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
PawnGraphicSet graphics = __instance.graphics;
|
PawnGraphicSet graphics = __instance.graphics;
|
||||||
Pawn pawn = graphics.pawn;
|
Pawn pawn = graphics.pawn;
|
||||||
CompBodyAnimator bodyAnim = pawn.TryGetComp<CompBodyAnimator>();
|
|
||||||
|
|
||||||
|
if (CompBodyAnimator.IsAnimating(pawn) && pawn.Map == Find.CurrentMap)
|
||||||
if (bodyAnim != null && bodyAnim.isAnimating && pawn.Map == Find.CurrentMap)
|
|
||||||
{
|
{
|
||||||
bodyAnim.animatePawnBody(ref rootLoc, ref angle, ref bodyFacing);
|
pawn.TryGetComp<CompBodyAnimator>().animatePawnBody(ref rootLoc, ref angle, ref bodyFacing);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +72,7 @@ namespace Rimworld_Animations {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yield return ins[i];
|
yield return ins[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,23 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Verse;
|
using Verse;
|
||||||
|
|
||||||
namespace Rimworld_Animations {
|
namespace Rimworld_Animations {
|
||||||
[HarmonyPatch(typeof(Thing), "Rotation", MethodType.Getter)]
|
[HarmonyPatch(typeof(Thing), nameof(Thing.Rotation), MethodType.Getter)]
|
||||||
public static class HarmonyPatch_PawnRotation {
|
public static class HarmonyPatch_PawnRotation {
|
||||||
|
|
||||||
public static bool Prefix(Thing __instance, ref Rot4 __result) {
|
public static bool Prefix(Thing __instance, ref Rot4 __result) {
|
||||||
|
|
||||||
if(!(__instance is Pawn) || (__instance as Pawn)?.TryGetComp<CompBodyAnimator>() == null || !(__instance as Pawn).TryGetComp<CompBodyAnimator>().isAnimating) {
|
if (!(__instance is Pawn pawn)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CompBodyAnimator.IsAnimating(pawn)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pawn pawn = (__instance as Pawn);
|
|
||||||
__result = pawn.TryGetComp<CompBodyAnimator>().bodyFacing;
|
__result = pawn.TryGetComp<CompBodyAnimator>().bodyFacing;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Verse;
|
using Verse;
|
||||||
|
|
||||||
|
@ -13,10 +8,9 @@ namespace Rimworld_Animations {
|
||||||
public static class HarmonyPatch_Pawn_DrawTracker {
|
public static class HarmonyPatch_Pawn_DrawTracker {
|
||||||
public static bool Prefix(ref Pawn ___pawn, ref Vector3 __result) {
|
public static bool Prefix(ref Pawn ___pawn, ref Vector3 __result) {
|
||||||
|
|
||||||
CompBodyAnimator bodyAnim = ___pawn.TryGetComp<CompBodyAnimator>();
|
if (CompBodyAnimator.IsAnimating(___pawn)) {
|
||||||
|
CompBodyAnimator bodyAnim = ___pawn.TryGetComp<CompBodyAnimator>();
|
||||||
if (bodyAnim != null && bodyAnim.isAnimating) {
|
__result = bodyAnim.anchor + bodyAnim.deltaPos;
|
||||||
__result = ___pawn.TryGetComp<CompBodyAnimator>().anchor + ___pawn.TryGetComp<CompBodyAnimator>().deltaPos;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Verse;
|
using Verse;
|
||||||
|
|
||||||
namespace Rimworld_Animations
|
namespace Rimworld_Animations
|
||||||
|
@ -13,8 +8,7 @@ namespace Rimworld_Animations
|
||||||
{
|
{
|
||||||
public static bool Prefix(ref Pawn ___pawn)
|
public static bool Prefix(ref Pawn ___pawn)
|
||||||
{
|
{
|
||||||
|
if (CompBodyAnimator.IsAnimating(___pawn))
|
||||||
if (___pawn.TryGetComp<CompBodyAnimator>() != null && ___pawn.TryGetComp<CompBodyAnimator>().isAnimating)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection.Emit;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
|
||||||
using Verse;
|
using Verse;
|
||||||
|
|
||||||
namespace Rimworld_Animations
|
namespace Rimworld_Animations
|
||||||
|
@ -16,18 +10,16 @@ namespace Rimworld_Animations
|
||||||
{
|
{
|
||||||
static bool ClearCache(Pawn pawn)
|
static bool ClearCache(Pawn pawn)
|
||||||
{
|
{
|
||||||
return pawn.IsInvisible() || (pawn.TryGetComp<CompBodyAnimator>() != null && pawn.TryGetComp<CompBodyAnimator>().isAnimating);
|
return pawn.IsInvisible() || CompBodyAnimator.IsAnimating(pawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||||
{
|
{
|
||||||
var list = instructions.ToList();
|
|
||||||
|
|
||||||
foreach (CodeInstruction i in instructions)
|
foreach (CodeInstruction i in instructions)
|
||||||
{
|
{
|
||||||
if (i.OperandIs(AccessTools.Method(typeof(PawnUtility), "IsInvisible")))
|
if (i.Calls(AccessTools.Method(typeof(PawnUtility), nameof(PawnUtility.IsInvisible))))
|
||||||
{
|
{
|
||||||
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PawnRenderer_RenderPawnAt_Patch), "ClearCache"));
|
yield return CodeInstruction.Call(typeof(PawnRenderer_RenderPawnAt_Patch), nameof(ClearCache));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -169,11 +169,10 @@ namespace Rimworld_Animations {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
if (!CompBodyAnimator.IsAnimating(pawn)) {
|
||||||
|
|
||||||
if (pawnAnimator == null || !pawnAnimator.isAnimating) {
|
|
||||||
GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, material, drawNow);
|
GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, material, drawNow);
|
||||||
} else {
|
} else {
|
||||||
|
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
Vector3 pawnHeadPosition = pawnAnimator.getPawnHeadPosition();
|
Vector3 pawnHeadPosition = pawnAnimator.getPawnHeadPosition();
|
||||||
pawnHeadPosition.y = loc.y;
|
pawnHeadPosition.y = loc.y;
|
||||||
GenDraw.DrawMeshNowOrLater(MeshPool.humanlikeHeadSet.MeshAt(pawnAnimator.headFacing), pawnHeadPosition, Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up), material, true);
|
GenDraw.DrawMeshNowOrLater(MeshPool.humanlikeHeadSet.MeshAt(pawnAnimator.headFacing), pawnHeadPosition, Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up), material, true);
|
||||||
|
@ -184,14 +183,13 @@ namespace Rimworld_Animations {
|
||||||
{
|
{
|
||||||
if (flags.FlagSet(PawnRenderFlags.Portrait)) return;
|
if (flags.FlagSet(PawnRenderFlags.Portrait)) return;
|
||||||
|
|
||||||
CompBodyAnimator anim = pawn.TryGetComp<CompBodyAnimator>();
|
if (CompBodyAnimator.IsAnimating(pawn))
|
||||||
if (anim.isAnimating)
|
|
||||||
{
|
{
|
||||||
|
CompBodyAnimator anim = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
bodyFacing = anim.headFacing;
|
bodyFacing = anim.headFacing;
|
||||||
angle = anim.headAngle;
|
angle = anim.headAngle;
|
||||||
quat = Quaternion.AngleAxis(anim.headAngle, Vector3.up);
|
quat = Quaternion.AngleAxis(anim.headAngle, Vector3.up);
|
||||||
pos = anim.getPawnHeadOffset();
|
pos = anim.getPawnHeadOffset();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,12 +200,12 @@ namespace Rimworld_Animations {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
|
||||||
|
|
||||||
if (pawnAnimator == null || !pawnAnimator.isAnimating || portrait) {
|
if (!CompBodyAnimator.IsAnimating(pawn) || portrait) {
|
||||||
GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, material, portrait);
|
GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, material, portrait);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
Vector3 pawnHeadPosition = pawnAnimator.getPawnHeadPosition();
|
Vector3 pawnHeadPosition = pawnAnimator.getPawnHeadPosition();
|
||||||
pawnHeadPosition.x *= bodySizeFactor;
|
pawnHeadPosition.x *= bodySizeFactor;
|
||||||
pawnHeadPosition.x *= bodySizeFactor;
|
pawnHeadPosition.x *= bodySizeFactor;
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Rimworld_Animations {
|
||||||
public static bool Prefix_AnimateHeadAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
|
public static bool Prefix_AnimateHeadAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (renderFlags.FlagSet(PawnRenderFlags.Portrait) || pawn.TryGetComp<CompBodyAnimator>() == null || !pawn.TryGetComp<CompBodyAnimator>().isAnimating) return true;
|
if (renderFlags.FlagSet(PawnRenderFlags.Portrait) || !CompBodyAnimator.IsAnimating(pawn)) return true;
|
||||||
if (!(pawn.def is ThingDef_AlienRace alienProps) || renderFlags.FlagSet(PawnRenderFlags.Invisible)) return false;
|
if (!(pawn.def is ThingDef_AlienRace alienProps) || renderFlags.FlagSet(PawnRenderFlags.Invisible)) return false;
|
||||||
|
|
||||||
List<AlienPartGenerator.BodyAddon> addons = alienProps.alienRace.generalSettings.alienPartGenerator.bodyAddons;
|
List<AlienPartGenerator.BodyAddon> addons = alienProps.alienRace.generalSettings.alienPartGenerator.bodyAddons;
|
||||||
|
|
Loading…
Reference in New Issue