Files
tbd-station-14/Content.Server/Construction/Completions/SetStackCount.cs
2021-07-16 17:37:09 -07:00

25 lines
722 B
C#

using System.Threading.Tasks;
using Content.Server.Stack;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class SetStackCount : IGraphAction
{
[DataField("amount")] public int Amount { get; } = 1;
public async Task PerformAction(IEntity entity, IEntity? user)
{
if (entity.Deleted) return;
if(!entity.TryGetComponent<StackComponent>(out var stack)) return;
EntitySystem.Get<StackSystem>().SetCount(entity.Uid, stack, Amount);
}
}
}