using Content.Shared.FixedPoint; using Content.Shared.Store; using Robust.Shared.Audio; using Robust.Shared.Map; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; namespace Content.Server.Store.Components; /// /// This component manages a store which players can use to purchase different listings /// through the ui. The currency, listings, and categories are defined in yaml. /// [RegisterComponent] public sealed partial class StoreComponent : Component { /// /// The default preset for the store. Is overriden by default values specified on the component. /// [DataField("preset", customTypeSerializer: typeof(PrototypeIdSerializer))] public string? Preset; /// /// All the listing categories that are available on this store. /// The available listings are partially based on the categories. /// [DataField("categories", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))] public HashSet Categories = new(); /// /// The total amount of currency that can be used in the store. /// The string represents the ID of te currency prototype, where the /// float is that amount. /// [ViewVariables(VVAccess.ReadWrite), DataField("balance", customTypeSerializer: typeof(PrototypeIdDictionarySerializer))] public Dictionary Balance = new(); /// /// The list of currencies that can be inserted into this store. /// [ViewVariables(VVAccess.ReadOnly), DataField("currencyWhitelist", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))] public HashSet CurrencyWhitelist = new(); /// /// The person who "owns" the store/account. Used if you want the listings to be fixed /// regardless of who activated it. I.E. role specific items for uplinks. /// [ViewVariables(VVAccess.ReadWrite)] public EntityUid? AccountOwner = null; /// /// All listings, including those that aren't available to the buyer /// public HashSet Listings = new(); /// /// All available listings from the last time that it was checked. /// [ViewVariables] public HashSet LastAvailableListings = new(); /// /// All current entities bought from this shop. Useful for keeping track of refunds and upgrades. /// [ViewVariables, DataField] public List BoughtEntities = new(); /// /// The total balance spent in this store. Used for refunds. /// [ViewVariables, DataField] public Dictionary BalanceSpent = new(); /// /// Controls if the store allows refunds /// [ViewVariables, DataField] public bool RefundAllowed; /// /// The map the store was originally from, used to block refunds if the map is changed /// [DataField] public EntityUid? StartingMap; #region audio /// /// The sound played to the buyer when a purchase is succesfully made. /// [DataField("buySuccessSound")] public SoundSpecifier BuySuccessSound = new SoundPathSpecifier("/Audio/Effects/kaching.ogg"); #endregion } /// /// Event that is broadcast when a store is added to an entity /// [ByRefEvent] public readonly record struct StoreAddedEvent; /// /// Event that is broadcast when a store is removed from an entity /// [ByRefEvent] public readonly record struct StoreRemovedEvent; /// /// Broadcast when an Entity with the is deleted /// [ByRefEvent] public readonly struct RefundEntityDeletedEvent { public EntityUid Uid { get; } public RefundEntityDeletedEvent(EntityUid uid) { Uid = uid; } }