Remove FoodContainer, add whitelists, replace with SpawnItemsOnUse (#4358)
This commit is contained in:
41
Content.Server/Storage/EntitySystems/ItemCounterSystem.cs
Normal file
41
Content.Server/Storage/EntitySystems/ItemCounterSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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.EntitySystems
|
||||
{
|
||||
[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user