Refactor UserInterface properties to use a helper (#1896)

This commit is contained in:
DrSmugleaf
2020-08-24 20:47:17 +02:00
committed by GitHub
parent d9f02a6a0a
commit 520e523d30
29 changed files with 76 additions and 166 deletions

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Materials;
using Content.Shared.GameObjects.Components.Power;
using Content.Shared.GameObjects.Components.Research;
@@ -45,12 +46,7 @@ namespace Content.Server.GameObjects.Components.Research
private static readonly TimeSpan InsertionTime = TimeSpan.FromSeconds(0.9f);
[ViewVariables]
private BoundUserInterface? UserInterface =>
Owner.TryGetComponent(out ServerUserInterfaceComponent? ui) &&
ui.TryGetBoundUserInterface(LatheUiKey.Key, out var boundUi)
? boundUi
: null;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(LatheUiKey.Key);
public override void Initialize()
{

View File

@@ -1,5 +1,6 @@
#nullable enable
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects.Components.UserInterface;
@@ -18,11 +19,7 @@ namespace Content.Server.GameObjects.Components.Research
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
// TODO: Create GUI for changing RD server.
private BoundUserInterface? UserInterface =>
Owner.TryGetComponent(out ServerUserInterfaceComponent? ui) &&
ui.TryGetBoundUserInterface(ResearchClientUiKey.Key, out var boundUi)
? boundUi
: null;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchClientUiKey.Key);
public bool ConnectedToServer => Server != null;

View File

@@ -1,5 +1,6 @@
#nullable enable
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Server.Utility;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Interfaces.GameObjects.Components;
@@ -30,12 +31,7 @@ namespace Content.Server.GameObjects.Components.Research
private bool Powered => !Owner.TryGetComponent(out PowerReceiverComponent? receiver) || receiver.Powered;
[ViewVariables]
private BoundUserInterface? UserInterface =>
Owner.TryGetComponent(out ServerUserInterfaceComponent? ui) &&
ui.TryGetBoundUserInterface(ResearchConsoleUiKey.Key, out var boundUi)
? boundUi
: null;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchConsoleUiKey.Key);
public override void Initialize()
{