StatsComponent.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine.Stats
  6. {
  7. [HideMonoScript, AddComponentMenu("KairoEngine/Stats Controller")]
  8. public class StatsComponent : MonoBehaviour
  9. {
  10. [InlineProperty, HideLabel, PropertySpace(2, 2), OnInspectorInit("Initialize")] public StatsController statsController = new StatsController();
  11. //[InlineButton("CreateNewStatusEffect", "Create")]
  12. [LabelText("Add new StatusEffect"), ShowIf("@showEdit")] public StatusEffectTemplate template;
  13. [ShowIf("@target == null")] public Transform target;
  14. private bool showEdit = false;
  15. void Awake()
  16. {
  17. statsController.Initialize();
  18. }
  19. void OnDisable()
  20. {
  21. statsController.statusEffects.Stop();
  22. }
  23. private void Initialize()
  24. {
  25. statsController.statusEffects.target = target;
  26. statsController.statusEffects.Start();
  27. }
  28. private void CreateNewStatusEffect()
  29. {
  30. statsController.statusEffects.Add(template, null);
  31. }
  32. }
  33. }