ITransition.cs 3.5 KB

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