Inline TryGetComponent completely, for real
This commit is contained in:
@@ -71,7 +71,7 @@ namespace Content.Shared.Pulling.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent<SharedPullerComponent>(out var comp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullerComponent?>(entity.Uid, out var comp))
|
||||
{
|
||||
Logger.Error($"Entity {state.Puller.Value} for pulling had no Puller component");
|
||||
// ensure it disconnects from any different puller, still
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Shared.Pulling.Systems
|
||||
if (args.Puller.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ShowAlert(AlertType.Pulling);
|
||||
|
||||
RefreshMovementSpeed(component);
|
||||
@@ -62,7 +62,7 @@ namespace Content.Shared.Pulling.Systems
|
||||
if (args.Puller.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ClearAlert(AlertType.Pulling);
|
||||
|
||||
RefreshMovementSpeed(component);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Content.Shared.Pulling
|
||||
ForceSetMovingTo(pullable, null);
|
||||
|
||||
// Joint shutdown
|
||||
if (puller.Owner.TryGetComponent<JointComponent>(out var jointComp))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<JointComponent?>(puller.Owner.Uid, out var jointComp))
|
||||
{
|
||||
if (jointComp.GetJoints.Contains(pullable.PullJoint!))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pulled.TryGetComponent<IPhysBody>(out var _physics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<IPhysBody?>(pulled.Uid, out var _physics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (puller.TryGetComponent<SharedBuckleComponent>(out var buckle))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBuckleComponent?>(puller.Uid, out var buckle))
|
||||
{
|
||||
// Prevent people pulling the chair they're on, etc.
|
||||
if (buckle.Buckled && (buckle.LastEntityBuckledTo == pulled.Uid))
|
||||
@@ -102,11 +102,11 @@ namespace Content.Shared.Pulling
|
||||
|
||||
public bool TryStartPull(IEntity puller, IEntity pullable)
|
||||
{
|
||||
if (!puller.TryGetComponent<SharedPullerComponent>(out var pullerComp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullerComponent?>(puller.Uid, out var pullerComp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!pullable.TryGetComponent<SharedPullableComponent>(out var pullableComp))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullableComponent?>(pullable.Uid, out var pullableComp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -126,12 +126,12 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!puller.Owner.TryGetComponent<PhysicsComponent>(out var pullerPhysics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(puller.Owner.Uid, out var pullerPhysics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pullable.Owner.TryGetComponent<PhysicsComponent>(out var pullablePhysics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(pullable.Owner.Uid, out var pullablePhysics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Content.Shared.Pulling
|
||||
var oldPullable = puller.Pulling;
|
||||
if (oldPullable != null)
|
||||
{
|
||||
if (oldPullable.TryGetComponent<SharedPullableComponent>(out var oldPullableComp))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedPullableComponent?>(oldPullable.Uid, out var oldPullableComp))
|
||||
{
|
||||
if (!TryStopPull(oldPullableComp))
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Content.Shared.Pulling
|
||||
if (args.Pulled.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ShowAlert(AlertType.Pulled);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Content.Shared.Pulling
|
||||
if (args.Pulled.OwnerUid != uid)
|
||||
return;
|
||||
|
||||
if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts))
|
||||
alerts.ClearAlert(AlertType.Pulled);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Content.Shared.Pulling
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pulled.TryGetComponent(out IPhysBody? physics))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulled.Uid, out IPhysBody? physics))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -183,16 +183,16 @@ namespace Content.Shared.Pulling
|
||||
// TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message.
|
||||
private void HandleContainerInsert(EntInsertedIntoContainerMessage message)
|
||||
{
|
||||
if (message.Entity.TryGetComponent(out SharedPullableComponent? pullable))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(message.Entity.Uid, out SharedPullableComponent? pullable))
|
||||
{
|
||||
TryStopPull(pullable);
|
||||
}
|
||||
|
||||
if (message.Entity.TryGetComponent(out SharedPullerComponent? puller))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(message.Entity.Uid, out SharedPullerComponent? puller))
|
||||
{
|
||||
if (puller.Pulling == null) return;
|
||||
|
||||
if (!puller.Pulling.TryGetComponent(out SharedPullableComponent? pulling))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(puller.Pulling.Uid, out SharedPullableComponent? pulling))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pulled.TryGetComponent(out SharedPullableComponent? pullable))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulled.Uid, out SharedPullableComponent? pullable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ namespace Content.Shared.Pulling
|
||||
private void UpdatePulledRotation(IEntity puller, IEntity pulled)
|
||||
{
|
||||
// TODO: update once ComponentReference works with directed event bus.
|
||||
if (!pulled.TryGetComponent(out RotatableComponent? rotatable))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulled.Uid, out RotatableComponent? rotatable))
|
||||
return;
|
||||
|
||||
if (!rotatable.RotateWhilePulling)
|
||||
|
||||
Reference in New Issue
Block a user