/// <summary>
 /// Invokes the setter.
 /// </summary>
 private void InvokeSetter()
 {
     if (XValue != null && YValue != null)
     {
         FrameCallback.Invoke(new Float2D(XValue.Value, YValue.Value));
     }
 }
 /// <summary>
 /// Invokes the finisher.
 /// </summary>
 private void InvokeFinisher()
 {
     if (EndCallback != null && !IsEnded)
     {
         lock (EndCallback)
         {
             if (CurrentStatus == AnimatorStatus.Stopped)
             {
                 IsEnded = true;
                 EndCallback.Invoke();
             }
         }
     }
 }
Exemple #3
0
 private void ElapsedInt(ulong millSinceBeginning = 0)
 {
     while (true)
     {
         lock (_tempPaths)
         {
             if (_tempPaths != null && ActivePath == null && _tempPaths.Count > 0)
             {
                 while (ActivePath == null)
                 {
                     if (_tempReverseRepeat)
                     {
                         ActivePath = _tempPaths.LastOrDefault();
                         _tempPaths.RemoveAt(_tempPaths.Count - 1);
                     }
                     else
                     {
                         ActivePath = _tempPaths.FirstOrDefault();
                         _tempPaths.RemoveAt(0);
                     }
                     _timer.ResetClock();
                     millSinceBeginning = 0;
                 }
             }
             var ended = ActivePath == null;
             if (ActivePath != null)
             {
                 if (!_tempReverseRepeat && millSinceBeginning < ActivePath.Delay)
                 {
                     CurrentStatus = AnimatorStatus.OnHold;
                     return;
                 }
                 if (millSinceBeginning - (!_tempReverseRepeat ? ActivePath.Delay : 0) <= ActivePath.Duration)
                 {
                     if (CurrentStatus != AnimatorStatus.Playing)
                     {
                         CurrentStatus = AnimatorStatus.Playing;
                     }
                     var value = ActivePath.Function(_tempReverseRepeat ? ActivePath.Duration - millSinceBeginning : millSinceBeginning - ActivePath.Delay, ActivePath.Start, ActivePath.Change, ActivePath.Duration);
                     FrameCallbackInt.Invoke((int)value);
                     return;
                 }
                 if (CurrentStatus == AnimatorStatus.Playing)
                 {
                     if (_tempPaths.Count == 0)
                     {
                         // For the last path, we make sure that control is in end point
                         FrameCallbackInt.Invoke(_tempReverseRepeat ? (int)ActivePath.Start : (int)ActivePath.End);
                         ended = true;
                     }
                     else
                     {
                         if ((_tempReverseRepeat && ActivePath.Delay > 0) || !_tempReverseRepeat && _tempPaths.FirstOrDefault()?.Delay > 0)
                         {
                             // Or if the next path or this one in revese order has a delay
                             FrameCallbackInt.Invoke(_tempReverseRepeat ? (int)ActivePath.Start : (int)ActivePath.End);
                         }
                     }
                 }
                 if (_tempReverseRepeat && (millSinceBeginning - ActivePath.Duration) < ActivePath.Delay)
                 {
                     CurrentStatus = AnimatorStatus.OnHold;
                     return;
                 }
                 ActivePath = null;
             }
             if (!ended)
             {
                 return;
             }
         }
         if (Repeat)
         {
             lock (_tempPaths)
             {
                 _tempPaths.AddRange(_paths);
                 _tempReverseRepeat = ReverseRepeat && !_tempReverseRepeat;
             }
             millSinceBeginning = 0;
             continue;
         }
         Stop();
         EndCallback?.Invoke();
         break;
     }
 }