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

@@ -17,6 +17,8 @@ namespace Content.Server.Singularity.Components
[ComponentReference(typeof(SharedContainmentFieldGeneratorComponent))]
public class ContainmentFieldGeneratorComponent : SharedContainmentFieldGeneratorComponent
{
[Dependency] private readonly IEntityManager _entMan = default!;
private int _powerBuffer;
[ViewVariables]
@@ -95,9 +97,9 @@ namespace Content.Server.Singularity.Components
{
if (_connection1?.Item1 == direction || _connection2?.Item1 == direction) continue;
var dirVec = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldRotation.RotateVec(direction.ToVec());
var ray = new CollisionRay(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldPosition, dirVec, (int) CollisionGroup.MobMask);
var rawRayCastResults = EntitySystem.Get<SharedPhysicsSystem>().IntersectRay(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapID, ray, 4.5f, Owner, false);
var dirVec = _entMan.GetComponent<TransformComponent>(Owner).WorldRotation.RotateVec(direction.ToVec());
var ray = new CollisionRay(_entMan.GetComponent<TransformComponent>(Owner).WorldPosition, dirVec, (int) CollisionGroup.MobMask);
var rawRayCastResults = EntitySystem.Get<SharedPhysicsSystem>().IntersectRay(_entMan.GetComponent<TransformComponent>(Owner).MapID, ray, 4.5f, Owner, false);
var rayCastResults = rawRayCastResults as RayCastResults[] ?? rawRayCastResults.ToArray();
if(!rayCastResults.Any()) continue;
@@ -113,11 +115,11 @@ namespace Content.Server.Singularity.Components
}
if(closestResult == null) continue;
var ent = closestResult.Value.HitEntity;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainmentFieldGeneratorComponent?>(ent, out var fieldGeneratorComponent) ||
if (!_entMan.TryGetComponent<ContainmentFieldGeneratorComponent?>(ent, out var fieldGeneratorComponent) ||
fieldGeneratorComponent.Owner == Owner ||
!fieldGeneratorComponent.HasFreeConnections() ||
IsConnectedWith(fieldGeneratorComponent) ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(ent, out var collidableComponent) ||
!_entMan.TryGetComponent<PhysicsComponent?>(ent, out var collidableComponent) ||
collidableComponent.BodyType != BodyType.Static)
{
continue;

View File

@@ -14,6 +14,8 @@ namespace Content.Server.Singularity.Components
[ComponentReference(typeof(SharedSingularityComponent))]
public class ServerSingularityComponent : SharedSingularityComponent
{
[Dependency] private readonly IEntityManager _entMan = default!;
private SharedSingularitySystem _singularitySystem = default!;
[ViewVariables(VVAccess.ReadWrite)]
@@ -27,7 +29,7 @@ namespace Content.Server.Singularity.Components
_energy = value;
if (_energy <= 0)
{
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner);
_entMan.DeleteEntity(Owner);
return;
}
@@ -92,7 +94,7 @@ namespace Content.Server.Singularity.Components
protected override void Shutdown()
{
base.Shutdown();
SoundSystem.Play(Filter.Pvs(Owner), _singularityCollapsingSound.GetSound(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
SoundSystem.Play(Filter.Pvs(Owner), _singularityCollapsingSound.GetSound(), _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
}
}
}

View File

@@ -7,6 +7,8 @@ namespace Content.Server.Singularity.Components
[RegisterComponent]
public class SingularityGeneratorComponent : Component
{
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "SingularityGenerator";
[ViewVariables] private int _power;
@@ -21,8 +23,7 @@ namespace Content.Server.Singularity.Components
_power = value;
if (_power > 15)
{
var entityManager = IoCManager.Resolve<IEntityManager>();
entityManager.SpawnEntity("Singularity", IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
_entMan.SpawnEntity("Singularity", _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
//dont delete ourselves, just wait to get eaten
}
}