HealthPool.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
  2. #pragma warning disable CS0649 // Field is never assigned to, and will always have its default value.
  3. using Animancer.Samples.FineControl;
  4. using System;
  5. using UnityEngine;
  6. namespace Animancer.Samples.StateMachines
  7. {
  8. /// <summary>Manages a character's health and damage received.</summary>
  9. ///
  10. /// <remarks>
  11. /// <strong>Sample:</strong>
  12. /// <see href="https://kybernetik.com.au/animancer/docs/samples/fsm/interruptions">
  13. /// Interruptions</see>
  14. /// </remarks>
  15. ///
  16. /// https://kybernetik.com.au/animancer/api/Animancer.Samples.StateMachines/HealthPool
  17. ///
  18. [AddComponentMenu(Strings.SamplesMenuPrefix + "Interruptions - Health Pool")]
  19. [AnimancerHelpUrl(typeof(HealthPool))]
  20. public class HealthPool : MonoBehaviour, IInteractable
  21. {
  22. /************************************************************************************************************************/
  23. // Normally, this class would have fields like maximum health and
  24. // current health to keep track of how much damage the character takes,
  25. // but for this sample we're just pretending the character was hit
  26. // whenever something interacts with it.
  27. public event Action OnHitReceived;
  28. /************************************************************************************************************************/
  29. public void Interact()
  30. {
  31. OnHitReceived?.Invoke();
  32. }
  33. /************************************************************************************************************************/
  34. }
  35. }