Files
tbd-station-14/Content.Server/Storage/ItemCounterSystem.cs
Ygg01 3fd28c2565 Added mapped storage for things like crayon belts and tools (#4201)
* Added mapped storage for things like crayon belts and tools

* Attempt to get StorageFillEvent to work

* Managed to get it working with Visualizer logi

* Improved PR and did some light refactoring of components

* Update Content.Client/Storage/Visualizers/MappedItemVisualizer.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Removed event, went with stateful ApperanceData

* Removed ids in favor of whitelist

* Refactor YAML, Moved functionality to Shared and renamed it.

* Changed so insert/remove always send full state.

* Move logic to component

* Fix some issues on MappedVisualizer and few nitpicks

- Fix mapped visualizer only doing init or update layers
- Fixed naming of systems
- Fixed sort of crayons

* Forgot to apply Vera's suggestion

* Fix the data to be more strict and to avoid unnecessary clearing

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2021-07-22 02:56:55 -07:00

42 lines
1.3 KiB
C#

using System.Collections.Generic;
using Content.Server.Storage.Components;
using Content.Shared.Storage.ItemCounter;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
namespace Content.Server.Storage
{
[UsedImplicitly]
public class ItemCounterSystem : SharedItemCounterSystem
{
protected override bool TryGetContainer(ContainerModifiedMessage msg,
ItemCounterComponent itemCounter,
out IReadOnlyList<string> showLayers)
{
if (msg.Container.Owner.TryGetComponent(out ServerStorageComponent? component))
{
var containedLayers = component.StoredEntities ?? new List<IEntity>();
var list = new List<string>();
foreach (var mapLayerData in itemCounter.MapLayers.Values)
{
foreach (var entity in containedLayers)
{
if (mapLayerData.Whitelist.IsValid(entity))
{
list.Add(mapLayerData.Layer);
break;
}
}
}
showLayers = list;
return true;
}
showLayers = new List<string>();
return false;
}
}
}