Inline TryGetComponent completely, for real
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Content.Server.Research.Components
|
||||
[DataField("sound")]
|
||||
private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard");
|
||||
|
||||
[ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
[ViewVariables] private bool Powered => !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchConsoleUiKey.Key);
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace Content.Server.Research.Components
|
||||
|
||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out TechnologyDatabaseComponent? database))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out TechnologyDatabaseComponent? database))
|
||||
return;
|
||||
if (!Owner.TryGetComponent(out ResearchClientComponent? client))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ResearchClientComponent? client))
|
||||
return;
|
||||
if (!Powered)
|
||||
return;
|
||||
@@ -90,7 +90,7 @@ namespace Content.Server.Research.Components
|
||||
|
||||
private ResearchConsoleBoundInterfaceState GetNewUiState()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out ResearchClientComponent? client) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ResearchClientComponent? client) ||
|
||||
client.Server == null)
|
||||
return new ResearchConsoleBoundInterfaceState(default, default);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Content.Server.Research.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor))
|
||||
return;
|
||||
if (!Powered)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace Content.Server.Research.Components
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
Owner.TryGetComponent(out _powerReceiver);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out _powerReceiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Research.Prototypes;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -73,7 +74,7 @@ namespace Content.Server.Research.Components
|
||||
Id = ServerCount++;
|
||||
EntitySystem.Get<ResearchSystem>()?.RegisterServer(this);
|
||||
Database = Owner.EnsureComponent<TechnologyDatabaseComponent>();
|
||||
Owner.TryGetComponent(out _powerReceiver);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out _powerReceiver);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.Research.Components;
|
||||
using Content.Shared.Research.Prototypes;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Players;
|
||||
|
||||
namespace Content.Server.Research.Components
|
||||
@@ -41,7 +42,7 @@ namespace Content.Server.Research.Components
|
||||
/// <returns>Whether it could sync or not</returns>
|
||||
public bool SyncWithServer()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out ResearchClientComponent? client)) return false;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ResearchClientComponent? client)) return false;
|
||||
if (client.Server?.Database == null) return false;
|
||||
|
||||
Sync(client.Server.Database);
|
||||
|
||||
Reference in New Issue
Block a user