Files
crystall-punk-14/Content.Shared/Stacks/StackComponent.cs

56 lines
1.8 KiB
C#
Raw Normal View History

using Robust.Shared.GameStates;
2020-01-09 00:27:52 +01:00
using Robust.Shared.Serialization;
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
{
[RegisterComponent, NetworkedComponent]
public sealed class StackComponent : Component
2020-01-09 00:27:52 +01:00
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("stackType", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<StackPrototype>))]
public string? StackTypeId { get; private set; }
/// <summary>
/// Current stack count.
/// Do NOT set this directly, use the <see cref="SharedStackSystem.SetCount"/> method instead.
/// </summary>
[DataField("count")]
public int Count { get; set; } = 30;
2021-07-11 11:07:27 +02:00
/// <summary>
/// Max amount of things that can be in the stack.
/// Overrides the max defined on the stack prototype.
2021-07-11 11:07:27 +02:00
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("maxCountOverride")]
public int? MaxCountOverride { get; set; }
/// <summary>
/// Set to true to not reduce the count when used.
/// </summary>
[DataField("unlimited")]
[ViewVariables(VVAccess.ReadOnly)]
public bool Unlimited { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
public bool ThrowIndividually { get; set; } = false;
[ViewVariables]
public bool UiUpdateNeeded { get; set; }
2021-07-11 11:07:27 +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; }
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
}
}
}