Remove many resolves on Content.Server
This commit is contained in:
@@ -16,6 +16,8 @@ namespace Content.Server.Chemistry.Components
|
||||
[ComponentReference(typeof(SolutionAreaEffectComponent))]
|
||||
public class FoamSolutionAreaEffectComponent : SolutionAreaEffectComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "FoamSolutionAreaEffect";
|
||||
public new const string SolutionName = "solutionArea";
|
||||
|
||||
@@ -23,7 +25,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
protected override void UpdateVisuals()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance) &&
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance) &&
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
{
|
||||
appearance.SetData(FoamVisuals.Color, solution.Color.WithAlpha(0.80f));
|
||||
@@ -35,13 +37,13 @@ namespace Content.Server.Chemistry.Components
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
return;
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out BloodstreamComponent? bloodstream))
|
||||
if (!_entMan.TryGetComponent(entity, out BloodstreamComponent? bloodstream))
|
||||
return;
|
||||
|
||||
// TODO: Add a permeability property to clothing
|
||||
// For now it just adds to protection for each clothing equipped
|
||||
var protection = 0f;
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out InventoryComponent? inventory))
|
||||
if (_entMan.TryGetComponent(entity, out InventoryComponent? inventory))
|
||||
{
|
||||
foreach (var slot in inventory.Slots)
|
||||
{
|
||||
@@ -68,9 +70,9 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
protected override void OnKill()
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
if ((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
return;
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(FoamVisuals.State, true);
|
||||
}
|
||||
@@ -79,10 +81,10 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_foamedMetalPrototype))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(_foamedMetalPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
_entMan.SpawnEntity(_foamedMetalPrototype, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner);
|
||||
_entMan.QueueDeleteEntity(Owner);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace Content.Server.Chemistry.Components
|
||||
[RegisterComponent]
|
||||
public sealed class HyposprayComponent : SharedHyposprayComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
[DataField("clumsyFailChance")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ClumsyFailChance { get; set; } = 0.5f;
|
||||
@@ -80,7 +82,7 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
target.Value.PopupMessage(Loc.GetString("hypospray-component-feel-prick-message"));
|
||||
var meleeSys = EntitySystem.Get<MeleeWeaponSystem>();
|
||||
var angle = Angle.FromWorldVec(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(target.Value).WorldPosition - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).WorldPosition);
|
||||
var angle = Angle.FromWorldVec(_entMan.GetComponent<TransformComponent>(target.Value).WorldPosition - _entMan.GetComponent<TransformComponent>(user).WorldPosition);
|
||||
meleeSys.SendLunge(angle, user);
|
||||
}
|
||||
|
||||
@@ -116,8 +118,8 @@ namespace Content.Server.Chemistry.Components
|
||||
// TODO: Does checking for BodyComponent make sense as a "can be hypospray'd" tag?
|
||||
// In SS13 the hypospray ONLY works on mobs, NOT beakers or anything else.
|
||||
|
||||
return IoCManager.Resolve<IEntityManager>().HasComponent<SolutionContainerManagerComponent>(entity)
|
||||
&& IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(entity);
|
||||
return _entMan.HasComponent<SolutionContainerManagerComponent>(entity)
|
||||
&& _entMan.HasComponent<MobStateComponent>(entity);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -125,7 +127,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
var solutionSys = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
|
||||
var solutionSys = _entMan.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
|
||||
return solutionSys.TryGetSolution(Owner, SolutionName, out var solution)
|
||||
? new HyposprayComponentState(solution.CurrentVolume, solution.MaxVolume)
|
||||
: new HyposprayComponentState(FixedPoint2.Zero, FixedPoint2.Zero);
|
||||
|
||||
@@ -14,12 +14,14 @@ namespace Content.Server.Chemistry.Components
|
||||
[ComponentReference(typeof(SolutionAreaEffectComponent))]
|
||||
public class SmokeSolutionAreaEffectComponent : SolutionAreaEffectComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "SmokeSolutionAreaEffect";
|
||||
public new const string SolutionName = "solutionArea";
|
||||
|
||||
protected override void UpdateVisuals()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance) &&
|
||||
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance) &&
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
{
|
||||
appearance.SetData(SmokeVisuals.Color, solution.Color);
|
||||
@@ -31,10 +33,10 @@ namespace Content.Server.Chemistry.Components
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
return;
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out BloodstreamComponent? bloodstream))
|
||||
if (!_entMan.TryGetComponent(entity, out BloodstreamComponent? bloodstream))
|
||||
return;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out InternalsComponent? internals) &&
|
||||
if (_entMan.TryGetComponent(entity, out InternalsComponent? internals) &&
|
||||
internals.AreInternalsWorking())
|
||||
return;
|
||||
|
||||
@@ -56,9 +58,9 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
protected override void OnKill()
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
if ((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
return;
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner);
|
||||
_entMan.DeleteEntity(Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Content.Server.Chemistry.Components
|
||||
[RegisterComponent]
|
||||
public class TransformableContainerComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "TransformableContainer";
|
||||
|
||||
public SpriteSpecifier? InitialSprite;
|
||||
@@ -23,14 +25,14 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SpriteComponent? sprite) &&
|
||||
if (_entMan.TryGetComponent(Owner, out SpriteComponent? sprite) &&
|
||||
sprite.BaseRSIPath != null)
|
||||
{
|
||||
InitialSprite = new SpriteSpecifier.Rsi(new ResourcePath(sprite.BaseRSIPath), "icon");
|
||||
}
|
||||
|
||||
InitialName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName;
|
||||
InitialDescription = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityDescription;
|
||||
InitialName = _entMan.GetComponent<MetaDataComponent>(Owner).EntityName;
|
||||
InitialDescription = _entMan.GetComponent<MetaDataComponent>(Owner).EntityDescription;
|
||||
}
|
||||
|
||||
protected override void Startup()
|
||||
|
||||
Reference in New Issue
Block a user