ITransition.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2022 Kybernetik //
  2. using Object = UnityEngine.Object;
  3. namespace Animancer
  4. {
  5. /// <summary>An object which can create an <see cref="AnimancerState"/> and set its details.</summary>
  6. /// <remarks>
  7. /// Transitions are generally used as arguments for <see cref="AnimancerPlayable.Play(ITransition)"/>.
  8. /// <para></para>
  9. /// Documentation: <see href="https://kybernetik.com.au/animancer/docs/manual/transitions">Transitions</see>
  10. /// </remarks>
  11. /// https://kybernetik.com.au/animancer/api/Animancer/ITransition
  12. ///
  13. public interface ITransition : IHasKey, IPolymorphic
  14. {
  15. /************************************************************************************************************************/
  16. /// <summary>
  17. /// Creates and returns a new <see cref="AnimancerState"/>.
  18. /// <para></para>
  19. /// Note that using methods like <see cref="AnimancerPlayable.Play(ITransition)"/> will also call
  20. /// <see cref="Apply"/>, so if you call this method manually you may want to call that method as well. Or you
  21. /// can just use <see cref="AnimancerUtilities.CreateStateAndApply"/>.
  22. /// </summary>
  23. /// <remarks>
  24. /// The first time a transition is used on an object, this method is called to create the state and register it
  25. /// in the internal dictionary using the <see cref="IHasKey.Key"/> so that it can be reused later on.
  26. /// </remarks>
  27. AnimancerState CreateState();
  28. /// <summary>The amount of time this transition should take (in seconds).</summary>
  29. float FadeDuration { get; }
  30. /// <summary>
  31. /// The <see cref="Animancer.FadeMode"/> which should be used when this transition is passed into
  32. /// <see cref="AnimancerPlayable.Play(ITransition)"/>.
  33. /// </summary>
  34. FadeMode FadeMode { get; }
  35. /// <summary>
  36. /// Called by <see cref="AnimancerPlayable.Play(ITransition)"/> to apply any modifications to the `state`.
  37. /// </summary>
  38. /// <remarks>
  39. /// Unlike <see cref="CreateState"/>, this method is called every time the transition is used so it can do
  40. /// things like set the <see cref="AnimancerState.Events"/> or starting <see cref="AnimancerState.Time"/>.
  41. /// </remarks>
  42. void Apply(AnimancerState state);
  43. /************************************************************************************************************************/
  44. }
  45. /// <summary>An <see cref="ITransition"/> which creates a specific type of <see cref="AnimancerState"/>.</summary>
  46. /// <remarks>
  47. /// Documentation: <see href="https://kybernetik.com.au/animancer/docs/manual/transitions">Transitions</see>
  48. /// </remarks>
  49. /// https://kybernetik.com.au/animancer/api/Animancer/ITransition_1
  50. ///
  51. public interface ITransition<TState> : ITransition where TState : AnimancerState
  52. {
  53. /************************************************************************************************************************/
  54. /// <summary>
  55. /// The state that was created by this object. Specifically, this is the state that was most recently
  56. /// passed into <see cref="ITransition.Apply"/> (usually by <see cref="AnimancerPlayable.Play(ITransition)"/>).
  57. /// </summary>
  58. TState State { get; }
  59. /************************************************************************************************************************/
  60. /// <summary>Creates and returns a new <typeparamref name="TState"/>.</summary>
  61. new TState CreateState();
  62. /************************************************************************************************************************/
  63. }
  64. }