2020-04-09 00:43:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2022-01-25 02:17:49 +00:00
|
|
|
|
using Verse;
|
|
|
|
|
using RimWorld;
|
2020-04-09 00:43:01 +00:00
|
|
|
|
|
|
|
|
|
namespace Rimworld_Animations {
|
|
|
|
|
public class ThingAnimationClip : BaseAnimationClip
|
|
|
|
|
{
|
|
|
|
|
public List<ThingKeyframe> keyframes;
|
|
|
|
|
|
2022-01-25 02:17:49 +00:00
|
|
|
|
public SimpleCurve PositionX = new SimpleCurve();
|
|
|
|
|
public SimpleCurve PositionZ = new SimpleCurve();
|
|
|
|
|
public SimpleCurve Rotation = new SimpleCurve();
|
|
|
|
|
|
|
|
|
|
|
2020-04-09 00:43:01 +00:00
|
|
|
|
public override void buildSimpleCurves() {
|
2022-01-25 02:17:49 +00:00
|
|
|
|
int duration = 0;
|
|
|
|
|
//getting the length of the whole clip
|
|
|
|
|
foreach (ThingKeyframe frame in keyframes)
|
|
|
|
|
{
|
|
|
|
|
duration += frame.tickDuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//guarantees loops don't get cut off mid-anim
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
|
|
|
|
|
int keyframePosition = 0;
|
|
|
|
|
foreach (ThingKeyframe frame in keyframes)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (frame.atTick.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (frame.positionX.HasValue)
|
|
|
|
|
PositionX.Add((float)frame.atTick / (float)duration, frame.positionX.Value, true);
|
|
|
|
|
|
|
|
|
|
if (frame.positionZ.HasValue)
|
|
|
|
|
PositionZ.Add((float)frame.atTick / (float)duration, frame.positionZ.Value, true);
|
|
|
|
|
|
|
|
|
|
if (frame.rotation.HasValue)
|
|
|
|
|
Rotation.Add((float)frame.atTick / (float)duration, frame.rotation.Value, true);
|
|
|
|
|
|
|
|
|
|
if (frame.soundEffect != null)
|
|
|
|
|
{
|
|
|
|
|
SoundEffects.Add((int)frame.atTick, frame.soundEffect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (frame.positionX.HasValue)
|
|
|
|
|
PositionX.Add((float)keyframePosition / (float)duration, frame.positionX.Value, true);
|
|
|
|
|
|
|
|
|
|
if (frame.positionZ.HasValue)
|
|
|
|
|
PositionZ.Add((float)keyframePosition / (float)duration, frame.positionZ.Value, true);
|
|
|
|
|
|
|
|
|
|
if (frame.rotation.HasValue)
|
|
|
|
|
Rotation.Add((float)keyframePosition / (float)duration, frame.rotation.Value, true);
|
|
|
|
|
|
|
|
|
|
if (frame.soundEffect != null)
|
|
|
|
|
{
|
|
|
|
|
SoundEffects.Add(keyframePosition, frame.soundEffect);
|
|
|
|
|
}
|
|
|
|
|
keyframePosition += frame.tickDuration;
|
|
|
|
|
|
|
|
|
|
}
|
2020-04-22 18:24:31 +00:00
|
|
|
|
|
2022-01-25 02:17:49 +00:00
|
|
|
|
}
|
2020-04-09 00:43:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|