Inline TryGetComponent completely

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:05:23 +01:00
parent f3edecf994
commit 2ff4ec65d5
34 changed files with 98 additions and 84 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared.Storage.Components;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Shared.Storage.EntitySystems
{
@@ -20,7 +21,7 @@ namespace Content.Shared.Storage.EntitySystems
private void InitLayers(EntityUid uid, ItemMapperComponent component, ComponentInit args)
{
if (component.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearanceComponent))
{
var list = new List<string>(component.MapLayers.Keys);
appearanceComponent.SetData(StorageMapVisuals.InitLayers, new ShowLayerData(list));
@@ -30,7 +31,7 @@ namespace Content.Shared.Storage.EntitySystems
private void MapperEntityRemoved(EntityUid uid, ItemMapperComponent itemMapper,
EntRemovedFromContainerMessage args)
{
if (itemMapper.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemMapper.Owner.Uid, out AppearanceComponent? appearanceComponent)
&& TryGetLayers(args, itemMapper, out var containedLayers))
{
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));
@@ -40,7 +41,7 @@ namespace Content.Shared.Storage.EntitySystems
private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper,
EntInsertedIntoContainerMessage args)
{
if (itemMapper.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemMapper.Owner.Uid, out AppearanceComponent? appearanceComponent)
&& TryGetLayers(args, itemMapper, out var containedLayers))
{
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));
@@ -51,4 +52,4 @@ namespace Content.Shared.Storage.EntitySystems
ItemMapperComponent itemMapper,
out IReadOnlyList<string> containedLayers);
}
}
}