StatModifier.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine.Stats
  6. {
  7. [System.Serializable]
  8. public class StatModifier
  9. {
  10. [ShowInInspector, HideLabel, ShowIf("@enabled == true")] public string text => $"{op}{value}{endOp} {valueType} {statName} - {from}";
  11. [ShowInInspector, HideLabel, HorizontalGroup("m",Width=0.02f), ShowIf("@enabled == false")] public bool enabled = false;
  12. [HideLabel, HorizontalGroup("m", Width=0.1f), ValueDropdown("GetOperators"), ShowIf("@enabled == false")] public string op = "+";
  13. [HideLabel, HorizontalGroup("m", Width=0.1f), ShowIf("@enabled == false")] public int value = 1;
  14. [HideLabel, HorizontalGroup("m", Width=0.1f), ValueDropdown("GetEndOperators"), ShowIf("@enabled == false")] public string endOp = "";
  15. [HideLabel, HorizontalGroup("m", Width=0.16f), ValueDropdown("GetValueTypes"), ShowIf("@enabled == false")] public string valueType = "";
  16. [HideLabel, HorizontalGroup("m", Width=0.2f), ShowIf("@enabled == false")] public string statName = "Stat Name";
  17. [HideLabel, HorizontalGroup("m", Width=0.32f), ShowIf("@enabled == false")] public string from = "From Entity";
  18. private IEnumerable GetOperators = new ValueDropdownList<string>()
  19. {
  20. { "+", "+" },
  21. { "-", "-" }
  22. };
  23. private IEnumerable GetEndOperators = new ValueDropdownList<string>()
  24. {
  25. { " ", "" },
  26. { "%", "%" }
  27. };
  28. private IEnumerable GetValueTypes = new ValueDropdownList<string>()
  29. {
  30. { " ", "" },
  31. { "min", "min" },
  32. { "max", "max" }
  33. };
  34. public bool Equals(StatModifier statModifier) => statModifier.text == text ? true : false;
  35. public StatModifier()
  36. {
  37. this.op = "+";
  38. this.value = 1;
  39. this.endOp = "";
  40. this.valueType = "";
  41. this.statName = "Stat Name";
  42. this.from = "From Entity";
  43. this.enabled = false;
  44. }
  45. public StatModifier(string op = "+", int value = 1, string endOp = "", string valueType = "", string statName = "Stat Name", string from = "From Entity", bool enabled = true)
  46. {
  47. this.op = op;
  48. this.value = value;
  49. this.endOp = endOp;
  50. this.valueType = valueType;
  51. this.statName = statName;
  52. this.from = from;
  53. this.enabled = enabled;
  54. }
  55. }
  56. }