using Content.Shared.FixedPoint;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.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, NetworkedComponent]
public sealed partial class StoreComponent : Component
{
[DataField]
public LocId Name = "store-ui-default-title";
///
/// All the listing categories that are available on this store.
/// The available listings are partially based on the categories.
///
[DataField]
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.
///
[DataField]
public Dictionary, FixedPoint2> Balance = new();
///
/// The list of currencies that can be inserted into this store.
///
[DataField]
public HashSet> CurrencyWhitelist = new();
///
/// The person/mind 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.
///
[DataField]
public EntityUid? AccountOwner = null;
///
/// Cached list of listings items with modifiers.
///
[DataField]
public HashSet FullListingsCatalog = 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, FixedPoint2> BalanceSpent = new();
///
/// Controls if the store allows refunds
///
[ViewVariables, DataField]
public bool RefundAllowed;
///
/// Checks if store can be opened by the account owner only.
/// Not meant to be used with uplinks.
///
[ViewVariables(VVAccess.ReadWrite), DataField]
public bool OwnerOnly;
///
/// 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]
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;
}
}