Move StackSystem Use method to SharedStackSystem

This commit is contained in:
Vera Aguilera Puerto
2021-08-30 12:31:28 +02:00
parent d1fe278afc
commit fa48e2abae
2 changed files with 18 additions and 18 deletions

View File

@@ -28,23 +28,6 @@ namespace Content.Server.Stack
SubscribeLocalEvent<StackComponent, InteractUsingEvent>(OnStackInteractUsing);
}
/// <summary>
/// Try to use an amount of items on this stack. Returns whether this succeeded.
/// </summary>
public bool Use(EntityUid uid, SharedStackComponent stack, int amount)
{
// Check if we have enough things in the stack for this...
if (stack.Count < amount)
{
// Not enough things in the stack, return false.
return false;
}
// We do have enough things in the stack, so remove them and change.
SetCount(uid, stack, stack.Count - amount);
return true;
}
/// <summary>
/// Try to split this stack into two. Returns a non-null <see cref="IEntity"/> if successful.
/// </summary>

View File

@@ -60,7 +60,24 @@ namespace Content.Shared.Stacks
if (ComponentManager.TryGetComponent(uid, out SharedAppearanceComponent? appearance))
appearance.SetData(StackVisuals.Actual, component.Count);
RaiseLocalEvent(uid, new StackCountChangedEvent(old, component.Count));
RaiseLocalEvent(uid, new StackCountChangedEvent(old, component.Count), false);
}
/// <summary>
/// Try to use an amount of items on this stack. Returns whether this succeeded.
/// </summary>
public bool Use(EntityUid uid, SharedStackComponent stack, int amount)
{
// Check if we have enough things in the stack for this...
if (stack.Count < amount)
{
// Not enough things in the stack, return false.
return false;
}
// We do have enough things in the stack, so remove them and change.
SetCount(uid, stack, stack.Count - amount);
return true;
}
private void OnStackGetState(EntityUid uid, SharedStackComponent component, ref ComponentGetState args)