// WL-Changes-start: Alert Level Rework
using Content.Shared.AlertLevel;
using Robust.Shared.Prototypes;
// WL-Changes-end
namespace Content.Server.AlertLevel;
///
/// Alert level component. This is the component given to a station to
/// signify its alert level state.
///
[RegisterComponent]
public sealed partial class AlertLevelComponent : Component
{
///
/// The current set of alert levels on the station.
///
[ViewVariables]
// WL-Changes-start: Alert Level Rework
public AlertLevelsListPrototype? AlertLevels;
// Once stations are a prototype, this should be used.
[DataField(required: true)]
public ProtoId AlertLevelsListPrototype;
// WL-Changes-end
///
/// The current level on the station.
///
[ViewVariables(VVAccess.ReadWrite)] public string CurrentLevel = string.Empty;
///
/// Is current station level can be changed by crew.
///
[ViewVariables(VVAccess.ReadWrite)] public bool IsLevelLocked = false;
[ViewVariables] public float CurrentDelay = 0;
[ViewVariables] public bool ActiveDelay;
///
/// If the level can be selected on the station.
///
[ViewVariables]
public bool IsSelectable
{
get
{
var prototypeManager = IoCManager.Resolve();
if (AlertLevels == null
// WL-Changes-start: Alert Level Rework
|| !prototypeManager.TryIndex(CurrentLevel, out var level)) // TryGetValue -> TryIndex
return false;
// WL-Changes-end
return level.Selectable && !level.DisableSelection && !IsLevelLocked;
}
}
}