2021-02-22 04:08:17 +00:00
|
|
|
using System;
|
2021-08-30 11:49:09 +02:00
|
|
|
using Robust.Shared.Analyzers;
|
2020-01-09 00:27:52 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2021-02-18 09:09:07 +01:00
|
|
|
using Robust.Shared.Players;
|
2020-01-09 00:27:52 +01:00
|
|
|
using Robust.Shared.Serialization;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2021-05-26 10:20:57 +02:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
2020-04-12 01:15:16 +02:00
|
|
|
using Robust.Shared.ViewVariables;
|
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
|
|
|
{
|
2021-08-30 11:49:09 +02:00
|
|
|
[NetworkedComponent, Friend(typeof(SharedStackSystem))]
|
2021-03-05 01:08:38 +01:00
|
|
|
public abstract class SharedStackComponent : Component, ISerializationHooks
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
2020-04-12 01:15:16 +02:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-05-26 10:20:57 +02:00
|
|
|
[DataField("stackType", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
|
|
|
|
|
public string StackTypeId { get; private set; } = string.Empty;
|
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>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
[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.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
|
|
|
|
[DataField("max")]
|
2021-10-31 08:27:11 -05:00
|
|
|
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; }
|
2020-04-12 01:15:16 +02:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[ViewVariables]
|
2021-05-26 10:20:57 +02:00
|
|
|
public int AvailableSpace => MaxCount - Count;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|