Inline TryGetComponent completely, for real
This commit is contained in:
@@ -54,7 +54,7 @@ namespace Content.Server.Singularity.Components
|
||||
{
|
||||
var currentCoords = pos1.Offset(currentOffset);
|
||||
var newEnt = entityManager.SpawnEntity("ContainmentField", currentCoords);
|
||||
if (!newEnt.TryGetComponent<ContainmentFieldComponent>(out var containmentFieldComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainmentFieldComponent?>(newEnt.Uid, out var containmentFieldComponent))
|
||||
{
|
||||
Logger.Error("While creating Fields in ContainmentFieldConnection, a ContainmentField without a ContainmentFieldComponent was created. Deleting newly spawned ContainmentField...");
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(newEnt.Uid);
|
||||
@@ -75,7 +75,7 @@ namespace Content.Server.Singularity.Components
|
||||
public bool CanRepell(IEntity toRepell)
|
||||
{
|
||||
var powerNeeded = 1;
|
||||
if (toRepell.TryGetComponent<ServerSingularityComponent>(out var singularityComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ServerSingularityComponent?>(toRepell.Uid, out var singularityComponent))
|
||||
{
|
||||
powerNeeded += 2*singularityComponent.Level;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Physics;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
@@ -113,11 +114,11 @@ namespace Content.Server.Singularity.Components
|
||||
}
|
||||
if(closestResult == null) continue;
|
||||
var ent = closestResult.Value.HitEntity;
|
||||
if (!ent.TryGetComponent<ContainmentFieldGeneratorComponent>(out var fieldGeneratorComponent) ||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainmentFieldGeneratorComponent?>(ent.Uid, out var fieldGeneratorComponent) ||
|
||||
fieldGeneratorComponent.Owner == Owner ||
|
||||
!fieldGeneratorComponent.HasFreeConnections() ||
|
||||
IsConnectedWith(fieldGeneratorComponent) ||
|
||||
!ent.TryGetComponent<PhysicsComponent>(out var collidableComponent) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(ent.Uid, out var collidableComponent) ||
|
||||
collidableComponent.BodyType != BodyType.Static)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Content.Server.Singularity.Components
|
||||
|
||||
protected void SetAppearance(RadiationCollectorVisualState state)
|
||||
{
|
||||
if (Owner.TryGetComponent<AppearanceComponent>(out var appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(Owner.Uid, out var appearance))
|
||||
{
|
||||
appearance.SetData(RadiationCollectorVisuals.VisualState, state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user