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);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Singularity.Components;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.Server.Singularity.EntitySystems
|
||||
@@ -21,7 +22,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
|
||||
private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, StartCollideEvent args)
|
||||
{
|
||||
if (args.OtherFixture.Body.Owner.TryGetComponent<SingularityGeneratorComponent>(out var singularityGeneratorComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SingularityGeneratorComponent?>(args.OtherFixture.Body.Owner.Uid, out var singularityGeneratorComponent))
|
||||
{
|
||||
singularityGeneratorComponent.Power += component.State switch
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.Owner.TryGetComponent(out PhysicsComponent? phys) && phys.BodyType == BodyType.Static)
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out PhysicsComponent? phys) && phys.BodyType == BodyType.Static)
|
||||
{
|
||||
if (!component.IsOn)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
{
|
||||
var projectile = IoCManager.Resolve<IEntityManager>().SpawnEntity(component.BoltType, component.Owner.Transform.Coordinates);
|
||||
|
||||
if (!projectile.TryGetComponent<PhysicsComponent>(out var physicsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(projectile.Uid, out var physicsComponent))
|
||||
{
|
||||
Logger.Error("Emitter tried firing a bolt, but it was spawned without a PhysicsComponent");
|
||||
return;
|
||||
@@ -176,7 +176,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
|
||||
physicsComponent.BodyStatus = BodyStatus.InAir;
|
||||
|
||||
if (!projectile.TryGetComponent<ProjectileComponent>(out var projectileComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ProjectileComponent?>(projectile.Uid, out var projectileComponent))
|
||||
{
|
||||
Logger.Error("Emitter tried firing a bolt, but it was spawned without a ProjectileComponent");
|
||||
return;
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
if (CanDestroy(component, entity)) return;
|
||||
|
||||
// Singularity priority management / etc.
|
||||
if (entity.TryGetComponent<ServerSingularityComponent>(out var otherSingulo))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ServerSingularityComponent?>(entity.Uid, out var otherSingulo))
|
||||
{
|
||||
// MERGE
|
||||
if (!otherSingulo.BeingDeletedByAnotherSingularity)
|
||||
@@ -127,7 +127,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(entity.Uid);
|
||||
|
||||
if (entity.TryGetComponent<SinguloFoodComponent>(out var singuloFood))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SinguloFoodComponent?>(entity.Uid, out var singuloFood))
|
||||
component.Energy += singuloFood.Energy;
|
||||
else
|
||||
component.Energy++;
|
||||
@@ -166,7 +166,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
{
|
||||
// I tried having it so level 6 can de-anchor. BAD IDEA, MASSIVE LAG.
|
||||
if (entity == component.Owner ||
|
||||
!entity.TryGetComponent<PhysicsComponent>(out var collidableComponent) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(entity.Uid, out var collidableComponent) ||
|
||||
collidableComponent.BodyType == BodyType.Static) continue;
|
||||
|
||||
if (!CanPull(entity)) continue;
|
||||
|
||||
Reference in New Issue
Block a user