using Content.Shared.Whitelist; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Materials; [Access(typeof(SharedMaterialStorageSystem))] [RegisterComponent, NetworkedComponent] public sealed partial class MaterialStorageComponent : Component { [DataField("storage", customTypeSerializer: typeof(PrototypeIdDictionarySerializer))] public Dictionary Storage { get; set; } = new(); /// /// Whether or not interacting with the materialstorage inserts the material in hand. /// [DataField("insertOnInteract")] public bool InsertOnInteract = true; /// /// How much material the storage can store in total. /// [ViewVariables(VVAccess.ReadWrite), DataField("storageLimit")] public int? StorageLimit; /// /// Whitelist for specifying the kind of items that can be insert into this entity. /// [DataField("whitelist")] public EntityWhitelist? EntityWhitelist; /// /// Whether or not to drop contained materials when deconstructed. /// [DataField("dropOnDeconstruct")] public bool DropOnDeconstruct = true; /// /// Whitelist generated on runtime for what specific materials can be inserted into this entity. /// [DataField("materialWhiteList", customTypeSerializer: typeof(PrototypeIdListSerializer))] public List? MaterialWhiteList; /// /// Whether or not the visualization for the insertion animation /// should ignore the color of the material being inserted. /// [DataField("ignoreColor")] public bool IgnoreColor; /// /// The sound that plays when inserting an item into the storage /// [DataField("insertingSound")] public SoundSpecifier? InsertingSound; /// /// How long the inserting animation will play /// [DataField("insertionTime")] public TimeSpan InsertionTime = TimeSpan.FromSeconds(0.79f); // 0.01 off for animation timing } [Serializable, NetSerializable] public enum MaterialStorageVisuals : byte { Inserting } /// /// 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(); } [Serializable, NetSerializable] public sealed class MaterialStorageComponentState : ComponentState { public Dictionary Storage; public List? MaterialWhitelist; public MaterialStorageComponentState(Dictionary storage, List? materialWhitelist) { Storage = storage; MaterialWhitelist = materialWhitelist; } }