2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2020-01-09 00:27:52 +01:00
|
|
|
using Robust.Shared.Serialization;
|
2021-05-26 10:20:57 +02:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
2020-01-09 00:27:52 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Stacks
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
2022-12-24 23:28:21 -05:00
|
|
|
[RegisterComponent, NetworkedComponent]
|
|
|
|
|
public sealed class StackComponent : Component
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
2020-04-12 01:15:16 +02:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2022-11-08 21:24:23 -05:00
|
|
|
[DataField("stackType", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<StackPrototype>))]
|
|
|
|
|
public string? StackTypeId { get; private set; }
|
2020-04-12 01:15:16 +02:00
|
|
|
|
2021-05-26 10:20:57 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current stack count.
|
2021-08-30 11:49:09 +02:00
|
|
|
/// Do NOT set this directly, use the <see cref="SharedStackSystem.SetCount"/> method instead.
|
2021-05-26 10:20:57 +02:00
|
|
|
/// </summary>
|
|
|
|
|
[DataField("count")]
|
|
|
|
|
public int Count { get; set; } = 30;
|
2020-04-12 01:15:16 +02:00
|
|
|
|
2021-07-11 11:07:27 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Max amount of things that can be in the stack.
|
2022-11-08 21:24:23 -05:00
|
|
|
/// Overrides the max defined on the stack prototype.
|
2021-07-11 11:07:27 +02:00
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
2022-11-08 21:24:23 -05:00
|
|
|
[DataField("maxCountOverride")]
|
|
|
|
|
public int? MaxCountOverride { get; set; }
|
2021-10-31 08:27:11 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set to true to not reduce the count when used.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField("unlimited")]
|
|
|
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
|
|
|
|
public bool Unlimited { get; set; }
|
2022-12-24 23:28:21 -05:00
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public bool ThrowIndividually { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public bool UiUpdateNeeded { get; set; }
|
2021-07-11 11:07:27 +02:00
|
|
|
}
|
2020-04-12 01:15:16 +02:00
|
|
|
|
2021-07-11 11:07:27 +02:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class StackComponentState : ComponentState
|
|
|
|
|
{
|
|
|
|
|
public int Count { get; }
|
|
|
|
|
public int MaxCount { get; }
|
2020-04-12 01:15:16 +02:00
|
|
|
|
2021-07-12 01:32:10 -07:00
|
|
|
public StackComponentState(int count, int maxCount)
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
2021-07-11 11:07:27 +02:00
|
|
|
Count = count;
|
|
|
|
|
MaxCount = maxCount;
|
2020-01-09 00:27:52 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|