Add to PDA alert level, shift duration, instructions and ID access. Also fix uknown station name. (#15220)

* PDA update and fix

* fix alert level

* Fix color level

* Maybe this will look better

* PDA update and fix

* fix alert level

* Fix color level

* Maybe this will look better

* Now threat color is taken in the same way as for emergency lamps

* Minor improvements

* Fix alert level string

* AlertLevelChangedEvent for all PDAs

* StationAlert is also stored in PDAComponent

* Removed IdAccessLevels

* Removed Access from PDAMenu.xaml.cs and Draw time real-time

* AlertLevel updated from AlertLevelChangedEvent

* Removed garbage

* Removed garbage from PDAUpdateState.cs

* Change comp-pda-ui-station-time

* revert rename PDAOwnerInfo to PdaOwnerInfo

* remove not use short names jobs

* "ftl var should be lowercase"

* "ftl var should be lowercase" again

* transfer StationAlert to PDAIdInfoText

* transfer StationAlert to PDAIdInfoText

* Line breaks of parameter/argument lists conventions

* not randomly inline property attributes

* no broadcast AlertLevelChangedEvent

* fix cctualOwnerName

* GridModifiedEvent never called

* add alert-level-unknown-instructions

* UpdateAlertLevel for latejoin

* Add alert-level-unknown

* Revert "GridModifiedEvent never called"

This reverts commit fa7d1620

* remove garbage and fix quite long
This commit is contained in:
Daniil Sikinami
2023-05-17 23:35:40 +03:00
committed by GitHub
parent 5da40f0d88
commit 7ca7272a80
8 changed files with 128 additions and 26 deletions

View File

@@ -1,20 +1,16 @@
using Content.Server.AlertLevel;
using Content.Server.CartridgeLoader;
using Content.Server.DeviceNetwork.Components;
using Content.Server.Instruments;
using Content.Server.Light.Components;
using Content.Server.Light.EntitySystems;
using Content.Server.Light.Events;
using Content.Server.PDA.Ringer;
using Content.Server.Station.Systems;
using Content.Server.Store.Components;
using Content.Server.Store.Systems;
using Content.Server.UserInterface;
using Content.Shared.PDA;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Content.Server.Mind.Components;
using Content.Server.Traitor;
using Content.Shared.Light.Component;
namespace Content.Server.PDA
@@ -35,6 +31,7 @@ namespace Content.Server.PDA
SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle);
SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged);
SubscribeLocalEvent<PDAComponent, AlertLevelChangedEvent>(OnAlertLevelChanged);
}
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
@@ -44,6 +41,7 @@ namespace Content.Server.PDA
if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent))
return;
UpdateAlertLevel(uid, pda);
UpdateStationName(uid, pda);
if (_ui.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent))
@@ -89,7 +87,9 @@ namespace Content.Server.PDA
{
ActualOwnerName = pda.OwnerName,
IdOwner = pda.ContainedID?.FullName,
JobTitle = pda.ContainedID?.JobTitle
JobTitle = pda.ContainedID?.JobTitle,
StationAlertLevel = pda.StationAlertLevel,
StationAlertColor = pda.StationAlertColor
};
if (!_ui.TryGetUi(uid, PDAUiKey.Key, out var ui))
@@ -99,7 +99,20 @@ namespace Content.Server.PDA
var hasInstrument = HasComp<InstrumentComponent>(uid);
var showUplink = HasComp<StoreComponent>(uid) && IsUnlocked(uid);
var state = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, pda.StationName, showUplink, hasInstrument, address);
UpdateStationName(uid, pda);
UpdateAlertLevel(uid, pda);
// TODO: Update the level and name of the station with each call to UpdatePdaUi is only needed for latejoin players.
// TODO: If someone can implement changing the level and name of the station when changing the PDA grid, this can be removed.
var state = new PDAUpdateState(
pda.FlashlightOn,
pda.PenSlot.HasItem,
ownerInfo,
pda.StationName,
showUplink,
hasInstrument,
address);
_cartridgeLoader?.UpdateUiState(uid, state);
}
@@ -160,6 +173,23 @@ 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);
if (!TryComp(station, out AlertLevelComponent? alertComp) ||
alertComp.AlertLevels == null)
return;
pda.StationAlertLevel = alertComp.CurrentLevel;
if (alertComp.AlertLevels.Levels.TryGetValue(alertComp.CurrentLevel, out var details))
pda.StationAlertColor = details.Color;
}
private string? GetDeviceNetAddress(EntityUid uid)
{
string? address = null;