AlertLevelComponent.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  2. namespace Content.Server.AlertLevel;
  3. /// <summary>
  4. /// Alert level component. This is the component given to a station to
  5. /// signify its alert level state.
  6. /// </summary>
  7. [RegisterComponent]
  8. public sealed partial class AlertLevelComponent : Component
  9. {
  10. /// <summary>
  11. /// The current set of alert levels on the station.
  12. /// </summary>
  13. [ViewVariables]
  14. public AlertLevelPrototype? AlertLevels;
  15. // Once stations are a prototype, this should be used.
  16. [DataField("alertLevelPrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<AlertLevelPrototype>))]
  17. public string AlertLevelPrototype = default!;
  18. /// <summary>
  19. /// The current level on the station.
  20. /// </summary>
  21. [ViewVariables(VVAccess.ReadWrite)] public string CurrentLevel = string.Empty;
  22. /// <summary>
  23. /// Is current station level can be changed by crew.
  24. /// </summary>
  25. [ViewVariables(VVAccess.ReadWrite)] public bool IsLevelLocked = false;
  26. [ViewVariables] public float CurrentDelay = 0;
  27. [ViewVariables] public bool ActiveDelay;
  28. /// <summary>
  29. /// If the level can be selected on the station.
  30. /// </summary>
  31. [ViewVariables]
  32. public bool IsSelectable
  33. {
  34. get
  35. {
  36. if (AlertLevels == null
  37. || !AlertLevels.Levels.TryGetValue(CurrentLevel, out var level))
  38. {
  39. return false;
  40. }
  41. return level.Selectable && !level.DisableSelection && !IsLevelLocked;
  42. }
  43. }
  44. }