57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace RimWorldAnimationStudio
|
|
{
|
|
public class AnimationTimeline : MonoBehaviour
|
|
{
|
|
public int actorID;
|
|
public KeyframeSlider keyframeSliderPrefab;
|
|
|
|
public void Initialize(int actorID)
|
|
{
|
|
this.actorID = actorID;
|
|
|
|
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(actorID);
|
|
|
|
if (clip == null || clip.keyframes.NullOrEmpty())
|
|
{
|
|
Debug.Log("Clip was empty");
|
|
|
|
clip = new PawnAnimationClip();
|
|
clip.keyframes.Add(new PawnKeyframe());
|
|
clip.BuildSimpleCurves();
|
|
}
|
|
|
|
foreach (PawnKeyframe keyframe in clip.keyframes)
|
|
{
|
|
KeyframeSlider keyframeSlider = Instantiate(keyframeSliderPrefab, transform);
|
|
keyframeSlider.Initialize(this, actorID, keyframe.keyframeID);
|
|
}
|
|
}
|
|
|
|
public void AddKeyFrame(int atTick)
|
|
{
|
|
|
|
}
|
|
|
|
public bool CanAddKeyFrameAtTick(int atTick)
|
|
{
|
|
foreach (Transform child in transform)
|
|
{
|
|
KeyframeSlider keyframeSlider = child.GetComponent<KeyframeSlider>();
|
|
|
|
if (keyframeSlider != null && Workspace.Instance.GetPawnKeyframe(keyframeSlider.actorID, keyframeSlider.keyframeID).atTick == atTick)
|
|
{ return false; }
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|