Basic actor timelines and keyframe tweaking

This commit is contained in:
AbstractConcept 2022-09-16 09:18:06 -05:00
parent 0364322d46
commit dfa564759b
246 changed files with 1918 additions and 150 deletions

View file

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using UnityEngine;
namespace RimWorldAnimationStudio
{
@ -21,58 +22,81 @@ namespace RimWorldAnimationStudio
public override void BuildSimpleCurves()
{
BodyAngle.Clear();
HeadAngle.Clear();
BodyOffsetX.Clear();
BodyOffsetZ.Clear();
HeadFacing.Clear();
BodyFacing.Clear();
HeadBob.Clear();
GenitalAngle.Clear();
SoundEffects.Clear();
int duration = 0;
foreach (PawnKeyframe frame in keyframes)
{ duration += frame.tickDuration; }
this.duration = duration;
int keyframePosition = 0;
foreach (PawnKeyframe frame in keyframes)
for (int i = 0; i < keyframes.Count; i++)
{
if (frame.atTick.HasValue)
PawnKeyframe keyframe = keyframes[i];
if (keyframe.atTick.HasValue)
{
BodyAngle.Add((float)frame.atTick / (float)duration, frame.bodyAngle, true);
HeadAngle.Add((float)frame.atTick / (float)duration, frame.headAngle, true);
BodyOffsetX.Add((float)frame.atTick / (float)duration, frame.bodyOffsetX, true);
BodyOffsetZ.Add((float)frame.atTick / (float)duration, frame.bodyOffsetZ, true);
HeadFacing.Add((float)frame.atTick / (float)duration, frame.headFacing, true);
BodyFacing.Add((float)frame.atTick / (float)duration, frame.bodyFacing, true);
HeadBob.Add((float)frame.atTick / (float)duration, frame.headBob, true);
if (keyframe.HasValidKeyframeID() == false)
{ keyframe.GenerateKeyframeID(); }
if (frame.genitalAngle.HasValue)
{ GenitalAngle.Add((float)frame.atTick / (float)duration, frame.genitalAngle.Value, true); }
Debug.Log(keyframe.atTick.Value);
if (frame.soundEffect != null)
{ SoundEffects.Add((int)frame.atTick, frame.soundEffect); }
BodyAngle.Add((float)keyframe.atTick / (float)duration, keyframe.bodyAngle, true);
HeadAngle.Add((float)keyframe.atTick / (float)duration, keyframe.headAngle, true);
BodyOffsetX.Add((float)keyframe.atTick / (float)duration, keyframe.bodyOffsetX, true);
BodyOffsetZ.Add((float)keyframe.atTick / (float)duration, keyframe.bodyOffsetZ, true);
HeadFacing.Add((float)keyframe.atTick / (float)duration, keyframe.headFacing, true);
BodyFacing.Add((float)keyframe.atTick / (float)duration, keyframe.bodyFacing, true);
HeadBob.Add((float)keyframe.atTick / (float)duration, keyframe.headBob, true);
if (keyframe.genitalAngle.HasValue)
{ GenitalAngle.Add((float)keyframe.atTick / (float)duration, keyframe.genitalAngle.Value, true); }
if (keyframe.soundEffect != null)
{ SoundEffects.Add((int)keyframe.atTick, keyframe.soundEffect); }
if (i + 1 < keyframes.Count)
{ keyframes[i].tickDuration = keyframes[i + 1].atTick.Value - keyframes[i].atTick.Value; }
}
else
{
BodyAngle.Add((float)keyframePosition / (float)duration, frame.bodyAngle, true);
HeadAngle.Add((float)keyframePosition / (float)duration, frame.headAngle, true);
BodyOffsetX.Add((float)keyframePosition / (float)duration, frame.bodyOffsetX, true);
BodyOffsetZ.Add((float)keyframePosition / (float)duration, frame.bodyOffsetZ, true);
HeadFacing.Add((float)keyframePosition / (float)duration, frame.headFacing, true);
BodyFacing.Add((float)keyframePosition / (float)duration, frame.bodyFacing, true);
HeadBob.Add((float)keyframePosition / (float)duration, frame.headBob, true);
BodyAngle.Add((float)keyframePosition / (float)duration, keyframe.bodyAngle, true);
HeadAngle.Add((float)keyframePosition / (float)duration, keyframe.headAngle, true);
BodyOffsetX.Add((float)keyframePosition / (float)duration, keyframe.bodyOffsetX, true);
BodyOffsetZ.Add((float)keyframePosition / (float)duration, keyframe.bodyOffsetZ, true);
HeadFacing.Add((float)keyframePosition / (float)duration, keyframe.headFacing, true);
BodyFacing.Add((float)keyframePosition / (float)duration, keyframe.bodyFacing, true);
HeadBob.Add((float)keyframePosition / (float)duration, keyframe.headBob, true);
if (frame.genitalAngle.HasValue)
GenitalAngle.Add((float)keyframePosition / (float)duration, frame.genitalAngle.Value, true);
if (keyframe.genitalAngle.HasValue)
GenitalAngle.Add((float)keyframePosition / (float)duration, keyframe.genitalAngle.Value, true);
if (frame.soundEffect != null)
{ SoundEffects.Add(keyframePosition, frame.soundEffect); }
if (keyframe.soundEffect != null)
{ SoundEffects.Add(keyframePosition, keyframe.soundEffect); }
if (frame.tickDuration != 1 && frame.quiver.HasValue)
if (keyframe.tickDuration != 1 && keyframe.quiver.HasValue)
{
quiver.Add(keyframePosition, true);
quiver.Add(keyframePosition + frame.tickDuration - 1, false);
quiver.Add(keyframePosition + keyframe.tickDuration - 1, false);
}
keyframePosition += frame.tickDuration;
keyframe.atTick = keyframePosition + 1;
keyframePosition += keyframe.tickDuration;
}
}
keyframes[keyframes.Count - 1].tickDuration = 1;
}
}
}

View file

@ -6,7 +6,7 @@ namespace RimWorldAnimationStudio
{
public class Keyframe
{
public float? atTick;
public int? atTick;
public int tickDuration = 1;
public string soundEffect;

View file

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using UnityEngine;
namespace RimWorldAnimationStudio
{
@ -19,5 +20,16 @@ namespace RimWorldAnimationStudio
public bool ShouldSerializegenitalAngle() { return genitalAngle != null; }
public bool ShouldSerializequiver() { return quiver != null; }
[XmlIgnore] public int keyframeID;
public void GenerateKeyframeID()
{
keyframeID = Random.Range(100000, 1000000);
Debug.Log("Generated ID: " + keyframeID);
}
public bool HasValidKeyframeID()
{ return keyframeID >= 100000 && keyframeID < 1000000; }
}
}