Improved undo redo function and timelines

This commit is contained in:
AbstractConcept 2022-09-21 00:40:58 -05:00
parent 1af7f41d63
commit e36ef6a368
372 changed files with 4086 additions and 211 deletions

View file

@ -68,5 +68,37 @@ namespace RimWorldAnimationStudio
{
BroadcastMessage("UpdateGhostFrames");
}
public void OnMoveTimeline(int delta)
{
int? siblingIndex = transform.parent.GetComponentsInChildren<AnimationTimeline>()?.ToList()?.IndexOf(this);
int? siblingCount = transform.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);
}
}
public bool MoveAnimationTimeline(int startIndex, int delta)
{
if (startIndex + delta < 0 || startIndex + delta >= Workspace.animationDef.animationStages[Workspace.stageID].animationClips.Count)
{ return false; }
Actor actor = Workspace.animationDef.actors[startIndex];
Workspace.animationDef.actors[startIndex] = Workspace.animationDef.actors[startIndex + delta];
Workspace.animationDef.actors[startIndex + delta] = actor;
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(startIndex);
Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex] = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex + delta];
Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex + delta] = clip;
Workspace.actorID = startIndex + delta;
Workspace.Instance.RecordEvent("Timeline move");
return true;
}
}
}