Inline GetComponentOrNull

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 15:32:05 +01:00
parent ee4ff9cfe8
commit 2654775bf0
30 changed files with 55 additions and 32 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared.Instruments;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Content.Server.Instruments;
@@ -23,8 +24,8 @@ public sealed class InstrumentComponent : SharedInstrumentComponent
public int MidiEventCount = 0;
public IPlayerSession? InstrumentPlayer =>
Owner.GetComponentOrNull<ActivatableUIComponent>()?.CurrentSingleUser
?? Owner.GetComponentOrNull<ActorComponent>()?.PlayerSession;
IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ActivatableUIComponent>(Owner.Uid)?.CurrentSingleUser
?? IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ActorComponent>(Owner.Uid)?.PlayerSession;
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(InstrumentUiKey.Key);
}