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));
|
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();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<PdaComponent, LightToggleEvent>(OnLightToggle);
|
SubscribeLocalEvent<PdaComponent, LightToggleEvent>(OnLightToggle);
|
||||||
SubscribeLocalEvent<PdaComponent, GridModifiedEvent>(OnGridChanged);
|
|
||||||
SubscribeLocalEvent<PdaComponent, AlertLevelChangedEvent>(OnAlertLevelChanged);
|
|
||||||
|
|
||||||
// UI Events:
|
// UI Events:
|
||||||
SubscribeLocalEvent<PdaComponent, PdaRequestUpdateInterfaceMessage>(OnUiMessage);
|
SubscribeLocalEvent<PdaComponent, PdaRequestUpdateInterfaceMessage>(OnUiMessage);
|
||||||
@@ -43,6 +41,9 @@ namespace Content.Server.PDA
|
|||||||
SubscribeLocalEvent<PdaComponent, PdaShowMusicMessage>(OnUiMessage);
|
SubscribeLocalEvent<PdaComponent, PdaShowMusicMessage>(OnUiMessage);
|
||||||
SubscribeLocalEvent<PdaComponent, PdaShowUplinkMessage>(OnUiMessage);
|
SubscribeLocalEvent<PdaComponent, PdaShowUplinkMessage>(OnUiMessage);
|
||||||
SubscribeLocalEvent<PdaComponent, PdaLockUplinkMessage>(OnUiMessage);
|
SubscribeLocalEvent<PdaComponent, PdaLockUplinkMessage>(OnUiMessage);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<StationRenamedEvent>(OnStationRenamed);
|
||||||
|
SubscribeLocalEvent<AlertLevelChangedEvent>(OnAlertLevelChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnComponentInit(EntityUid uid, PdaComponent pda, ComponentInit args)
|
protected override void OnComponentInit(EntityUid uid, PdaComponent pda, ComponentInit args)
|
||||||
@@ -80,10 +81,23 @@ namespace Content.Server.PDA
|
|||||||
UpdatePdaUi(uid, pda);
|
UpdatePdaUi(uid, pda);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGridChanged(EntityUid uid, PdaComponent pda, GridModifiedEvent args)
|
private void OnStationRenamed(StationRenamedEvent ev)
|
||||||
{
|
{
|
||||||
UpdateStationName(uid, pda);
|
UpdateAllPdaUisOnStation();
|
||||||
UpdatePdaUi(uid, pda);
|
}
|
||||||
|
|
||||||
|
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>
|
/// <summary>
|
||||||
@@ -91,16 +105,7 @@ namespace Content.Server.PDA
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdatePdaUi(EntityUid uid, PdaComponent pda)
|
public void UpdatePdaUi(EntityUid uid, PdaComponent pda)
|
||||||
{
|
{
|
||||||
var ownerInfo = new PdaIdInfoText
|
if (!_ui.TryGetUi(uid, PdaUiKey.Key, out _))
|
||||||
{
|
|
||||||
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))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var address = GetDeviceNetAddress(uid);
|
var address = GetDeviceNetAddress(uid);
|
||||||
@@ -115,7 +120,14 @@ namespace Content.Server.PDA
|
|||||||
var state = new PdaUpdateState(
|
var state = new PdaUpdateState(
|
||||||
pda.FlashlightOn,
|
pda.FlashlightOn,
|
||||||
pda.PenSlot.HasItem,
|
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,
|
pda.StationName,
|
||||||
showUplink,
|
showUplink,
|
||||||
hasInstrument,
|
hasInstrument,
|
||||||
@@ -192,12 +204,6 @@ namespace Content.Server.PDA
|
|||||||
pda.StationName = station is null ? null : Name(station.Value);
|
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)
|
private void UpdateAlertLevel(EntityUid uid, PdaComponent pda)
|
||||||
{
|
{
|
||||||
var station = _station.GetOwningStation(uid);
|
var station = _station.GetOwningStation(uid);
|
||||||
|
|||||||
Reference in New Issue
Block a user