Inline TryGetComponent completely, for real
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
|
||||
[ViewVariables]
|
||||
public bool Anchored =>
|
||||
!Owner.TryGetComponent(out IPhysBody? physics) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out IPhysBody? physics) ||
|
||||
physics.BodyType == BodyType.Static;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key);
|
||||
@@ -160,12 +160,12 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
/// <param name="args">Data relevant to the event such as the actor which triggered it.</param>
|
||||
void IActivate.Activate(ActivateEventArgs args)
|
||||
{
|
||||
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.User.TryGetComponent(out HandsComponent? hands))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out HandsComponent? hands))
|
||||
{
|
||||
Owner.PopupMessage(args.User, Loc.GetString("disposal-router-window-tag-input-activate-no-hands"));
|
||||
return;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
|
||||
[ViewVariables]
|
||||
public bool Anchored =>
|
||||
!Owner.TryGetComponent(out PhysicsComponent? physics) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PhysicsComponent? physics) ||
|
||||
physics.BodyType == BodyType.Static;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalTaggerUiKey.Key);
|
||||
@@ -126,12 +126,12 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
/// <param name="args">Data relevant to the event such as the actor which triggered it.</param>
|
||||
void IActivate.Activate(ActivateEventArgs args)
|
||||
{
|
||||
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.User.TryGetComponent(out HandsComponent? hands))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out HandsComponent? hands))
|
||||
{
|
||||
Owner.PopupMessage(args.User, Loc.GetString("disposal-tagger-window-activate-no-hands"));
|
||||
return;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
|
||||
[ViewVariables]
|
||||
private bool Anchored =>
|
||||
!Owner.TryGetComponent(out PhysicsComponent? physics) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PhysicsComponent? physics) ||
|
||||
physics.BodyType == BodyType.Static;
|
||||
|
||||
/// <summary>
|
||||
@@ -91,7 +91,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
|
||||
foreach (var entity in Contents.ContainedEntities.ToArray())
|
||||
{
|
||||
if (!entity.TryGetComponent(out DisposalHolderComponent? holder))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out DisposalHolderComponent? holder))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
|
||||
private void UpdateVisualState()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
|
||||
public void AnchoredChanged()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out PhysicsComponent? physics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PhysicsComponent? physics))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Content.Server.Disposal
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out IDisposalTubeComponent? tube))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IDisposalTubeComponent? tube))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("shell-entity-with-uid-lacks-component",
|
||||
("uid", id),
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out IPhysBody? physics))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics))
|
||||
{
|
||||
physics.CanCollide = false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -74,7 +75,7 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
|
||||
[ViewVariables]
|
||||
public bool Powered =>
|
||||
!Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) ||
|
||||
receiver.Powered;
|
||||
|
||||
[ViewVariables] public PressureState State => Pressure >= 1 ? PressureState.Ready : PressureState.Pressurizing;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
foreach (var entity in holder.Container.ContainedEntities.ToArray())
|
||||
{
|
||||
if (entity.TryGetComponent(out IPhysBody? physics))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics))
|
||||
{
|
||||
physics.CanCollide = true;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
#region Eventbus Handlers
|
||||
private void HandleActivate(EntityUid uid, DisposalUnitComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
private void HandleInteractHand(EntityUid uid, DisposalUnitComponent component, InteractHandEvent args)
|
||||
{
|
||||
if (!args.User.TryGetComponent(out ActorComponent? actor)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return;
|
||||
|
||||
// Duplicated code here, not sure how else to get actor inside to make UserInterface happy.
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
private void HandleInteractUsing(EntityUid uid, DisposalUnitComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if (!args.User.TryGetComponent(out HandsComponent? hands))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out HandsComponent? hands))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
{
|
||||
var currentTime = GameTiming.CurTime;
|
||||
|
||||
if (!args.Entity.TryGetComponent(out HandsComponent? hands) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Entity.Uid, out HandsComponent? hands) ||
|
||||
hands.Count == 0 ||
|
||||
currentTime < component.LastExitAttempt + ExitAttemptDelay)
|
||||
{
|
||||
@@ -351,7 +351,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
if (!component.Owner.TryGetComponent(out PhysicsComponent? disposalsBody))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out PhysicsComponent? disposalsBody))
|
||||
{
|
||||
component.RecentlyEjected.Clear();
|
||||
}
|
||||
@@ -504,7 +504,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
public void UpdateVisualState(DisposalUnitComponent component, bool flush)
|
||||
{
|
||||
if (!component.Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -633,7 +633,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
{
|
||||
TryQueueEngage(component);
|
||||
|
||||
if (entity.TryGetComponent(out ActorComponent? actor))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ActorComponent? actor))
|
||||
{
|
||||
component.UserInterface?.Close(actor.PlayerSession);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user