Inline TryGetComponent completely

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:05:23 +01:00
parent f3edecf994
commit 2ff4ec65d5
34 changed files with 98 additions and 84 deletions

View File

@@ -23,8 +23,8 @@ namespace Content.Server.Actions.Actions
public void DoInstantAction(InstantActionEventArgs args)
{
if (!args.Performer.TryGetComponent<ServerUserInterfaceComponent>(out var serverUi)) return;
if (!args.Performer.TryGetComponent<ActorComponent>(out var actor)) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ServerUserInterfaceComponent?>(args.Performer.Uid, out var serverUi)) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(args.Performer.Uid, out var actor)) return;
if (!serverUi.TryGetBoundUserInterface(InstrumentUiKey.Key,out var bui)) return;
bui.Toggle(actor.PlayerSession);

View File

@@ -5,6 +5,7 @@ using Content.Shared.Actions;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
@@ -29,7 +30,7 @@ namespace Content.Server.Actions.Commands
}
if (attachedEntity == null) return;
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Uid, out ServerActionsComponent? actionsComponent))
{
shell.WriteLine("user has no actions component");
return;