diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 583a300fe..ce30bd8d3 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -37,11 +37,15 @@ namespace Spine { public class Animation { internal String name; internal ExposedList timelines; + internal HashSet timelineIds; internal float duration; public Animation (string name, ExposedList timelines, float duration) { if (name == null) throw new ArgumentNullException("name", "name cannot be null."); if (timelines == null) throw new ArgumentNullException("timelines", "timelines cannot be null."); + this.timelineIds = new HashSet(); + foreach (Timeline timeline in timelines) + timelineIds.Add(timeline.PropertyId); this.name = name; this.timelines = timelines; this.duration = duration; @@ -55,6 +59,11 @@ namespace Spine { /// The animation's name, which is unique across all animations in the skeleton. public string Name { get { return name; } } + /// Whether the timeline with the property id is contained in this animation. + public bool HasTimeline (int id) { + return timelineIds.Contains(id); + } + /// Applies all the animation's timelines to the specified skeleton. /// public void Apply (Skeleton skeleton, float lastTime, float time, bool loop, ExposedList events, float alpha, MixBlend blend, diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index b0359ecf8..3dfed92ae 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -777,11 +777,11 @@ namespace Spine { if (!propertyIDs.Add(id)) timelineMode[i] = AnimationState.Subsequent; else if (to == null || timeline is AttachmentTimeline || timeline is DrawOrderTimeline - || timeline is EventTimeline || !HasTimeline(to, id)) { + || timeline is EventTimeline || !to.animation.HasTimeline(id)) { timelineMode[i] = AnimationState.First; } else { for (TrackEntry next = to.mixingTo; next != null; next = next.mixingTo) { - if (HasTimeline(next, id)) continue; + if (next.animation.HasTimeline(id)) continue; if (next.mixDuration > 0) { timelineMode[i] = AnimationState.HoldMix; timelineHoldMix[i] = next; @@ -809,13 +809,6 @@ namespace Spine { } } - static bool HasTimeline (TrackEntry entry, int id) { - var timelines = entry.animation.timelines.Items; - for (int i = 0, n = entry.animation.timelines.Count; i < n; i++) - if (timelines[i].PropertyId == id) return true; - return false; - } - /// The track entry for the animation currently playing on the track, or null if no animation is currently playing. public TrackEntry GetCurrent (int trackIndex) { if (trackIndex >= tracks.Count) return null;