Inline TryGetComponent completely, for real
This commit is contained in:
@@ -222,12 +222,12 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.User.TryGetComponent(out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent<WiresComponent>(out var wires) && wires.IsPanelOpen)
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<WiresComponent?>(Owner.Uid, out var wires) && wires.IsPanelOpen)
|
||||
{
|
||||
wires.OpenInterface(actor.PlayerSession);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
|
||||
private void UpdateWireStatus()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out WiresComponent? wires))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out WiresComponent? wires))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(ParticleAcceleratorVisuals.VisualState,
|
||||
_apcPowerReceiverComponent!.Powered
|
||||
@@ -683,7 +683,7 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
|
||||
private void UpdatePartVisualState(ParticleAcceleratorPartComponent? component)
|
||||
{
|
||||
if (component == null || !component.Owner.TryGetComponent<AppearanceComponent>(out var appearanceComponent))
|
||||
if (component == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(component.Owner.Uid, out var appearanceComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
{
|
||||
var projectile = IoCManager.Resolve<IEntityManager>().SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates);
|
||||
|
||||
if (!projectile.TryGetComponent<ParticleProjectileComponent>(out var particleProjectileComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ParticleProjectileComponent?>(projectile.Uid, out var particleProjectileComponent))
|
||||
{
|
||||
Logger.Error("ParticleAcceleratorEmitter tried firing particles, but they was spawned without a ParticleProjectileComponent");
|
||||
return;
|
||||
|
||||
@@ -22,21 +22,21 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
{
|
||||
State = state;
|
||||
|
||||
if (!Owner.TryGetComponent<PhysicsComponent>(out var physicsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(Owner.Uid, out var physicsComponent))
|
||||
{
|
||||
Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
|
||||
return;
|
||||
}
|
||||
physicsComponent.BodyStatus = BodyStatus.InAir;
|
||||
|
||||
if (!Owner.TryGetComponent<ProjectileComponent>(out var projectileComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ProjectileComponent?>(Owner.Uid, out var projectileComponent))
|
||||
{
|
||||
Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent");
|
||||
return;
|
||||
}
|
||||
projectileComponent.IgnoreEntity(firer);
|
||||
|
||||
if (!Owner.TryGetComponent<SinguloFoodComponent>(out var singuloFoodComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SinguloFoodComponent?>(Owner.Uid, out var singuloFoodComponent))
|
||||
{
|
||||
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent");
|
||||
return;
|
||||
@@ -61,7 +61,7 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
_ => "0"
|
||||
};
|
||||
|
||||
if (!Owner.TryGetComponent<SpriteComponent>(out var spriteComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(Owner.Uid, out var spriteComponent))
|
||||
{
|
||||
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent");
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.EntitySystems
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace Content.Server.ParticleAccelerator.EntitySystems
|
||||
|
||||
private static void RotateEvent(ref RotateEvent ev)
|
||||
{
|
||||
if (ev.Sender.TryGetComponent(out ParticleAcceleratorPartComponent? part))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(ev.Sender.Uid, out ParticleAcceleratorPartComponent? part))
|
||||
{
|
||||
part.Rotated();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user