using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; namespace Content.Shared.Stacks; /// /// Component on an entity that represents a stack of identical things, usually materials. /// [RegisterComponent, NetworkedComponent] [Access(typeof(SharedStackSystem))] public sealed partial class StackComponent : Component { /// /// What stack type we are. /// [DataField("stackType", required: true)] public ProtoId StackTypeId = default!; /// /// Current stack count. /// Do NOT set this directly, use the method instead. /// [DataField] public int Count = 30; /// /// Max amount of things that can be in the stack. /// Overrides the max defined on the stack prototype. /// [DataField] public int? MaxCountOverride; /// /// Set to true to not reduce the count when used. /// [DataField] public bool Unlimited; /// /// When throwing this item, do we want to only throw one part of the stack or the whole stack at once? /// [DataField] public bool ThrowIndividually; /// /// Used by StackStatusControl in client to update UI. /// [ViewVariables] [Access(typeof(SharedStackSystem), Other = AccessPermissions.ReadWrite)] // Set by StackStatusControl public bool UiUpdateNeeded { get; set; } /// /// Default IconLayer stack. /// [DataField] 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")] 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] public List LayerStates = new(); /// /// An optional function to convert the amounts used to adjust a stack's appearance. /// Useful for different denominations of cash, for example. /// [DataField] public StackLayerFunction LayerFunction = StackLayerFunction.None; } [Serializable, NetSerializable] public sealed class StackComponentState : ComponentState { public int Count { get; } public int? MaxCountOverride { get; } public bool Unlimited { get; } public StackComponentState(int count, int? maxCountOverride, bool unlimited) { Count = count; MaxCountOverride = maxCountOverride; Unlimited = unlimited; } } [Serializable, NetSerializable] public enum StackLayerFunction : byte { // // No operation performed. // None, // // Arbitrarily thresholds the stack amount for each layer. // Expects entity to have StackLayerThresholdComponent. // Threshold }