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

View File

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

View File

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

View File

@ -35,21 +35,23 @@ namespace Rimworld_Animations {
int ActorIndex = curPawn.TryGetComp<CompBodyAnimator>().ActorIndex; int ActorIndex = curPawn.TryGetComp<CompBodyAnimator>().ActorIndex;
float offsetX = 0, offsetZ = 0, rotation = 0; float offsetX = 0, offsetZ = 0, rotation = 0;
if (AnimationSettings.offsets.ContainsKey(def.defName + curPawn.def.defName + ActorIndex)) { string bodyTypeDef = (curPawn.story?.bodyType != null) ? curPawn.story.bodyType.ToString() : "";
offsetX = AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].x;
offsetZ = AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].y; 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 { } 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)) { if (AnimationSettings.rotation.ContainsKey(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex)) {
rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex]; rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex];
} }
else { 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") { if(curPawn.def.defName == "Human") {
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");
@ -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]) { if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]) {
AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex] = rotation; 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; bool shiver = pawnsToAnimate[i].jobs.curDriver is JobDriver_SexBaseRecieverRaped;
pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().StartAnimation(anim, pawnsToAnimate, i, mirror, shiver, fastAnimForQuickie); pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().StartAnimation(anim, pawnsToAnimate, i, mirror, shiver, fastAnimForQuickie);
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = anim.animationTimeTicks; int animTicks = anim.animationTimeTicks - (fastAnimForQuickie ? anim.animationStages[0].playTimeTicks : 0);
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).sex_ticks = anim.animationTimeTicks; (pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = animTicks;
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).duration = anim.animationTimeTicks; (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) { if(!AnimationSettings.hearts) {
(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_between_hearts = Int32.MaxValue; (pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_between_hearts = Int32.MaxValue;