* Reorganized Shared.Storage folder * Replace StorageCounter with Item Counter * Change stack visuals setting data * Fix mirrorcult suggestions * Fix items from upstream * Fix type formatting
29 lines
870 B
C#
29 lines
870 B
C#
using Content.Server.Storage.Components;
|
|
using Content.Shared.Storage.Components;
|
|
using Content.Shared.Storage.EntitySystems;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Server.Storage.EntitySystems
|
|
{
|
|
[UsedImplicitly]
|
|
public class ItemCounterSystem : SharedItemCounterSystem
|
|
{
|
|
protected override int? GetCount(ContainerModifiedMessage msg, ItemCounterComponent itemCounter)
|
|
{
|
|
if (!msg.Container.Owner.TryGetComponent(out ServerStorageComponent? component)
|
|
|| component.StoredEntities == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var count = 0;
|
|
foreach (var entity in component.StoredEntities)
|
|
{
|
|
if (itemCounter.Count.IsValid(entity)) count++;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
}
|
|
} |