MobThresholdsComponent.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Content.Shared.Alert;
  2. using Content.Shared.FixedPoint;
  3. using Content.Shared.Mobs.Systems;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization;
  7. namespace Content.Shared.Mobs.Components;
  8. [RegisterComponent, NetworkedComponent]
  9. [Access(typeof(MobThresholdSystem))]
  10. public sealed partial class MobThresholdsComponent : Component
  11. {
  12. [DataField("thresholds", required: true)]
  13. public SortedDictionary<FixedPoint2, MobState> Thresholds = new();
  14. [DataField("triggersAlerts")]
  15. public bool TriggersAlerts = true;
  16. [DataField("currentThresholdState")]
  17. public MobState CurrentThresholdState;
  18. /// <summary>
  19. /// The health alert that should be displayed for player controlled entities.
  20. /// Used for alternate health alerts (silicons, for example)
  21. /// </summary>
  22. [DataField("stateAlertDict")]
  23. public Dictionary<MobState, ProtoId<AlertPrototype>> StateAlertDict = new()
  24. {
  25. {MobState.Alive, "HumanHealth"},
  26. {MobState.Critical, "HumanCrit"},
  27. {MobState.Dead, "HumanDead"},
  28. };
  29. [DataField]
  30. public ProtoId<AlertCategoryPrototype> HealthAlertCategory = "Health";
  31. /// <summary>
  32. /// Whether or not this entity should display damage overlays (robots don't feel pain, black out etc.)
  33. /// </summary>
  34. [DataField("showOverlays")]
  35. public bool ShowOverlays = true;
  36. /// <summary>
  37. /// Whether or not this entity can be revived out of a dead state.
  38. /// </summary>
  39. [DataField("allowRevives")]
  40. public bool AllowRevives;
  41. }
  42. [Serializable, NetSerializable]
  43. public sealed class MobThresholdsComponentState : ComponentState
  44. {
  45. public Dictionary<FixedPoint2, MobState> UnsortedThresholds;
  46. public bool TriggersAlerts;
  47. public MobState CurrentThresholdState;
  48. public Dictionary<MobState, ProtoId<AlertPrototype>> StateAlertDict;
  49. public bool ShowOverlays;
  50. public bool AllowRevives;
  51. public MobThresholdsComponentState(Dictionary<FixedPoint2, MobState> unsortedThresholds,
  52. bool triggersAlerts,
  53. MobState currentThresholdState,
  54. Dictionary<MobState,
  55. ProtoId<AlertPrototype>> stateAlertDict,
  56. bool showOverlays,
  57. bool allowRevives)
  58. {
  59. UnsortedThresholds = unsortedThresholds;
  60. TriggersAlerts = triggersAlerts;
  61. CurrentThresholdState = currentThresholdState;
  62. StateAlertDict = stateAlertDict;
  63. ShowOverlays = showOverlays;
  64. AllowRevives = allowRevives;
  65. }
  66. }