MotionData.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Runtime.InteropServices;
  2. using LitMotion.Collections;
  3. namespace LitMotion
  4. {
  5. [StructLayout(LayoutKind.Sequential)]
  6. public struct MotionDataCore
  7. {
  8. public MotionStatus Status;
  9. public double Time;
  10. public float PlaybackSpeed;
  11. public float Duration;
  12. public Ease Ease;
  13. #if LITMOTION_COLLECTIONS_2_0_OR_NEWER
  14. public NativeAnimationCurve AnimationCurve;
  15. #else
  16. public UnsafeAnimationCurve AnimationCurve;
  17. #endif
  18. public MotionTimeKind TimeKind;
  19. public float Delay;
  20. public int Loops;
  21. public DelayType DelayType;
  22. public LoopType LoopType;
  23. public static readonly MotionDataCore Default = new()
  24. {
  25. Loops = 1,
  26. PlaybackSpeed = 1f,
  27. };
  28. }
  29. /// <summary>
  30. /// A structure representing motion data.
  31. /// </summary>
  32. /// <typeparam name="TValue">The type of value to animate</typeparam>
  33. /// <typeparam name="TOptions">The type of special parameters given to the motion data</typeparam>
  34. [StructLayout(LayoutKind.Sequential)]
  35. public struct MotionData<TValue, TOptions>
  36. where TValue : unmanaged
  37. where TOptions : unmanaged, IMotionOptions
  38. {
  39. // Because of pointer casting, this field must always be placed at the beginning.
  40. public MotionDataCore Core;
  41. public TValue StartValue;
  42. public TValue EndValue;
  43. public TOptions Options;
  44. public static readonly MotionData<TValue, TOptions> Default = new()
  45. {
  46. Core = MotionDataCore.Default,
  47. };
  48. }
  49. }