mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Improved undo redo function and timelines
This commit is contained in:
parent
1af7f41d63
commit
e36ef6a368
372 changed files with 4086 additions and 211 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue