2022-09-13 05:36:34 +00:00
|
|
|
|
using System.Collections.Generic;
|
2022-09-21 21:15:25 +00:00
|
|
|
|
using System.Linq;
|
2022-09-13 05:36:34 +00:00
|
|
|
|
using System.Xml;
|
|
|
|
|
using System.Xml.Serialization;
|
2022-09-18 00:06:33 +00:00
|
|
|
|
using UnityEngine;
|
2022-09-13 05:36:34 +00:00
|
|
|
|
|
|
|
|
|
namespace RimWorldAnimationStudio
|
|
|
|
|
{
|
|
|
|
|
public class AnimationStage
|
|
|
|
|
{
|
2022-09-18 00:06:33 +00:00
|
|
|
|
public string stageName = "NewStage";
|
2022-09-13 05:36:34 +00:00
|
|
|
|
public int stageIndex = 0;
|
|
|
|
|
public int playTimeTicks = 0;
|
|
|
|
|
public int playTimeTicksQuick = -1;
|
2022-09-18 00:06:33 +00:00
|
|
|
|
public bool isLooping = false;
|
2022-09-13 05:36:34 +00:00
|
|
|
|
|
2022-09-18 05:01:12 +00:00
|
|
|
|
[XmlArray("animationClips"), XmlArrayItem("li")] public List<PawnAnimationClip> animationClips = new List<PawnAnimationClip>();
|
|
|
|
|
[XmlIgnore] public int stageWindowSize = -1;
|
2022-09-13 05:36:34 +00:00
|
|
|
|
|
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
2022-09-19 00:07:44 +00:00
|
|
|
|
foreach (PawnAnimationClip clip in animationClips)
|
2022-09-13 05:36:34 +00:00
|
|
|
|
{
|
|
|
|
|
clip.BuildSimpleCurves();
|
|
|
|
|
|
|
|
|
|
//select playTimeTicks as longest playtime of all the animations
|
|
|
|
|
if (clip.duration > playTimeTicks)
|
|
|
|
|
{ playTimeTicks = clip.duration; }
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-18 00:06:33 +00:00
|
|
|
|
|
2022-09-21 21:15:25 +00:00
|
|
|
|
public void ValidateData()
|
|
|
|
|
{
|
|
|
|
|
// Sort keyframes by atTick
|
|
|
|
|
foreach (PawnAnimationClip clip in animationClips)
|
|
|
|
|
{ clip.keyframes = clip.keyframes.OrderBy(x => x.atTick).ToList(); }
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 00:06:33 +00:00
|
|
|
|
public bool MakeNew()
|
|
|
|
|
{
|
|
|
|
|
if (Workspace.animationDef == null)
|
|
|
|
|
{ Debug.LogWarning("Cannot make new animation stage - there is no AnimationDef"); return false; }
|
|
|
|
|
|
|
|
|
|
foreach(Actor actor in Workspace.animationDef.actors)
|
|
|
|
|
{
|
|
|
|
|
PawnAnimationClip clip = new PawnAnimationClip();
|
|
|
|
|
|
|
|
|
|
if (clip.MakeNew())
|
|
|
|
|
{ animationClips.Add(clip); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Initialize();
|
|
|
|
|
|
|
|
|
|
Workspace.animationDef.animationStages.Add(this);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-09-13 05:36:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|