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

@@ -1,10 +1,8 @@
using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.Timing;
using Content.Server.Administration.Logs;
using Content.Server.Medical.Components;
using Content.Server.Cloning.Components;
using Content.Server.DeviceLinking.Events;
using Content.Server.DeviceLinking.Systems;
using Content.Server.Power.Components;
using Content.Server.Mind.Components;
@@ -62,12 +60,12 @@ namespace Content.Server.Cloning
TryClone(uid, consoleComponent.CloningPod.Value, consoleComponent.GeneticScanner.Value, consoleComponent: consoleComponent);
break;
}
UpdateUserInterface(consoleComponent);
UpdateUserInterface(uid, consoleComponent);
}
private void OnPowerChanged(EntityUid uid, CloningConsoleComponent component, ref PowerChangedEvent args)
{
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
private void OnMapInit(EntityUid uid, CloningConsoleComponent component, MapInitEvent args)
@@ -115,12 +113,12 @@ namespace Content.Server.Cloning
if (args.Port == CloningConsoleComponent.PodPort)
component.CloningPod = null;
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
private void OnUIOpen(EntityUid uid, CloningConsoleComponent component, AfterActivatableUIOpenEvent args)
{
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
private void OnAnchorChanged(EntityUid uid, CloningConsoleComponent component, ref AnchorStateChangedEvent args)
@@ -130,27 +128,27 @@ namespace Content.Server.Cloning
RecheckConnections(uid, component.CloningPod, component.GeneticScanner, component);
return;
}
UpdateUserInterface(component);
UpdateUserInterface(uid, component);
}
public void UpdateUserInterface(CloningConsoleComponent consoleComponent)
public void UpdateUserInterface(EntityUid consoleUid, CloningConsoleComponent consoleComponent)
{
var ui = _uiSystem.GetUiOrNull(consoleComponent.Owner, CloningConsoleUiKey.Key);
if (ui == null)
if (!_uiSystem.TryGetUi(consoleUid, CloningConsoleUiKey.Key, out var ui))
return;
if (!_powerReceiverSystem.IsPowered(consoleComponent.Owner))
if (!_powerReceiverSystem.IsPowered(consoleUid))
{
_uiSystem.CloseAll(ui);
return;
}
var newState = GetUserInterfaceState(consoleComponent);
_uiSystem.SetUiState(ui, newState);
UserInterfaceSystem.SetUiState(ui, newState);
}
public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null)
{
if (!Resolve(uid, ref consoleComponent) || !Resolve(cloningPodUid, ref cloningPod) || !Resolve(scannerUid, ref scannerComp))
if (!Resolve(uid, ref consoleComponent) || !Resolve(cloningPodUid, ref cloningPod) || !Resolve(scannerUid, ref scannerComp))
return;
if (!Transform(cloningPodUid).Anchored || !Transform(scannerUid).Anchored)
@@ -192,7 +190,7 @@ namespace Content.Server.Cloning
consoleComp.CloningPodInRange = podDistance <= consoleComp.MaxDistance;
}
UpdateUserInterface(consoleComp);
UpdateUserInterface(console, consoleComp);
}
private CloningConsoleBoundUserInterfaceState GetUserInterfaceState(CloningConsoleComponent consoleComponent)
{