diff --git a/Content.Server/AlertLevel/AlertLevelSystem.cs b/Content.Server/AlertLevel/AlertLevelSystem.cs index 975235b937..121f6f4c1b 100644 --- a/Content.Server/AlertLevel/AlertLevelSystem.cs +++ b/Content.Server/AlertLevel/AlertLevelSystem.cs @@ -189,12 +189,6 @@ public sealed class AlertLevelSystem : EntitySystem } RaiseLocalEvent(new AlertLevelChangedEvent(station, level)); - - var pdas = EntityQueryEnumerator(); - while (pdas.MoveNext(out var ent, out var comp)) - { - RaiseLocalEvent(ent,new AlertLevelChangedEvent(station, level)); - } } } diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index eaf7b96ecc..1fbdb5b0ff 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -33,8 +33,6 @@ namespace Content.Server.PDA base.Initialize(); SubscribeLocalEvent(OnLightToggle); - SubscribeLocalEvent(OnGridChanged); - SubscribeLocalEvent(OnAlertLevelChanged); // UI Events: SubscribeLocalEvent(OnUiMessage); @@ -43,6 +41,9 @@ namespace Content.Server.PDA SubscribeLocalEvent(OnUiMessage); SubscribeLocalEvent(OnUiMessage); SubscribeLocalEvent(OnUiMessage); + + SubscribeLocalEvent(OnStationRenamed); + SubscribeLocalEvent(OnAlertLevelChanged); } protected override void OnComponentInit(EntityUid uid, PdaComponent pda, ComponentInit args) @@ -80,10 +81,23 @@ namespace Content.Server.PDA UpdatePdaUi(uid, pda); } - private void OnGridChanged(EntityUid uid, PdaComponent pda, GridModifiedEvent args) + private void OnStationRenamed(StationRenamedEvent ev) { - UpdateStationName(uid, pda); - UpdatePdaUi(uid, pda); + UpdateAllPdaUisOnStation(); + } + + private void OnAlertLevelChanged(AlertLevelChangedEvent args) + { + UpdateAllPdaUisOnStation(); + } + + private void UpdateAllPdaUisOnStation() + { + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var ent, out var comp)) + { + UpdatePdaUi(ent, comp); + } } /// @@ -91,16 +105,7 @@ namespace Content.Server.PDA /// public void UpdatePdaUi(EntityUid uid, PdaComponent pda) { - var ownerInfo = new PdaIdInfoText - { - ActualOwnerName = pda.OwnerName, - IdOwner = pda.ContainedId?.FullName, - JobTitle = pda.ContainedId?.JobTitle, - StationAlertLevel = pda.StationAlertLevel, - StationAlertColor = pda.StationAlertColor - }; - - if (!_ui.TryGetUi(uid, PdaUiKey.Key, out var ui)) + if (!_ui.TryGetUi(uid, PdaUiKey.Key, out _)) return; var address = GetDeviceNetAddress(uid); @@ -115,7 +120,14 @@ namespace Content.Server.PDA var state = new PdaUpdateState( pda.FlashlightOn, pda.PenSlot.HasItem, - ownerInfo, + new PdaIdInfoText + { + ActualOwnerName = pda.OwnerName, + IdOwner = pda.ContainedId?.FullName, + JobTitle = pda.ContainedId?.JobTitle, + StationAlertLevel = pda.StationAlertLevel, + StationAlertColor = pda.StationAlertColor + }, pda.StationName, showUplink, hasInstrument, @@ -192,12 +204,6 @@ namespace Content.Server.PDA pda.StationName = station is null ? null : Name(station.Value); } - private void OnAlertLevelChanged(EntityUid uid, PdaComponent pda, AlertLevelChangedEvent args) - { - UpdateAlertLevel(uid, pda); - UpdatePdaUi(uid, pda); - } - private void UpdateAlertLevel(EntityUid uid, PdaComponent pda) { var station = _station.GetOwningStation(uid);