SpaceVillainGame.Fighter.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. namespace Content.Server.Arcade.SpaceVillain;
  2. public sealed partial class SpaceVillainGame
  3. {
  4. /// <summary>
  5. /// A state holder for the fighters in the SpaceVillain game.
  6. /// </summary>
  7. public sealed class Fighter
  8. {
  9. /// <summary>
  10. /// The current hit point total of the fighter.
  11. /// </summary>
  12. [ViewVariables(VVAccess.ReadWrite)]
  13. public int Hp
  14. {
  15. get => _hp;
  16. set => _hp = MathHelper.Clamp(value, 0, HpMax);
  17. }
  18. private int _hp;
  19. /// <summary>
  20. /// The maximum hit point total of the fighter.
  21. /// </summary>
  22. [ViewVariables(VVAccess.ReadWrite)]
  23. public int HpMax
  24. {
  25. get => _hpMax;
  26. set
  27. {
  28. _hpMax = Math.Max(value, 0);
  29. Hp = MathHelper.Clamp(Hp, 0, HpMax);
  30. }
  31. }
  32. private int _hpMax;
  33. /// <summary>
  34. /// The current mana total of the fighter.
  35. /// </summary>
  36. [ViewVariables(VVAccess.ReadWrite)]
  37. public int Mp
  38. {
  39. get => _mp;
  40. set => _mp = MathHelper.Clamp(value, 0, MpMax);
  41. }
  42. private int _mp;
  43. /// <summary>
  44. /// The maximum mana total of the fighter.
  45. /// </summary>
  46. [ViewVariables(VVAccess.ReadWrite)]
  47. public int MpMax
  48. {
  49. get => _mpMax;
  50. set
  51. {
  52. _mpMax = Math.Max(value, 0);
  53. Mp = MathHelper.Clamp(Mp, 0, MpMax);
  54. }
  55. }
  56. private int _mpMax;
  57. /// <summary>
  58. /// Whether the given fighter can take damage/lose mana.
  59. /// </summary>
  60. [ViewVariables(VVAccess.ReadWrite)]
  61. public bool Invincible = false;
  62. }
  63. }