bugfixes related to quickie speed up anim

This commit is contained in:
c0ffee 2021-05-14 09:58:49 -07:00
parent 756bfc63f1
commit 7fda462532
6 changed files with 57 additions and 30 deletions

View File

@ -6,7 +6,7 @@
<url>https://gitgud.io/c0ffeeeeeeee/rimworld-animations</url>
<supportedVersions>
<li>1.1</li>
<li>1.2</li>
<li>1.2</li>
</supportedVersions>
<packageId>c0ffee.rimworld.animations</packageId>
<modDependencies>
@ -31,7 +31,7 @@
<loadAfter>
<li>UnlimitedHugs.HugsLib</li>
<li>brrainz.harmony</li>
<li>rim.job.world</li>
<li>rim.job.world</li>
</loadAfter>
<description>
Rimworld Animations! Hurray!

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>Rimworld-Animations</identifier>
<version>1.1.2</version>
<version>1.1.3</version>
</Manifest>

View File

@ -15,7 +15,7 @@ namespace Rimworld_Animations {
{
public Pawn pawn => base.parent as Pawn;
public PawnGraphicSet Graphics;
//public CompProperties_BodyAnimator Props => (CompProperties_BodyAnimator)(object)base.props;
public bool isAnimating {
@ -25,7 +25,7 @@ namespace Rimworld_Animations {
set {
Animating = value;
if(value == true) {
if (value == true) {
SexUtility.DrawNude(pawn);
} else {
pawn.Drawer.renderer.graphics.ResolveAllGraphics();
@ -54,7 +54,13 @@ namespace Rimworld_Animations {
public bool controlGenitalAngle = false;
private AnimationDef anim;
private AnimationStage stage => anim.animationStages[curStage];
private AnimationStage stage {
get
{
return anim.animationStages[curStage];
}
}
private PawnAnimationClip clip => (PawnAnimationClip)stage.animationClips[actor];
public bool Mirror {
@ -144,9 +150,16 @@ namespace Rimworld_Animations {
this.actor = actor;
this.anim = anim;
this.mirror = mirror;
curStage = fastAnimForQuickie ? 1 : 0;
animTicks = 0;
if(fastAnimForQuickie)
{
curStage = 1;
animTicks = anim.animationStages[0].playTimeTicks;
} else
{
curStage = 0;
animTicks = 0;
}
stageTicks = 0;
clipTicks = 0;
@ -222,6 +235,13 @@ namespace Rimworld_Animations {
public void tickStage()
{
if(stage == null)
{
isAnimating = false;
return;
}
stageTicks++;
if(stageTicks >= stage.playTimeTicks) {
@ -321,9 +341,11 @@ namespace Rimworld_Animations {
deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent) * (mirror ? -1 : 1), clip.layer.AltitudeFor(), clip.BodyOffsetZ.Evaluate(clipPercent));
if (AnimationSettings.offsets != null && AnimationSettings.offsets.ContainsKey(CurrentAnimation.defName + pawn.def.defName + ActorIndex)) {
deltaPos.x += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + ActorIndex].x * (mirror ? -1 : 1);
deltaPos.z += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + ActorIndex].y;
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;
}
@ -334,8 +356,8 @@ namespace Rimworld_Animations {
genitalAngle = clip.GenitalAngle.Evaluate(clipPercent) * (mirror ? -1 : 1);
}
if (AnimationSettings.rotation != null && AnimationSettings.rotation.ContainsKey(CurrentAnimation.defName + pawn.def.defName + ActorIndex)) {
float offsetRotation = AnimationSettings.rotation[CurrentAnimation.defName + pawn.def.defName + ActorIndex] * (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;

View File

@ -35,21 +35,23 @@ namespace Rimworld_Animations {
int ActorIndex = curPawn.TryGetComp<CompBodyAnimator>().ActorIndex;
float offsetX = 0, offsetZ = 0, rotation = 0;
if (AnimationSettings.offsets.ContainsKey(def.defName + curPawn.def.defName + ActorIndex)) {
offsetX = AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].x;
offsetZ = AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].y;
string bodyTypeDef = (curPawn.story?.bodyType != null) ? curPawn.story.bodyType.ToString() : "";
if (AnimationSettings.offsets.ContainsKey(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex)) {
offsetX = AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].x;
offsetZ = AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].y;
} else {
AnimationSettings.offsets.Add(def.defName + curPawn.def.defName + ActorIndex, new Vector2(0, 0));
AnimationSettings.offsets.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, new Vector2(0, 0));
}
if (AnimationSettings.rotation.ContainsKey(def.defName + curPawn.def.defName + ActorIndex)) {
rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex];
if (AnimationSettings.rotation.ContainsKey(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex)) {
rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex];
}
else {
AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + ActorIndex, 0);
AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, 0);
}
listingStandard.Label("Name: " + curPawn.Name + " Race: " + curPawn.def.defName + " Actor Index: " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex + " Animation: " + def.label + (curPawn.TryGetComp<CompBodyAnimator>().Mirror ? " mirrored" : ""));
listingStandard.Label("Name: " + curPawn.Name + " Race: " + curPawn.def.defName + " Actor Index: " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex + " Body Type (if any): " + bodyTypeDef + " Animation: " + def.label + (curPawn.TryGetComp<CompBodyAnimator>().Mirror ? " mirrored" : ""));
if(curPawn.def.defName == "Human") {
listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets");
@ -96,13 +98,15 @@ namespace Rimworld_Animations {
}
if (offsetX != AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].x || offsetZ != AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].y) {
AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex] = new Vector2(offsetX, offsetZ);
if (offsetX != AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].x || offsetZ != AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].y) {
AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex] = new Vector2(offsetX, offsetZ);
}
if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex]) {
AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex] = rotation;
if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]) {
AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex] = rotation;
}
}

View File

@ -121,12 +121,13 @@ namespace Rimworld_Animations {
bool shiver = pawnsToAnimate[i].jobs.curDriver is JobDriver_SexBaseRecieverRaped;
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().StartAnimation(anim, pawnsToAnimate, i, mirror, shiver, fastAnimForQuickie);
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = anim.animationTimeTicks;
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).sex_ticks = anim.animationTimeTicks;
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).duration = anim.animationTimeTicks;
int animTicks = anim.animationTimeTicks - (fastAnimForQuickie ? anim.animationStages[0].playTimeTicks : 0);
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = animTicks;
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).sex_ticks = animTicks;
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).duration = animTicks;
AnimationTimeTicks = anim.animationTimeTicks;
AnimationTimeTicks = animTicks;
if(!AnimationSettings.hearts) {
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_between_hearts = Int32.MaxValue;