Cleaner BoundUserInterfaces (#17736)

This commit is contained in:
TemporalOroboros
2023-07-08 09:02:17 -07:00
committed by GitHub
parent 55b4fb1649
commit 3ac4cf85db
137 changed files with 1069 additions and 972 deletions

View File

@@ -20,36 +20,36 @@ public sealed class RadarConsoleSystem : SharedRadarConsoleSystem
private void OnRadarStartup(EntityUid uid, RadarConsoleComponent component, ComponentStartup args)
{
UpdateState(component);
UpdateState(uid, component);
}
protected override void UpdateState(RadarConsoleComponent component)
protected override void UpdateState(EntityUid uid, RadarConsoleComponent component)
{
var xform = Transform(component.Owner);
var xform = Transform(uid);
var onGrid = xform.ParentUid == xform.GridUid;
EntityCoordinates? coordinates = onGrid ? xform.Coordinates : null;
Angle? angle = onGrid ? xform.LocalRotation : null;
// Use ourself I guess.
if (TryComp<IntrinsicUIComponent>(component.Owner, out var intrinsic))
if (TryComp<IntrinsicUIComponent>(uid, out var intrinsic))
{
foreach (var uiKey in intrinsic.UIs)
{
if (uiKey.Key?.Equals(RadarConsoleUiKey.Key) == true)
{
coordinates = new EntityCoordinates(component.Owner, Vector2.Zero);
coordinates = new EntityCoordinates(uid, Vector2.Zero);
angle = Angle.Zero;
break;
}
}
}
var radarState = new RadarConsoleBoundInterfaceState(
component.MaxRange,
coordinates,
angle,
new List<DockingInterfaceState>());
_uiSystem.GetUiOrNull(component.Owner, RadarConsoleUiKey.Key)?.SetState(radarState);
if (_uiSystem.TryGetUi(uid, RadarConsoleUiKey.Key, out var bui))
UserInterfaceSystem.SetUiState(bui, new RadarConsoleBoundInterfaceState(
component.MaxRange,
coordinates,
angle,
new List<DockingInterfaceState>()
));
}
}