ChronosComponentAction.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #if CHRONOS_PLAYMAKER
  2. using HutongGames.PlayMaker;
  3. using UnityEngine;
  4. namespace Chronos.PlayMaker
  5. {
  6. public abstract class ChronosComponentAction<T> : FsmStateAction where T : Component
  7. {
  8. private GameObject cachedGameObject;
  9. protected T component;
  10. protected Timeline timeline
  11. {
  12. get { return component as Timeline; }
  13. }
  14. protected Clock clock
  15. {
  16. get { return component as Clock; }
  17. }
  18. protected GlobalClock globalClock
  19. {
  20. get { return component as GlobalClock; }
  21. }
  22. protected LocalClock localClock
  23. {
  24. get { return component as LocalClock; }
  25. }
  26. protected IAreaClock areaClock
  27. {
  28. get { return component as IAreaClock; }
  29. }
  30. protected AreaClock3D areaClock3D
  31. {
  32. get { return component as AreaClock3D; }
  33. }
  34. protected AreaClock2D areaClock2D
  35. {
  36. get { return component as AreaClock2D; }
  37. }
  38. protected bool UpdateCache(GameObject go)
  39. {
  40. if (go == null)
  41. {
  42. return false;
  43. }
  44. if (component == null || cachedGameObject != go)
  45. {
  46. component = go.GetComponent<T>();
  47. cachedGameObject = go;
  48. if (component == null)
  49. {
  50. LogWarning("Missing component: " + typeof(T).FullName + " on: " + go.name);
  51. }
  52. }
  53. return component != null;
  54. }
  55. }
  56. }
  57. #endif