mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Stage and anim lengths display
This commit is contained in:
parent
ab5a2a4c02
commit
cc28ac4bd4
174 changed files with 604 additions and 245 deletions
|
@ -21,14 +21,10 @@ namespace RimWorldAnimationStudio
|
|||
anchorTransform = transform.parent;
|
||||
this.actorID = actorID;
|
||||
|
||||
Reset();
|
||||
|
||||
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();
|
||||
|
@ -39,12 +35,27 @@ namespace RimWorldAnimationStudio
|
|||
KeyframeSlider keyframeSlider = Instantiate(keyframeSliderPrefab, transform);
|
||||
keyframeSlider.Initialize(this, actorID, keyframe.keyframeID);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
foreach(KeyframeSlider keyframeSlider in GetComponentsInChildren<KeyframeSlider>())
|
||||
{ Destroy(keyframeSlider.gameObject); }
|
||||
int keyframeCount = clip.keyframes.Count;
|
||||
int childCount = GetComponentsInChildren<KeyframeSlider>().Count();
|
||||
|
||||
for (int i = 0; i < Mathf.Max(keyframeCount, childCount); i++)
|
||||
{
|
||||
// Add new keyframe sliders as required
|
||||
if (i >= childCount)
|
||||
{ Instantiate(keyframeSliderPrefab, transform); }
|
||||
|
||||
// Get objects to update
|
||||
KeyframeSlider keyframeSlider = GetComponentsInChildren<KeyframeSlider>()[i];
|
||||
|
||||
// Update values
|
||||
if (i < keyframeCount)
|
||||
{ keyframeSlider.Initialize(this, actorID, clip.keyframes[i].keyframeID); }
|
||||
|
||||
// Remove excess objects as required
|
||||
else
|
||||
{ Destroy(keyframeSlider.gameObject); }
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPawnKeyFrame(int keyframeID)
|
||||
|
@ -70,6 +81,8 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void InitiateUpdateOfGhostFrames()
|
||||
{
|
||||
if (AnimationController.Instance.IsTimelineDirty()) return;
|
||||
|
||||
BroadcastMessage("UpdateGhostFrames");
|
||||
}
|
||||
|
||||
|
@ -79,12 +92,7 @@ namespace RimWorldAnimationStudio
|
|||
int? siblingCount = anchorTransform.parent.GetComponentsInChildren<AnimationTimeline>()?.ToList()?.Count();
|
||||
|
||||
if (siblingIndex != null && siblingCount != null && MoveAnimationTimeline(siblingIndex.Value, delta))
|
||||
{
|
||||
//siblingIndex = Mathf.Clamp(siblingCount.Value + delta, 0, siblingCount.Value - 1);
|
||||
//transform.SetSiblingIndex(transform.GetSiblingIndex() + delta);
|
||||
AnimationController.Instance.ResetAnimationTimeline();
|
||||
AnimationController.Instance.InitializeAnimationTimeline();
|
||||
}
|
||||
{ AnimationController.Instance.InitializeAnimationTimeline(); }
|
||||
}
|
||||
|
||||
public bool MoveAnimationTimeline(int startIndex, int delta)
|
||||
|
|
|
@ -187,11 +187,7 @@ namespace RimWorldAnimationStudio
|
|||
{ linkedSlider = null; }
|
||||
|
||||
else if (AnimationController.Instance.stretchKeyframesToggle.isOn && linkedSlider != null && linkedSlider.IsPivotKeyframe(keyframe) == false)
|
||||
{
|
||||
//int minTick = linkedSlider.pivotKeyframe.atTick.Value + GetIndexAmongstSelectedKeyframes();
|
||||
//value = Mathf.Clamp(Mathf.CeilToInt(linkedSlider.keyframe.atTick.Value + linkedOffset * linkedSlider.ScaledOffsetFromPivot()), minTick, Workspace.StageWindowSize);
|
||||
value = Mathf.CeilToInt(linkedSlider.keyframe.atTick.Value + linkedOffset * linkedSlider.ScaledOffsetFromPivot());
|
||||
}
|
||||
{ value = Mathf.CeilToInt(linkedSlider.keyframe.atTick.Value + linkedOffset * linkedSlider.ScaledOffsetFromPivot()); }
|
||||
|
||||
else if (AnimationController.Instance.stretchKeyframesToggle.isOn == false && linkedSlider != null)
|
||||
{ value = Mathf.Clamp(linkedSlider.keyframe.atTick.Value + linkedOffset, Constants.minTick + 1, Workspace.StageWindowSize); }
|
||||
|
@ -219,7 +215,6 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public float ScaledOffsetFromPivot()
|
||||
{
|
||||
//if (IsPivotKeyframe(keyframe)) return 1f;
|
||||
if (dragTickStart == pivotKeyframe.atTick.Value) return 0f;
|
||||
|
||||
return (float)(keyframe.atTick.Value - pivotKeyframe.atTick.Value) / (dragTickStart - pivotKeyframe.atTick.Value);
|
||||
|
@ -229,13 +224,5 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
return pivotKeyframe == otherKeyframe;
|
||||
}
|
||||
|
||||
public int GetIndexAmongstSelectedKeyframes()
|
||||
{
|
||||
List<PawnKeyframe> selectedKeyframes = Workspace.Instance.GetPawnKeyframes(Workspace.keyframeID).OrderBy(x => x.atTick)?.ToList();
|
||||
if (selectedKeyframes.NullOrEmpty() || selectedKeyframes.Contains(keyframe) == false) return -1;
|
||||
|
||||
return selectedKeyframes.IndexOf(keyframe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue