Clean up PDA event subscriptions. (#17434)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4d493ba674
commit
f5bd24f990
@@ -189,12 +189,6 @@ public sealed class AlertLevelSystem : EntitySystem
|
||||
}
|
||||
|
||||
RaiseLocalEvent(new AlertLevelChangedEvent(station, level));
|
||||
|
||||
var pdas = EntityQueryEnumerator<PdaComponent>();
|
||||
while (pdas.MoveNext(out var ent, out var comp))
|
||||
{
|
||||
RaiseLocalEvent(ent,new AlertLevelChangedEvent(station, level));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ namespace Content.Server.PDA
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PdaComponent, LightToggleEvent>(OnLightToggle);
|
||||
SubscribeLocalEvent<PdaComponent, GridModifiedEvent>(OnGridChanged);
|
||||
SubscribeLocalEvent<PdaComponent, AlertLevelChangedEvent>(OnAlertLevelChanged);
|
||||
|
||||
// UI Events:
|
||||
SubscribeLocalEvent<PdaComponent, PdaRequestUpdateInterfaceMessage>(OnUiMessage);
|
||||
@@ -43,6 +41,9 @@ namespace Content.Server.PDA
|
||||
SubscribeLocalEvent<PdaComponent, PdaShowMusicMessage>(OnUiMessage);
|
||||
SubscribeLocalEvent<PdaComponent, PdaShowUplinkMessage>(OnUiMessage);
|
||||
SubscribeLocalEvent<PdaComponent, PdaLockUplinkMessage>(OnUiMessage);
|
||||
|
||||
SubscribeLocalEvent<StationRenamedEvent>(OnStationRenamed);
|
||||
SubscribeLocalEvent<AlertLevelChangedEvent>(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<PdaComponent>();
|
||||
while (query.MoveNext(out var ent, out var comp))
|
||||
{
|
||||
UpdatePdaUi(ent, comp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,16 +105,7 @@ namespace Content.Server.PDA
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user