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

@@ -2,6 +2,7 @@ using Content.Server.Solar.Components;
using Content.Server.UserInterface;
using Content.Shared.Solar;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
namespace Content.Server.Solar.EntitySystems
{
@@ -11,7 +12,8 @@ namespace Content.Server.Solar.EntitySystems
[UsedImplicitly]
internal sealed class PowerSolarControlConsoleSystem : EntitySystem
{
[Dependency] private PowerSolarSystem _powerSolarSystem = default!;
[Dependency] private readonly PowerSolarSystem _powerSolarSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
/// <summary>
/// Timer used to avoid updating the UI state every frame (which would be overkill)
@@ -32,9 +34,10 @@ namespace Content.Server.Solar.EntitySystems
{
_updateTimer -= 1;
var state = new SolarControlConsoleBoundInterfaceState(_powerSolarSystem.TargetPanelRotation, _powerSolarSystem.TargetPanelVelocity, _powerSolarSystem.TotalPanelPower, _powerSolarSystem.TowardsSun);
foreach (var component in EntityManager.EntityQuery<SolarControlConsoleComponent>())
var query = EntityQueryEnumerator<SolarControlConsoleComponent, ServerUserInterfaceComponent>();
while (query.MoveNext(out var uid, out var _, out var uiComp))
{
component.Owner.GetUIOrNull(SolarControlConsoleUiKey.Key)?.SetState(state);
_uiSystem.TrySetUiState(uid, SolarControlConsoleUiKey.Key, state, ui: uiComp);
}
}
}