Adds support for unlimited stacks (#5084)
Co-authored-by: ike709 <ike709@github.com>
This commit is contained in:
@@ -62,6 +62,8 @@ namespace Content.Server.Stack
|
|||||||
{
|
{
|
||||||
// Set the split stack's count.
|
// Set the split stack's count.
|
||||||
SetCount(entity.Uid, amount, stackComp);
|
SetCount(entity.Uid, amount, stackComp);
|
||||||
|
// Don't let people dupe unlimited stacks
|
||||||
|
stackComp.Unlimited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace Content.Shared.Stacks
|
|||||||
{
|
{
|
||||||
public sealed override string Name => "Stack";
|
public sealed override string Name => "Stack";
|
||||||
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("stackType", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
|
[DataField("stackType", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
|
||||||
public string StackTypeId { get; private set; } = string.Empty;
|
public string StackTypeId { get; private set; } = string.Empty;
|
||||||
@@ -32,7 +33,14 @@ namespace Content.Shared.Stacks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
[DataField("max")]
|
[DataField("max")]
|
||||||
public int MaxCount { get; set; } = 30;
|
public int MaxCount { get; set; } = 30;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set to true to not reduce the count when used.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("unlimited")]
|
||||||
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
|
public bool Unlimited { get; set; }
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public int AvailableSpace => MaxCount - Count;
|
public int AvailableSpace => MaxCount - Count;
|
||||||
|
|||||||
@@ -73,7 +73,11 @@ namespace Content.Shared.Stacks
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We do have enough things in the stack, so remove them and change.
|
// We do have enough things in the stack, so remove them and change.
|
||||||
SetCount(uid, stack.Count - amount, stack);
|
if (!stack.Unlimited)
|
||||||
|
{
|
||||||
|
SetCount(uid, stack.Count - amount, stack);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user