Skip to content

Commit

Permalink
Refactor: Move method
Browse files Browse the repository at this point in the history
  • Loading branch information
acidbubbles committed Oct 4, 2021
1 parent d4548e1 commit d04016b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 0 additions & 16 deletions src/AtomAnimations/Animations/AtomAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,22 +569,6 @@ private static AtomAnimationClip GetSiblingInLayer(IList<AtomAnimationClip> laye
return sibling;
}

public static AtomAnimationClip GetPrincipalClipInLayer(IList<AtomAnimationClip> layer, string animationName, string animationSet)
{
#warning Optimize and move to a Layer object
var clip = (animationSet != null ? layer.FirstOrDefault(c => c.animationSet == animationSet) : null) ??
layer.FirstOrDefault(c => c.playbackMainInLayer) ??
layer.FirstOrDefault(c => c.animationName == animationName) ??
layer.FirstOrDefault(c => c.autoPlay) ??
layer[0];

// This is to prevent playing on the main layer, starting a set on another layer, which will then override the clip you just played on the main layer
if (clip.animationSet != null && clip.animationSet != animationSet)
clip = null;

return clip;
}

public void PlayOneAndOtherMainsInLayers(AtomAnimationClip selected, bool sequencing = true)
{
foreach (var clip in GetMainClipPerLayer())
Expand Down
18 changes: 17 additions & 1 deletion src/AtomAnimations/Editing/AtomAnimationEditContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ private AtomAnimationClip[] GetMainClipPerLayer()
var layer = layers[i];
list[i] = layer[0].animationLayer == current.animationLayer
? current
: AtomAnimation.GetPrincipalClipInLayer(layer, current.animationName, current.animationSet);
: GetPrincipalClipInLayer(layer, current.animationName, current.animationSet);
}

// Always start with the selected clip to avoid animation sets starting another animation on the currently shown layer
Expand All @@ -593,6 +593,22 @@ private AtomAnimationClip[] GetMainClipPerLayer()
return list;
}

private static AtomAnimationClip GetPrincipalClipInLayer(IList<AtomAnimationClip> layer, string animationName, string animationSet)
{
#warning Optimize and move to a Layer object
var clip = (animationSet != null ? layer.FirstOrDefault(c => c.animationSet == animationSet) : null) ??
layer.FirstOrDefault(c => c.playbackMainInLayer) ??
layer.FirstOrDefault(c => c.animationName == animationName) ??
layer.FirstOrDefault(c => c.autoPlay) ??
layer[0];

// This is to prevent playing on the main layer, starting a set on another layer, which will then override the clip you just played on the main layer
if (clip.animationSet != null && clip.animationSet != animationSet)
clip = null;

return clip;
}

#endregion

#region Selection
Expand Down

0 comments on commit d04016b

Please sign in to comment.