Inline TryGetComponent completely, for real

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:17:01 +01:00
parent 2ff4ec65d5
commit 69b270017b
425 changed files with 1143 additions and 995 deletions

View File

@@ -154,7 +154,7 @@ namespace Content.Server.Buckle.Components
return false;
}
if (!to.TryGetComponent(out strap))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(to.Uid, out strap))
{
return false;
}
@@ -255,7 +255,7 @@ namespace Content.Server.Buckle.Components
SendMessage(new BuckleMessage(Owner, to));
#pragma warning restore 618
if (Owner.TryGetComponent(out SharedPullableComponent? ownerPullable))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SharedPullableComponent? ownerPullable))
{
if (ownerPullable.Puller != null)
{
@@ -263,7 +263,7 @@ namespace Content.Server.Buckle.Components
}
}
if (to.TryGetComponent(out SharedPullableComponent? toPullable))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(to.Uid, out SharedPullableComponent? toPullable))
{
if (toPullable.Puller == Owner)
{

View File

@@ -9,6 +9,7 @@ using Content.Shared.Interaction;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -148,7 +149,7 @@ namespace Content.Server.Buckle.Components
{
foreach (var entity in _buckledEntities.ToArray())
{
if (entity.TryGetComponent<BuckleComponent>(out var buckle))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<BuckleComponent?>(entity.Uid, out var buckle))
{
buckle.TryUnbuckle(entity, true);
}
@@ -165,7 +166,7 @@ namespace Content.Server.Buckle.Components
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
{
if (!eventArgs.User.TryGetComponent<BuckleComponent>(out var buckle))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<BuckleComponent?>(eventArgs.User.Uid, out var buckle))
{
return false;
}
@@ -175,7 +176,7 @@ namespace Content.Server.Buckle.Components
public override bool DragDropOn(DragDropEvent eventArgs)
{
if (!eventArgs.Dragged.TryGetComponent(out BuckleComponent? buckleComponent)) return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Dragged.Uid, out BuckleComponent? buckleComponent)) return false;
return buckleComponent.TryBuckle(eventArgs.User, Owner);
}
}

View File

@@ -61,7 +61,7 @@ namespace Content.Server.Buckle.Systems
}
// Add a verb to buckle the user.
if (args.User.TryGetComponent<BuckleComponent>(out var buckle) &&
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<BuckleComponent?>(args.User.Uid, out var buckle) &&
buckle.BuckledTo != component &&
args.User != component.Owner &&
component.HasSpace(buckle) &&
@@ -76,7 +76,7 @@ namespace Content.Server.Buckle.Systems
// If the user is currently holding/pulling an entity that can be buckled, add a verb for that.
if (args.Using != null &&
args.Using.TryGetComponent<BuckleComponent>(out var usingBuckle) &&
IoCManager.Resolve<IEntityManager>().TryGetComponent<BuckleComponent?>(args.Using.Uid, out var usingBuckle) &&
component.HasSpace(usingBuckle) &&
_interactionSystem.InRangeUnobstructed(args.Using, args.Target, range: usingBuckle.Range))
{