Inline TryGetComponent completely, for real
This commit is contained in:
@@ -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