This commit is contained in:
c0ffee 2023-02-06 23:31:02 -08:00
parent bf8570287a
commit a3f53f79fe
3 changed files with 56 additions and 32 deletions

View File

@ -17,7 +17,7 @@ namespace Rimworld_Animations {
public PawnGraphicSet Graphics;
//public CompProperties_BodyAnimator Props => (CompProperties_BodyAnimator)(object)base.props;
string bodyTypeDef;
public bool isAnimating {
get {
return Animating;
@ -114,6 +114,8 @@ namespace Rimworld_Animations {
}
public void StartAnimation(AnimationDef anim, List<Pawn> actors, int actor, bool mirror = false, bool shiver = false, bool fastAnimForQuickie = false) {
bodyTypeDef = (pawn.story?.bodyType != null) ? pawn.story.bodyType.ToString() : "";
actorsInCurrentAnimation = actors;
if (anim.actors.Count <= actor)
@ -352,46 +354,60 @@ namespace Rimworld_Animations {
public void calculateDrawValues() {
/*if(Find.TickManager.TickRateMultiplier > 1 && (lastDrawFrame + 1 >= RealTime.frameCount || RealTime.deltaTime < 0.05f)) {
return;
}*/
deltaPos.y = clip.layer.AltitudeFor();
deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent) * (mirror ? -1 : 1), clip.layer.AltitudeFor(), clip.BodyOffsetZ.Evaluate(clipPercent));
string bodyTypeDef = (pawn.story?.bodyType != null) ? pawn.story.bodyType.ToString() : "";
if (AnimationSettings.offsets != null && AnimationSettings.offsets.ContainsKey(CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex)) {
deltaPos.x += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex].x * (mirror ? -1 : 1);
deltaPos.z += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex].y;
bool adjustOffsetX = false, adjustOffsetZ = false, adjustBodyAngle = false, adjustHeadAngle = false, adjustGenitalAngle = false;
if(clip.BodyOffsetX.Any())
{
deltaPos.x = clip.BodyOffsetX.Evaluate(clipPercent) * (mirror ? -1 : 1);
adjustOffsetX = true;
}
if(clip.BodyOffsetZ.Any())
{
deltaPos.z = clip.BodyOffsetZ.Evaluate(clipPercent);
adjustOffsetZ = true;
}
bodyAngle = (clip.BodyAngle.Evaluate(clipPercent) + (quiver || shiver ? ((Rand.Value * AnimationSettings.shiverIntensity) - (AnimationSettings.shiverIntensity / 2f)) : 0f)) * (mirror ? -1 : 1);
headAngle = clip.HeadAngle.Evaluate(clipPercent) * (mirror ? -1 : 1);
if (AnimationSettings.offsets != null && AnimationSettings.offsets.ContainsKey(CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex)) {
if(adjustOffsetX)
deltaPos.x += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex].x * (mirror ? -1 : 1);
if (controlGenitalAngle) {
if(adjustOffsetZ)
deltaPos.z += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + bodyTypeDef + ActorIndex].y;
}
if(clip.BodyAngle.Any())
{
adjustBodyAngle = true;
bodyAngle = (clip.BodyAngle.Evaluate(clipPercent) + (quiver || shiver ? ((Rand.Value * AnimationSettings.shiverIntensity) - (AnimationSettings.shiverIntensity / 2f)) : 0f)) * (mirror ? -1 : 1);
}
if(clip.HeadAngle.Any())
{
adjustHeadAngle = true;
headAngle = clip.HeadAngle.Evaluate(clipPercent) * (mirror ? -1 : 1);
}
if (controlGenitalAngle && clip.GenitalAngle.Any()) {
adjustGenitalAngle = true;
genitalAngle = clip.GenitalAngle.Evaluate(clipPercent) * (mirror ? -1 : 1);
}
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);
genitalAngle += offsetRotation;
bodyAngle += offsetRotation;
headAngle += offsetRotation;
if (adjustGenitalAngle) genitalAngle += offsetRotation;
if (adjustBodyAngle) bodyAngle += offsetRotation;
if (adjustHeadAngle) headAngle += offsetRotation;
}
//don't go past 360 or less than 0
if (bodyAngle < 0) bodyAngle = 360 - ((-1f*bodyAngle) % 360);
if (bodyAngle > 360) bodyAngle %= 360;
if (headAngle < 0) headAngle = 360 - ((-1f * headAngle) % 360);
if (headAngle > 360) headAngle %= 360;
if (genitalAngle < 0) genitalAngle = 360 - ((-1f * genitalAngle) % 360);
if (genitalAngle > 360) genitalAngle %= 360;
AnimationUtility.Clamp0to360(ref bodyAngle);
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));
@ -409,8 +425,6 @@ namespace Rimworld_Animations {
Vector2 bodyScale = (pawn.story?.bodyType?.bodyGraphicScale != null ? pawn.story.bodyType.bodyGraphicScale : Vector2.one);
headBob.z *= bodyScale.x;
lastDrawFrame = RealTime.frameCount;
}
public Vector3 getPawnHeadPosition() {

View File

@ -23,9 +23,11 @@ namespace Rimworld_Animations {
InteractionWithExtension interaction = InteractionHelper.GetWithExtension(sexProps.dictionaryKey);
participants =
participants.OrderBy(p =>
p.jobs.curDriver is rjw.JobDriver_Sex
&& !(p.jobs.curDriver as rjw.JobDriver_Sex).Sexprops.isReceiver)
participants.OrderBy(p =>
p.jobs.curDriver is rjw.JobDriver_Sex &&
((p.jobs.curDriver as rjw.JobDriver_Sex).Sexprops.dictionaryKey.defName.ToLower().Contains("reverse") ?
(p.jobs.curDriver as rjw.JobDriver_Sex).Sexprops.isReceiver :
!(p.jobs.curDriver as rjw.JobDriver_Sex).Sexprops.isReceiver))
.OrderBy(p => rjw.xxx.can_fuck(p))
.ToList();
@ -322,5 +324,13 @@ namespace Rimworld_Animations {
return regularPos;
}
public static void Clamp0to360(ref float angle)
{
if (angle < 0) angle = 360 - ((-1f * angle) % 360);
if (angle > 360) angle %= 360;
}
}
}