Remove useless resolves from a buncha tests.
This commit is contained in:
@@ -163,7 +163,7 @@ namespace Content.Client.Preferences.UI
|
||||
|
||||
var view = new SpriteView
|
||||
{
|
||||
Sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(_previewDummy),
|
||||
Sprite = entityManager.GetComponent<SpriteComponent>(_previewDummy),
|
||||
Scale = (2, 2),
|
||||
OverrideDirection = Direction.South
|
||||
};
|
||||
|
||||
@@ -21,8 +21,9 @@ namespace Content.Client.Recycling
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ISpriteComponent? sprite) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out AppearanceComponent? appearance))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetComponent(entity, out ISpriteComponent? sprite) ||
|
||||
!entMan.TryGetComponent(entity, out AppearanceComponent? appearance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,10 @@ namespace Content.Client.Rotation
|
||||
|
||||
private void SetRotation(AppearanceComponent component, Angle rotation)
|
||||
{
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var sprite = entMan.GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(sprite.Owner, out AnimationPlayerComponent? animation))
|
||||
if (!entMan.TryGetComponent(sprite.Owner, out AnimationPlayerComponent? animation))
|
||||
{
|
||||
sprite.Rotation = rotation;
|
||||
return;
|
||||
|
||||
@@ -46,10 +46,7 @@ namespace Content.Client.Singularity.Visualizers
|
||||
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AnimationPlayerComponent>(entity))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
|
||||
}
|
||||
IoCManager.Resolve<IEntityManager>().EnsureComponent<AnimationPlayerComponent>(entity);
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Content.Client.Spawners
|
||||
[RegisterComponent]
|
||||
public class ClientEntitySpawnerComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "ClientEntitySpawner";
|
||||
|
||||
[DataField("prototypes")] private List<string> _prototypes = new() { "HVDummyWire" };
|
||||
@@ -33,7 +35,7 @@ namespace Content.Client.Spawners
|
||||
{
|
||||
foreach (var proto in _prototypes)
|
||||
{
|
||||
var entity = IoCManager.Resolve<IEntityManager>().SpawnEntity(proto, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
var entity = _entMan.SpawnEntity(proto, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
_entity.Add(entity);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +44,7 @@ namespace Content.Client.Spawners
|
||||
{
|
||||
foreach (var entity in _entity)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity);
|
||||
_entMan.DeleteEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,16 +38,14 @@ namespace Content.Client.Trigger
|
||||
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AnimationPlayerComponent>(entity))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
|
||||
}
|
||||
IoCManager.Resolve<IEntityManager>().EnsureComponent<AnimationPlayerComponent>(entity);
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var sprite = entMan.GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
if (!component.TryGetData(TriggerVisuals.VisualState, out TriggerVisualState state))
|
||||
{
|
||||
state = TriggerVisualState.Unprimed;
|
||||
|
||||
@@ -121,10 +121,7 @@ namespace Content.Client.VendingMachines.UI
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AnimationPlayerComponent>(entity))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity);
|
||||
}
|
||||
IoCManager.Resolve<IEntityManager>().EnsureComponent<AnimationPlayerComponent>(entity);
|
||||
}
|
||||
|
||||
private void HideLayers(ISpriteComponent spriteComponent)
|
||||
@@ -141,8 +138,9 @@ namespace Content.Client.VendingMachines.UI
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var sprite = entMan.GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
if (!component.TryGetData(VendingMachineVisuals.VisualState, out VendingMachineVisualState state))
|
||||
{
|
||||
state = VendingMachineVisualState.Normal;
|
||||
|
||||
@@ -23,14 +23,15 @@ namespace Content.Client.VendingMachines
|
||||
{
|
||||
base.Open();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out SharedVendingMachineComponent? vendingMachine))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetComponent(Owner.Owner, out SharedVendingMachineComponent? vendingMachine))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VendingMachine = vendingMachine;
|
||||
|
||||
_menu = new VendingMachineMenu(this) {Title = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
|
||||
_menu = new VendingMachineMenu(this) {Title = entMan.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
|
||||
_menu.Populate(VendingMachine.Inventory);
|
||||
|
||||
_menu.OnClose += Close;
|
||||
|
||||
@@ -153,12 +153,12 @@ namespace Content.Client.Verbs
|
||||
// Remove any entities that do not have LOS
|
||||
if ((visibility & MenuVisibility.NoFov) == 0)
|
||||
{
|
||||
var playerPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.Value).MapPosition;
|
||||
var playerPos = EntityManager.GetComponent<TransformComponent>(player.Value).MapPosition;
|
||||
foreach (var entity in entities.ToList())
|
||||
{
|
||||
if (!ExamineSystemShared.InRangeUnOccluded(
|
||||
playerPos,
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapPosition,
|
||||
EntityManager.GetComponent<TransformComponent>(entity).MapPosition,
|
||||
ExamineSystemShared.ExamineRange,
|
||||
null))
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Content.Client.Wall.Components
|
||||
{
|
||||
public override string Name => "LowWall";
|
||||
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public CornerFill LastCornerNE { get; private set; }
|
||||
@@ -42,11 +43,11 @@ namespace Content.Client.Wall.Components
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
_overlayEntity = IoCManager.Resolve<IEntityManager>().SpawnEntity("LowWallOverlay", IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_overlayEntity).AttachParent(Owner);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_overlayEntity).LocalPosition = Vector2.Zero;
|
||||
_overlayEntity = _entMan.SpawnEntity("LowWallOverlay", _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
_entMan.GetComponent<TransformComponent>(_overlayEntity).AttachParent(Owner);
|
||||
_entMan.GetComponent<TransformComponent>(_overlayEntity).LocalPosition = Vector2.Zero;
|
||||
|
||||
_overlaySprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(_overlayEntity);
|
||||
_overlaySprite = _entMan.GetComponent<ISpriteComponent>(_overlayEntity);
|
||||
|
||||
var overState0 = $"{StateBase}over_0";
|
||||
_overlaySprite.LayerMapSet(OverCornerLayers.SE, _overlaySprite.AddLayerState(overState0));
|
||||
@@ -66,7 +67,7 @@ namespace Content.Client.Wall.Components
|
||||
EntityUid tempQualifier = _overlayEntity;
|
||||
if (tempQualifier != null)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(tempQualifier);
|
||||
_entMan.DeleteEntity(tempQualifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,13 +75,13 @@ namespace Content.Client.Wall.Components
|
||||
{
|
||||
base.CalculateNewSprite();
|
||||
|
||||
if (Sprite == null || !IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Anchored || _overlaySprite == null)
|
||||
if (Sprite == null || !_entMan.GetComponent<TransformComponent>(Owner).Anchored || _overlaySprite == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
var (n, nl) = MatchingWall(grid.GetInDir(coords, Direction.North));
|
||||
var (ne, nel) = MatchingWall(grid.GetInDir(coords, Direction.NorthEast));
|
||||
@@ -208,7 +209,7 @@ namespace Content.Client.Wall.Components
|
||||
|
||||
foreach (var entity in grid.GetLocal(coords))
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out WindowComponent? window))
|
||||
if (_entMan.TryGetComponent(entity, out WindowComponent? window))
|
||||
{
|
||||
//window.UpdateSprite();
|
||||
}
|
||||
@@ -220,7 +221,7 @@ namespace Content.Client.Wall.Components
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IconSmoothComponent? other))
|
||||
if (!_entMan.TryGetComponent(entity, out IconSmoothComponent? other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -39,14 +39,16 @@ namespace Content.Client.Weapons.Melee.Components
|
||||
offset *= (ResetTime - _time) / ResetTime;
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? spriteComponent))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entMan.TryGetComponent(Owner, out ISpriteComponent? spriteComponent))
|
||||
{
|
||||
spriteComponent.Offset = offset;
|
||||
}
|
||||
|
||||
if (deleteSelf)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().RemoveComponent<MeleeLungeComponent>(Owner);
|
||||
entMan.RemoveComponent<MeleeLungeComponent>(Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Content.Client.Weapons.Melee.Components
|
||||
[RegisterComponent]
|
||||
public sealed class MeleeWeaponArcAnimationComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "MeleeWeaponArcAnimation";
|
||||
|
||||
private MeleeWeaponAnimationPrototype? _meleeWeaponAnimation;
|
||||
@@ -22,7 +24,7 @@ namespace Content.Client.Weapons.Melee.Components
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(Owner);
|
||||
_sprite = _entMan.GetComponent<SpriteComponent>(Owner);
|
||||
}
|
||||
|
||||
public void SetData(MeleeWeaponAnimationPrototype prototype, Angle baseAngle, EntityUid attacker, bool followAttacker = true)
|
||||
@@ -31,7 +33,7 @@ namespace Content.Client.Weapons.Melee.Components
|
||||
_sprite?.AddLayer(new RSI.StateId(prototype.State));
|
||||
_baseAngle = baseAngle;
|
||||
if(followAttacker)
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).AttachParent(attacker);
|
||||
_entMan.GetComponent<TransformComponent>(Owner).AttachParent(attacker);
|
||||
}
|
||||
|
||||
internal void Update(float frameTime)
|
||||
@@ -51,16 +53,17 @@ namespace Content.Client.Weapons.Melee.Components
|
||||
_sprite.Color = new Color(r, g, b, a);
|
||||
}
|
||||
|
||||
var transform = _entMan.GetComponent<TransformComponent>(Owner);
|
||||
|
||||
switch (_meleeWeaponAnimation.ArcType)
|
||||
{
|
||||
case WeaponArcType.Slash:
|
||||
var angle = Angle.FromDegrees(_meleeWeaponAnimation.Width)/2;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldRotation =
|
||||
_baseAngle + Angle.Lerp(-angle, angle, (float) (_timer / _meleeWeaponAnimation.Length.TotalSeconds));
|
||||
transform.WorldRotation = _baseAngle + Angle.Lerp(-angle, angle, (float) (_timer / _meleeWeaponAnimation.Length.TotalSeconds));
|
||||
break;
|
||||
|
||||
case WeaponArcType.Poke:
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldRotation = _baseAngle;
|
||||
transform.WorldRotation = _baseAngle;
|
||||
|
||||
if (_sprite != null)
|
||||
{
|
||||
@@ -72,7 +75,7 @@ namespace Content.Client.Weapons.Melee.Components
|
||||
|
||||
if (_meleeWeaponAnimation.Length.TotalSeconds <= _timer)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner);
|
||||
_entMan.DeleteEntity(Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user