Improvements to timeline

This commit is contained in:
AbstractConcept 2022-09-18 01:52:54 -05:00
parent d2ca61c61c
commit 591b176924
99 changed files with 460 additions and 359 deletions

View file

@ -31,6 +31,7 @@ namespace RimWorldAnimationStudio
public AnimationTimeline animationTimelinePrefab;
// Private timing variables
private int lastStageTick = 1;
private float timeSinceLastUpdate = 0;
private int cycleIndex = 0;
@ -54,9 +55,6 @@ namespace RimWorldAnimationStudio
timeSinceLastUpdate -= 1f / 60f;
stageTick += 1;
stageTimelineSlider.value = stageTick;
animationClipTimeField.text = stageTick.ToString();
if (stageTick > Workspace.StageWindowSize)
{
if (stageLoopDropdown.value == 1)
@ -73,8 +71,8 @@ namespace RimWorldAnimationStudio
++Workspace.stageID;
cycleIndex = 0;
ResetAnimationTimeline();
InitializeAnimationTimeline();
//ResetAnimationTimeline();
//InitializeAnimationTimeline();
}
}
@ -84,15 +82,29 @@ namespace RimWorldAnimationStudio
}
// Update stage timeline
animationClipTimeField.interactable = isAnimating == false;
animationClipTimeField.interactable = isAnimating == false;
animationClipLengthField.interactable = isAnimating == false;
if (lastStageTick != stageTick)
{
stageTimelineSlider.value = stageTick;
animationClipTimeField.text = stageTick.ToString();
lastStageTick = stageTick;
}
// Update animation
UpdateAnimation();
}
public void UpdateAnimation()
{
if (Workspace.Instance.AnimationTimelinesNeedUpdate())
{
ResetAnimationTimeline();
InitializeAnimationTimeline();
}
List<ActorBody> actorBodies = GetComponentsInChildren<ActorBody>().ToList();
for (int actorID = 0; actorID < actorBodies.Count; actorID++)
@ -177,21 +189,20 @@ namespace RimWorldAnimationStudio
public void Reset()
{
Workspace.stageID = 0;
isAnimating = false;
ResetAnimationTimeline();
StageCardManager.Instance.Reset();
}
public void ResetAnimationTimeline()
{
isAnimating = false;
{
timeSinceLastUpdate = 0;
cycleIndex = 0;
foreach (ActorBody actorBody in GetComponentsInChildren<ActorBody>())
{ Destroy(actorBody.gameObject); }
foreach (Transform animationTimeline in animationTimelines)
foreach (AnimationTimeline animationTimeline in animationTimelines.GetComponentsInChildren<AnimationTimeline>())
{ Destroy(animationTimeline.gameObject); }
}
@ -299,7 +310,7 @@ namespace RimWorldAnimationStudio
clip.BuildSimpleCurves();
animationTimelines.GetChild(Workspace.actorID).GetComponent<AnimationTimeline>().AddPawnKeyFrame(keyframe.keyframeID);
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[Workspace.actorID].AddPawnKeyFrame(keyframe.keyframeID);
}
public void RemovePawnKeyframe()
@ -311,12 +322,12 @@ namespace RimWorldAnimationStudio
{
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
if (keyframe.atTick == 1)
if (keyframe != null && keyframe.atTick == 1)
{ Debug.LogWarning("Cannot delete key frame - the first key frame of an animation cannot be deleted"); return; }
if (keyframe != null)
{
animationTimelines.GetChild(actorID).GetComponent<AnimationTimeline>().RemovePawnKeyFrame(keyframe.keyframeID);
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[Workspace.actorID].RemovePawnKeyFrame(keyframe.keyframeID);
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[actorID];
clip.keyframes.Remove(keyframe);
@ -383,8 +394,8 @@ namespace RimWorldAnimationStudio
animationClipLengthField.text = newstageWindowSize.ToString();
Workspace.animationDef.animationStages[Workspace.stageID].stageWindowSize = newstageWindowSize;
ResetAnimationTimeline();
InitializeAnimationTimeline();
//ResetAnimationTimeline();
//InitializeAnimationTimeline();
}
public void OnCycleNormalFieldChange()