ScaleClockTimeSmoothly.cs 892 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if CHRONOS_PLAYMAKER
  2. using HutongGames.PlayMaker;
  3. namespace Chronos.PlayMaker
  4. {
  5. [ActionCategory("Chronos")]
  6. [Tooltip("Sets the time scale on a clock smoothly over time.")]
  7. [HelpUrl("http://ludiq.io/chronos/documentation#Clock.LerpTimeScale")]
  8. public class ScaleClockTimeSmoothly : ChronosComponentAction<Clock>
  9. {
  10. [RequiredField]
  11. [CheckForComponent(typeof(Clock))]
  12. public FsmOwnerDefault gameObject;
  13. [RequiredField]
  14. public FsmFloat timeScale;
  15. [RequiredField]
  16. public FsmFloat duration;
  17. public bool steady;
  18. public override void Reset()
  19. {
  20. gameObject = null;
  21. timeScale = null;
  22. duration = null;
  23. steady = false;
  24. }
  25. public override void OnEnter()
  26. {
  27. DoAction();
  28. }
  29. private void DoAction()
  30. {
  31. if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) return;
  32. clock.LerpTimeScale(timeScale.Value, duration.Value, steady);
  33. }
  34. }
  35. }
  36. #endif