Files
tbd-station-14/Content.Client/Stack/StackSystem.cs
2022-03-27 21:03:14 -07:00

29 lines
850 B
C#

using Content.Shared.Stacks;
using JetBrains.Annotations;
namespace Content.Client.Stack
{
[UsedImplicitly]
public sealed class StackSystem : SharedStackSystem
{
public override void SetCount(EntityUid uid, int amount, SharedStackComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
base.SetCount(uid, amount, component);
// TODO PREDICT ENTITY DELETION: This should really just be a normal entity deletion call.
if (component.Count <= 0)
{
Transform(uid).DetachParentToNull();
return;
}
// Dirty the UI now that the stack count has changed.
if (component is StackComponent clientComp)
clientComp.UiUpdateNeeded = true;
}
}
}