Remove many resolves on Content.Server

This commit is contained in:
Vera Aguilera Puerto
2021-12-08 17:04:21 +01:00
parent 420039f278
commit ba736f70df
72 changed files with 407 additions and 302 deletions

View File

@@ -24,6 +24,8 @@ namespace Content.Server.Configurable
[ComponentReference(typeof(SharedConfigurationComponent))]
public class ConfigurationComponent : SharedConfigurationComponent, IInteractUsing, ISerializationHooks
{
[Dependency] private readonly IEntityManager _entMan = default!;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ConfigurationUiKey.Key);
[DataField("keys")] private List<string> _keys = new();
@@ -81,10 +83,10 @@ namespace Content.Server.Configurable
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{
if (UserInterface == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor))
if (UserInterface == null || !_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ToolComponent?>(eventArgs.Using, out var tool) || !tool.Qualities.Contains(_qualityNeeded))
if (!_entMan.TryGetComponent<ToolComponent?>(eventArgs.Using, out var tool) || !tool.Qualities.Contains(_qualityNeeded))
return false;
OpenUserInterface(actor);