Even more resolve removals.

This commit is contained in:
Vera Aguilera Puerto
2021-12-08 17:32:32 +01:00
parent 684cb76173
commit cdc8336695
61 changed files with 364 additions and 278 deletions

View File

@@ -36,6 +36,7 @@ namespace Content.Server.ParticleAccelerator.Components
[RegisterComponent]
public class ParticleAcceleratorControlBoxComponent : ParticleAcceleratorPartComponent, IActivate, IWires
{
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
public override string Name => "ParticleAcceleratorControlBox";
@@ -221,12 +222,12 @@ namespace Content.Server.ParticleAccelerator.Components
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor))
if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
{
return;
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<WiresComponent?>(Owner, out var wires) && wires.IsPanelOpen)
if (_entMan.TryGetComponent<WiresComponent?>(Owner, out var wires) && wires.IsPanelOpen)
{
wires.OpenInterface(actor.PlayerSession);
}
@@ -333,7 +334,7 @@ namespace Content.Server.ParticleAccelerator.Components
private void UpdateWireStatus()
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out WiresComponent? wires))
if (!_entMan.TryGetComponent(Owner, out WiresComponent? wires))
{
return;
}
@@ -383,13 +384,13 @@ namespace Content.Server.ParticleAccelerator.Components
_partEmitterRight = null;
// Find fuel chamber first by scanning cardinals.
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Anchored)
if (_entMan.GetComponent<TransformComponent>(Owner).Anchored)
{
var grid = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID);
var coords = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
var grid = _mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridID);
var coords = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
foreach (var maybeFuel in grid.GetCardinalNeighborCells(coords))
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(maybeFuel, out _partFuelChamber))
if (_entMan.TryGetComponent(maybeFuel, out _partFuelChamber))
{
break;
}
@@ -405,7 +406,7 @@ namespace Content.Server.ParticleAccelerator.Components
// Align ourselves to match fuel chamber orientation.
// This means that if you mess up the orientation of the control box it's not a big deal,
// because the sprite is far from obvious about the orientation.
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_partFuelChamber.Owner).LocalRotation;
_entMan.GetComponent<TransformComponent>(Owner).LocalRotation = _entMan.GetComponent<TransformComponent>(_partFuelChamber.Owner).LocalRotation;
var offsetEndCap = RotateOffset((1, 1));
var offsetPowerBox = RotateOffset((1, -1));
@@ -451,7 +452,7 @@ namespace Content.Server.ParticleAccelerator.Components
Vector2i RotateOffset(in Vector2i vec)
{
var rot = new Angle(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation);
var rot = new Angle(_entMan.GetComponent<TransformComponent>(Owner).LocalRotation);
return (Vector2i) rot.RotateVec(vec);
}
}
@@ -459,11 +460,11 @@ namespace Content.Server.ParticleAccelerator.Components
private bool ScanPart<T>(Vector2i offset, [NotNullWhen(true)] out T? part)
where T : ParticleAcceleratorPartComponent
{
var grid = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID);
var coords = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
var grid = _mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridID);
var coords = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
foreach (var ent in grid.GetOffset(coords, offset))
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(ent, out part) && !part.Deleted)
if (_entMan.TryGetComponent(ent, out part) && !part.Deleted)
{
return true;
}
@@ -576,7 +577,7 @@ namespace Content.Server.ParticleAccelerator.Components
private void UpdateAppearance()
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{
appearance.SetData(ParticleAcceleratorVisuals.VisualState,
_apcPowerReceiverComponent!.Powered
@@ -682,7 +683,7 @@ namespace Content.Server.ParticleAccelerator.Components
private void UpdatePartVisualState(ParticleAcceleratorPartComponent? component)
{
if (component == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(component.Owner, out var appearanceComponent))
if (component == null || !_entMan.TryGetComponent<AppearanceComponent?>(component.Owner, out var appearanceComponent))
{
return;
}

View File

@@ -13,6 +13,8 @@ namespace Content.Server.ParticleAccelerator.Components
[RegisterComponent]
public class ParticleProjectileComponent : Component
{
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "ParticleProjectile";
public ParticleAcceleratorPowerState State;
@@ -20,21 +22,21 @@ namespace Content.Server.ParticleAccelerator.Components
{
State = state;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(Owner, out var physicsComponent))
if (!_entMan.TryGetComponent<PhysicsComponent?>(Owner, out var physicsComponent))
{
Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
return;
}
physicsComponent.BodyStatus = BodyStatus.InAir;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ProjectileComponent?>(Owner, out var projectileComponent))
if (!_entMan.TryGetComponent<ProjectileComponent?>(Owner, out var projectileComponent))
{
Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent");
return;
}
projectileComponent.IgnoreEntity(firer);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SinguloFoodComponent?>(Owner, out var singuloFoodComponent))
if (!_entMan.TryGetComponent<SinguloFoodComponent?>(Owner, out var singuloFoodComponent))
{
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent");
return;
@@ -59,7 +61,7 @@ namespace Content.Server.ParticleAccelerator.Components
_ => "0"
};
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(Owner, out var spriteComponent))
if (!_entMan.TryGetComponent<SpriteComponent?>(Owner, out var spriteComponent))
{
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent");
return;
@@ -69,8 +71,8 @@ namespace Content.Server.ParticleAccelerator.Components
physicsComponent
.LinearVelocity = angle.ToWorldVec() * 20f;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation = angle;
Timer.Spawn(3000, () => IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner));
_entMan.GetComponent<TransformComponent>(Owner).LocalRotation = angle;
Timer.Spawn(3000, () => _entMan.DeleteEntity(Owner));
}
}
}