using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Stacks { [RegisterComponent, NetworkedComponent] public sealed partial class StackComponent : Component { [ViewVariables(VVAccess.ReadWrite)] [DataField("stackType", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] public string StackTypeId { get; private set; } = default!; /// /// Current stack count. /// Do NOT set this directly, use the method instead. /// [DataField("count")] public int Count { get; set; } = 30; /// /// Max amount of things that can be in the stack. /// Overrides the max defined on the stack prototype. /// [ViewVariables(VVAccess.ReadOnly)] [DataField("maxCountOverride")] public int? MaxCountOverride { get; set; } /// /// Set to true to not reduce the count when used. /// Note that still limits the amount that can be used at any one time. /// [DataField("unlimited")] [ViewVariables(VVAccess.ReadOnly)] public bool Unlimited { get; set; } /// /// Lingering stacks will remain present even when there are no items. /// Instead, they will become transparent. /// [DataField("lingering"), ViewVariables(VVAccess.ReadWrite)] public bool Lingering; [DataField("throwIndividually"), ViewVariables(VVAccess.ReadWrite)] public bool ThrowIndividually { get; set; } = false; [ViewVariables] public bool UiUpdateNeeded { get; set; } /// /// Default IconLayer stack. /// [DataField("baseLayer")] [ViewVariables(VVAccess.ReadWrite)] public string BaseLayer = ""; /// /// Determines if the visualizer uses composite or non-composite layers for icons. Defaults to false. /// /// /// /// false: they are opaque and mutually exclusive (e.g. sprites in a cable coil). Default value /// /// /// true: they are transparent and thus layered one over another in ascending order first /// /// /// /// [DataField("composite")] [ViewVariables(VVAccess.ReadWrite)] public bool IsComposite; /// /// Sprite layers used in stack visualizer. Sprites first in layer correspond to lower stack states /// e.g. _spriteLayers[0] is lower stack level than _spriteLayers[1]. /// [DataField("layerStates")] [ViewVariables(VVAccess.ReadWrite)] public List LayerStates = new(); } [Serializable, NetSerializable] public sealed class StackComponentState : ComponentState { public int Count { get; } public int? MaxCount { get; } public bool Lingering; public StackComponentState(int count, int? maxCount, bool lingering) { Count = count; MaxCount = maxCount; Lingering = lingering; } } }