ActiveAni PlayAni(AniJob aniJob, float fpsMult, float progress, FrameActionPair[] pairs) { if (aniJob == null) { throw new ArgumentNullException("AniJob is null!"); } if (aniJob.ModelInstance != this.Instance) { throw new ArgumentException("AniJob is not for this Model!"); } if (fpsMult <= 0) { throw new ArgumentException("Frame speed multiplier has to be greater than zero!"); } if (!this.TryGetAniFromJob(aniJob, out Animation ani)) { return(null); } // search a free ActiveAni ActiveAni aa = null; for (int i = 0; i < activeAnis.Count; i++) { if (activeAnis[i].Ani == null) // this ActiveAni is unused { aa = activeAnis[i]; // continue to search, maybe there's an active ani with the same layer } else if (activeAnis[i].AniJob.Layer == aniJob.Layer) // same layer, stop this animation { aa = activeAnis[i]; aa.Stop(); // stop this animation break; } } if (aa == null) // no free ActiveAni, create a new one { aa = new ActiveAni(this); activeAnis.Add(aa); } aa.Start(ani, fpsMult, progress, pairs); return(aa); }
public void StopAnimation(ActiveAni ani, bool fadeOut = false) { if (ani == null) { throw new ArgumentNullException("ActiveAni is null!"); } if (ani.Ani == null) { return; } if (ani.Model != this) { throw new ArgumentException("ActiveAni is not from this Model!"); } pStopAnimation(ani, fadeOut); ani.Stop(); }