Remove many resolves on Content.Server
This commit is contained in:
@@ -10,6 +10,8 @@ namespace Content.Server.Atmos.Components
|
||||
[RegisterComponent]
|
||||
public sealed class AtmosPlaqueComponent : Component, IMapInit
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "AtmosPlaque";
|
||||
|
||||
[DataField("plaqueType")]
|
||||
@@ -55,6 +57,8 @@ namespace Content.Server.Atmos.Components
|
||||
return;
|
||||
}
|
||||
|
||||
var metaData = _entMan.GetComponent<MetaDataComponent>(Owner);
|
||||
|
||||
var val = _type switch
|
||||
{
|
||||
PlaqueType.Zumos =>
|
||||
@@ -68,7 +72,8 @@ namespace Content.Server.Atmos.Components
|
||||
PlaqueType.Unset => "Uhm",
|
||||
_ => "Uhm",
|
||||
};
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityDescription = val;
|
||||
|
||||
metaData.EntityDescription = val;
|
||||
|
||||
var val1 = _type switch
|
||||
{
|
||||
@@ -83,9 +88,10 @@ namespace Content.Server.Atmos.Components
|
||||
PlaqueType.Unset => "Uhm",
|
||||
_ => "Uhm",
|
||||
};
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName = val1;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
metaData.EntityName = val1;
|
||||
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
var state = _type == PlaqueType.Zumos ? "zumosplaque" : "atmosplaque";
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace Content.Server.Atmos.Components
|
||||
public class GasTankComponent : Component, IExamine, IGasMixtureHolder, IUse, IDropped, IActivate
|
||||
#pragma warning restore 618
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "GasTank";
|
||||
|
||||
private const float MaxExplosionRange = 14f;
|
||||
@@ -155,14 +157,14 @@ namespace Content.Server.Atmos.Components
|
||||
|
||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) return false;
|
||||
if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor)) return false;
|
||||
OpenInterface(actor.PlayerSession);
|
||||
return true;
|
||||
}
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor)) return;
|
||||
if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor)) return;
|
||||
OpenInterface(actor.PlayerSession);
|
||||
}
|
||||
|
||||
@@ -230,10 +232,10 @@ namespace Content.Server.Atmos.Components
|
||||
|
||||
private InternalsComponent? GetInternalsComponent(EntityUid? owner = null)
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) return null;
|
||||
if (owner != null) return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<InternalsComponent>(owner.Value);
|
||||
if ((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) return null;
|
||||
if (owner != null) return _entMan.GetComponentOrNull<InternalsComponent>(owner.Value);
|
||||
return Owner.TryGetContainer(out var container)
|
||||
? IoCManager.Resolve<IEntityManager>().GetComponentOrNull<InternalsComponent>(container.Owner)
|
||||
? _entMan.GetComponentOrNull<InternalsComponent>(container.Owner)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -271,7 +273,7 @@ namespace Content.Server.Atmos.Components
|
||||
|
||||
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(Owner, (int) (range * 0.25f), (int) (range * 0.5f), (int) (range * 1.5f), 1);
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner);
|
||||
_entMan.QueueDeleteEntity(Owner);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -279,13 +281,13 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
if (_integrity <= 0)
|
||||
{
|
||||
var environment = atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, true);
|
||||
var environment = atmosphereSystem.GetTileMixture(_entMan.GetComponent<TransformComponent>(Owner).Coordinates, true);
|
||||
if(environment != null)
|
||||
atmosphereSystem.Merge(environment, Air);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _ruptureSound.GetSound(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, AudioHelpers.WithVariation(0.125f));
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _ruptureSound.GetSound(), _entMan.GetComponent<TransformComponent>(Owner).Coordinates, AudioHelpers.WithVariation(0.125f));
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner);
|
||||
_entMan.QueueDeleteEntity(Owner);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -297,7 +299,7 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
if (_integrity <= 0)
|
||||
{
|
||||
var environment = atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, true);
|
||||
var environment = atmosphereSystem.GetTileMixture(_entMan.GetComponent<TransformComponent>(Owner).Coordinates, true);
|
||||
if (environment == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Content.Server.Atmos.Components
|
||||
public class MovedByPressureComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "MovedByPressure";
|
||||
|
||||
@@ -42,12 +43,12 @@ namespace Content.Server.Atmos.Components
|
||||
public void ExperiencePressureDifference(int cycle, float pressureDifference, AtmosDirection direction,
|
||||
float pressureResistanceProbDelta, EntityCoordinates throwTarget)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PhysicsComponent? physics))
|
||||
if (!_entMan.TryGetComponent(Owner, out PhysicsComponent? physics))
|
||||
return;
|
||||
|
||||
// TODO ATMOS stuns?
|
||||
|
||||
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(physics.Owner);
|
||||
var transform = _entMan.GetComponent<TransformComponent>(physics.Owner);
|
||||
var maxForce = MathF.Sqrt(pressureDifference) * 2.25f;
|
||||
var moveProb = 100f;
|
||||
|
||||
@@ -61,7 +62,7 @@ namespace Content.Server.Atmos.Components
|
||||
&& (maxForce >= (MoveResist * MoveForcePushRatio)))
|
||||
|| (physics.BodyType == BodyType.Static && (maxForce >= (MoveResist * MoveForceForcePushRatio))))
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(physics.Owner))
|
||||
if (_entMan.HasComponent<MobStateComponent>(physics.Owner))
|
||||
{
|
||||
physics.BodyStatus = BodyStatus.InAir;
|
||||
|
||||
@@ -72,10 +73,10 @@ namespace Content.Server.Atmos.Components
|
||||
|
||||
Owner.SpawnTimer(2000, () =>
|
||||
{
|
||||
if (Deleted || !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PhysicsComponent? physicsComponent)) return;
|
||||
if (Deleted || !_entMan.TryGetComponent(Owner, out PhysicsComponent? physicsComponent)) return;
|
||||
|
||||
// Uhh if you get race conditions good luck buddy.
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(physicsComponent.Owner))
|
||||
if (_entMan.HasComponent<MobStateComponent>(physicsComponent.Owner))
|
||||
{
|
||||
physicsComponent.BodyStatus = BodyStatus.OnGround;
|
||||
}
|
||||
@@ -118,7 +119,7 @@ namespace Content.Server.Atmos.Components
|
||||
|
||||
public static bool IsMovedByPressure(this EntityUid entity, [NotNullWhen(true)] out MovedByPressureComponent? moved)
|
||||
{
|
||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out moved) &&
|
||||
return _entMan.TryGetComponent(entity, out moved) &&
|
||||
moved.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user