using System.Collections.Generic; using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Prototypes; namespace Content.Shared.Alert { /// /// Provides access to all configured alerts by alert type. /// public class AlertManager { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; private Dictionary _typeToAlert; public void Initialize() { _typeToAlert = new Dictionary(); foreach (var alert in _prototypeManager.EnumeratePrototypes()) { if (!_typeToAlert.TryAdd(alert.AlertType, alert)) { Logger.ErrorS("alert", "Found alert with duplicate alertType {0} - all alerts must have" + " a unique alerttype, this one will be skipped", alert.AlertType); } } } /// /// Tries to get the alert of the indicated type /// /// true if found public bool TryGet(AlertType alertType, out AlertPrototype alert) { return _typeToAlert.TryGetValue(alertType, out alert); } } }