using Content.Shared.Whitelist; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; namespace Content.Shared.Materials; [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedMaterialStorageSystem))] public sealed partial class MaterialStorageComponent : Component { [DataField, AutoNetworkedField] public Dictionary, int> Storage { get; set; } = new(); /// /// Whether or not interacting with the materialstorage inserts the material in hand. /// [DataField] public bool InsertOnInteract = true; /// /// How much material the storage can store in total. /// [ViewVariables(VVAccess.ReadWrite), DataField] public int? StorageLimit; /// /// Whitelist for specifying the kind of items that can be insert into this entity. /// [DataField] public EntityWhitelist? Whitelist; /// /// Whether or not to drop contained materials when deconstructed. /// [DataField] public bool DropOnDeconstruct = true; /// /// Whitelist generated on runtime for what specific materials can be inserted into this entity. /// [DataField, AutoNetworkedField] public List>? MaterialWhiteList; /// /// Whether or not the visualization for the insertion animation /// should ignore the color of the material being inserted. /// [DataField] public bool IgnoreColor; /// /// The sound that plays when inserting an item into the storage /// [DataField] public SoundSpecifier? InsertingSound; /// /// How long the inserting animation will play /// [DataField] public TimeSpan InsertionTime = TimeSpan.FromSeconds(0.79f); // 0.01 off for animation timing /// /// Whether the storage can eject the materials stored within it /// [DataField] public bool CanEjectStoredMaterials = true; } [Serializable, NetSerializable] public enum MaterialStorageVisuals : byte { Inserting } /// /// Collects all the materials stored on a /// /// The entity holding all these materials /// A dictionary of all materials held /// An optional specifier. Non-local sources (silo, etc.) should not add materials when this is false. [ByRefEvent] public readonly record struct GetStoredMaterialsEvent(Entity Entity, Dictionary, int> Materials, bool LocalOnly); /// /// After using materials, removes them from storage. /// /// The entity that held the materials and is being used up /// A dictionary of the difference of materials left. /// An optional specifier. Non-local sources (silo, etc.) should not consume materials when this is false. [ByRefEvent] public readonly record struct ConsumeStoredMaterialsEvent(Entity Entity, Dictionary, int> Materials, bool LocalOnly); /// /// event raised on the materialStorage when a material entity is inserted into it. /// [ByRefEvent] public readonly record struct MaterialEntityInsertedEvent(MaterialComponent MaterialComp) { public readonly MaterialComponent MaterialComp = MaterialComp; } /// /// Event raised when a material amount is changed /// [ByRefEvent] public readonly record struct MaterialAmountChangedEvent; /// /// Event raised to get all the materials that the /// [ByRefEvent] public record struct GetMaterialWhitelistEvent(EntityUid Storage) { public readonly EntityUid Storage = Storage; public List> Whitelist = new(); } /// /// Message sent to try and eject a material from a storage /// [Serializable, NetSerializable] public sealed class EjectMaterialMessage : EntityEventArgs { public NetEntity Entity; public string Material; public int SheetsToExtract; public EjectMaterialMessage(NetEntity entity, string material, int sheetsToExtract) { Entity = entity; Material = material; SheetsToExtract = sheetsToExtract; } }