A bunch more resolves removed wooo

This commit is contained in:
Vera Aguilera Puerto
2021-12-08 11:37:10 +01:00
parent 4919f1db69
commit 9b9babd429
4 changed files with 14 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ namespace Content.Client.Access.UI
public class IdCardConsoleBoundUserInterface : BoundUserInterface public class IdCardConsoleBoundUserInterface : BoundUserInterface
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {
@@ -22,7 +23,7 @@ namespace Content.Client.Access.UI
{ {
base.Open(); base.Open();
_window = new IdCardConsoleWindow(this, _prototypeManager) {Title = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName}; _window = new IdCardConsoleWindow(this, _prototypeManager) {Title = _entityManager.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
_window.OnClose += Close; _window.OnClose += Close;
_window.OpenCentered(); _window.OpenCentered();
} }

View File

@@ -12,23 +12,24 @@ namespace Content.Client.Animations
{ {
public static class ReusableAnimations public static class ReusableAnimations
{ {
public static void AnimateEntityPickup(EntityUid entity, EntityCoordinates initialPosition, Vector2 finalPosition) public static void AnimateEntityPickup(EntityUid entity, EntityCoordinates initialPosition, Vector2 finalPosition, IEntityManager? entMan = null)
{ {
var animatableClone = IoCManager.Resolve<IEntityManager>().SpawnEntity("clientsideclone", initialPosition); IoCManager.Resolve(ref entMan);
string val = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName; var animatableClone = entMan.SpawnEntity("clientsideclone", initialPosition);
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(animatableClone).EntityName = val; string val = entMan.GetComponent<MetaDataComponent>(entity).EntityName;
entMan.GetComponent<MetaDataComponent>(animatableClone).EntityName = val;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SpriteComponent? sprite0)) if (!entMan.TryGetComponent(entity, out SpriteComponent? sprite0))
{ {
Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName, nameof(SpriteComponent)); Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entMan.GetComponent<MetaDataComponent>(entity).EntityName, nameof(SpriteComponent));
return; return;
} }
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(animatableClone); var sprite = entMan.GetComponent<SpriteComponent>(animatableClone);
sprite.CopyFrom(sprite0); sprite.CopyFrom(sprite0);
var animations = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(animatableClone); var animations = entMan.GetComponent<AnimationPlayerComponent>(animatableClone);
animations.AnimationCompleted += (_) => { animations.AnimationCompleted += (_) => {
IoCManager.Resolve<IEntityManager>().DeleteEntity(animatableClone); entMan.DeleteEntity(animatableClone);
}; };
animations.Play(new Animation animations.Play(new Animation

View File

@@ -62,7 +62,7 @@ namespace Content.Client.Hands
if (!_gameTiming.IsFirstTimePredicted) if (!_gameTiming.IsFirstTimePredicted)
return; return;
ReusableAnimations.AnimateEntityPickup(msg.EntityUid, msg.InitialPosition, msg.FinalPosition); ReusableAnimations.AnimateEntityPickup(msg.EntityUid, msg.InitialPosition, msg.FinalPosition, EntityManager);
} }
public HandsGuiState GetGuiState() public HandsGuiState GetGuiState()

View File

@@ -124,7 +124,7 @@ namespace Content.Client.Storage
if (_entityManager.EntityExists(entity)) if (_entityManager.EntityExists(entity))
{ {
ReusableAnimations.AnimateEntityPickup(entity, initialPosition, _entityManager.GetComponent<TransformComponent>(Owner).LocalPosition); ReusableAnimations.AnimateEntityPickup(entity, initialPosition, _entityManager.GetComponent<TransformComponent>(Owner).LocalPosition, _entityManager);
} }
} }
} }