diff --git a/1.4/Assemblies/Rimworld-Animations.dll b/1.4/Assemblies/Rimworld-Animations.dll index 1ea76d6..aab79e7 100644 Binary files a/1.4/Assemblies/Rimworld-Animations.dll and b/1.4/Assemblies/Rimworld-Animations.dll differ diff --git a/1.4/Source/Comps/CompBodyAnimator.cs b/1.4/Source/Comps/CompBodyAnimator.cs index 5ff09c2..fd1f95b 100644 --- a/1.4/Source/Comps/CompBodyAnimator.cs +++ b/1.4/Source/Comps/CompBodyAnimator.cs @@ -39,8 +39,6 @@ namespace Rimworld_Animations { private bool mirror = false, quiver = false, shiver = false; private int actor; - private int lastDrawFrame = -1; - private int animTicks = 0, stageTicks = 0, clipTicks = 0; private int curStage = 0; private float clipPercent = 0; @@ -357,7 +355,7 @@ namespace Rimworld_Animations { deltaPos.y = clip.layer.AltitudeFor(); - bool adjustOffsetX = false, adjustOffsetZ = false, adjustBodyAngle = false, adjustHeadAngle = false, adjustGenitalAngle = false; + bool adjustOffsetX = false, adjustOffsetZ = false; if(clip.BodyOffsetX.Any()) { deltaPos.x = clip.BodyOffsetX.Evaluate(clipPercent) * (mirror ? -1 : 1); @@ -378,30 +376,31 @@ namespace Rimworld_Animations { deltaPos.z += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex].y; } - if(clip.BodyAngle.Any()) + float offsetRotation = 0f; + if (AnimationSettings.rotation != null && AnimationSettings.rotation.ContainsKey(CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex)) + { + offsetRotation = AnimationSettings.rotation[CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex] * (Mirror ? -1 : 1); + } + + if (clip.BodyAngle.Any()) { - adjustBodyAngle = true; bodyAngle = (clip.BodyAngle.Evaluate(clipPercent) + (quiver || shiver ? ((Rand.Value * AnimationSettings.shiverIntensity) - (AnimationSettings.shiverIntensity / 2f)) : 0f)) * (mirror ? -1 : 1); + bodyAngle += offsetRotation; } if(clip.HeadAngle.Any()) { - adjustHeadAngle = true; headAngle = clip.HeadAngle.Evaluate(clipPercent) * (mirror ? -1 : 1); + headAngle += offsetRotation; } - if (controlGenitalAngle && clip.GenitalAngle.Any()) { - - adjustGenitalAngle = true; + if (controlGenitalAngle && clip.GenitalAngle.Any()) + { genitalAngle = clip.GenitalAngle.Evaluate(clipPercent) * (mirror ? -1 : 1); + genitalAngle += offsetRotation; } - if (AnimationSettings.rotation != null && AnimationSettings.rotation.ContainsKey(CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex)) { - float offsetRotation = AnimationSettings.rotation[CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex] * (Mirror ? -1 : 1); - if (adjustGenitalAngle) genitalAngle += offsetRotation; - if (adjustBodyAngle) bodyAngle += offsetRotation; - if (adjustHeadAngle) headAngle += offsetRotation; - } + //don't go past 360 or less than 0 @@ -409,21 +408,32 @@ namespace Rimworld_Animations { AnimationUtility.Clamp0to360(ref headAngle); AnimationUtility.Clamp0to360(ref genitalAngle); - - bodyFacing = mirror ? new Rot4((int)clip.BodyFacing.Evaluate(clipPercent)).Opposite : new Rot4((int)clip.BodyFacing.Evaluate(clipPercent)); - - bodyFacing = new Rot4((int)clip.BodyFacing.Evaluate(clipPercent)); - if(bodyFacing.IsHorizontal && mirror) { - bodyFacing = bodyFacing.Opposite; + if(clip.BodyFacing.Any()) + { + bodyFacing = new Rot4((int)clip.BodyFacing.Evaluate(clipPercent)); + if (bodyFacing.IsHorizontal && mirror) + { + bodyFacing = bodyFacing.Opposite; + } } - headFacing = new Rot4((int)clip.HeadFacing.Evaluate(clipPercent)); - if(headFacing.IsHorizontal && mirror) { - headFacing = headFacing.Opposite; + + if(clip.HeadFacing.Any()) + { + headFacing = new Rot4((int)clip.HeadFacing.Evaluate(clipPercent)); + if (headFacing.IsHorizontal && mirror) + { + headFacing = headFacing.Opposite; + } } - headBob = new Vector3(0, 0, clip.HeadBob.Evaluate(clipPercent)); - Vector2 bodyScale = (pawn.story?.bodyType?.bodyGraphicScale != null ? pawn.story.bodyType.bodyGraphicScale : Vector2.one); - headBob.z *= bodyScale.x; + if(clip.HeadBob.Any()) + { + headBob = new Vector3(0, 0, clip.HeadBob.Evaluate(clipPercent)); + Vector2 bodyScale = (pawn.story?.bodyType?.bodyGraphicScale != null ? pawn.story.bodyType.bodyGraphicScale : Vector2.one); + headBob.z *= bodyScale.x; + } + + }