WindZoneTimeline.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using UnityEngine;
  2. namespace Chronos
  3. {
  4. public class WindZoneTimeline : ComponentTimeline<WindZone>
  5. {
  6. private float _windMain;
  7. private float _windTurbulence;
  8. private float _windPulseFrequency;
  9. private float _windPulseMagnitude;
  10. /// <summary>
  11. /// The wind that is applied to the wind zone before time effects. Use this property instead of WindZone.windMain, which will be overwritten by the timeline at runtime.
  12. /// </summary>
  13. public float windMain
  14. {
  15. get { return _windMain; }
  16. set
  17. {
  18. _windMain = value;
  19. AdjustProperties();
  20. }
  21. }
  22. /// <summary>
  23. /// The turbulence that is applied to the wind zone before time effects. Use this property instead of WindZone.windTurbulence, which will be overwritten by the timeline at runtime.
  24. /// </summary>
  25. public float windTurbulence
  26. {
  27. get { return _windTurbulence; }
  28. set
  29. {
  30. _windTurbulence = value;
  31. AdjustProperties();
  32. }
  33. }
  34. /// <summary>
  35. /// The pulse magnitude that is applied to the wind zone before time effects. Use this property instead of WindZone.windPulseMagnitude, which will be overwritten by the timeline at runtime.
  36. /// </summary>
  37. public float windPulseMagnitude
  38. {
  39. get { return _windPulseMagnitude; }
  40. set
  41. {
  42. _windPulseMagnitude = value;
  43. AdjustProperties();
  44. }
  45. }
  46. /// <summary>
  47. /// The pulse frquency that is applied to the wind zone before time effects. Use this property instead of WindZone.windPulseFrequency, which will be overwritten by the timeline at runtime.
  48. /// </summary>
  49. public float windPulseFrequency
  50. {
  51. get { return _windPulseFrequency; }
  52. set
  53. {
  54. _windPulseFrequency = value;
  55. AdjustProperties();
  56. }
  57. }
  58. public WindZoneTimeline(Timeline timeline, WindZone component) : base(timeline, component) { }
  59. public override void CopyProperties(WindZone source)
  60. {
  61. _windMain = source.windMain;
  62. _windTurbulence = source.windTurbulence;
  63. _windPulseFrequency = source.windPulseFrequency;
  64. _windPulseMagnitude = source.windPulseMagnitude;
  65. }
  66. public override void AdjustProperties(float timeScale)
  67. {
  68. component.windTurbulence = windTurbulence * timeScale * Mathf.Abs(timeScale);
  69. component.windPulseFrequency = windPulseFrequency * timeScale;
  70. component.windPulseMagnitude = windPulseMagnitude * Mathf.Sign(timeScale);
  71. }
  72. }
  73. }