Files
OldThink/Content.Server/Store/Components/StoreComponent.cs
Remuchi d2d501dbc0 Merge remote-tracking branch 'upstream/master' into upstream
# Conflicts:
#	Content.Client/Access/AccessOverlay.cs
#	Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs
#	Content.Client/Access/UI/IdCardConsoleWindow.xaml
#	Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
#	Content.Client/Chemistry/UI/InjectorStatusControl.cs
#	Content.Client/StatusIcon/StatusIconOverlay.cs
#	Content.Client/Stylesheets/StyleNano.cs
#	Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
#	Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml
#	Content.Server/Access/Systems/IdCardConsoleSystem.cs
#	Content.Server/Administration/Commands/AGhost.cs
#	Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs
#	Content.Server/Connection/ConnectionManager.cs
#	Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs
#	Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs
#	Content.Server/GameTicking/GameTicker.RoundFlow.cs
#	Content.Server/GameTicking/GameTicker.Spawning.cs
#	Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs
#	Content.Server/Resist/EscapeInventorySystem.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
#	Content.Shared/Access/Components/IdCardConsoleComponent.cs
#	Content.Shared/Anomaly/SharedAnomalySystem.cs
#	Content.Shared/Bed/Sleep/SharedSleepingSystem.cs
#	Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
#	Content.Shared/Lock/LockSystem.cs
#	Content.Shared/RCD/Systems/RCDSystem.cs
#	Content.Shared/Roles/JobPrototype.cs
#	Content.Shared/StatusIcon/StatusIconPrototype.cs
#	Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
#	Resources/Audio/Machines/attributions.yml
#	Resources/Locale/en-US/rcd/components/rcd-component.ftl
#	Resources/Maps/reach.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_vending.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/heads.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/security.yml
#	Resources/Prototypes/Catalog/ReagentDispensers/beverage.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/boozeomat.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/cola.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/lawdrobe.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/pwrgame.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/shamblersjuice.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/soda.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/spaceup.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/starkist.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/theater.yml
#	Resources/Prototypes/DeviceLinking/sink_ports.yml
#	Resources/Prototypes/Entities/Clothing/Back/duffel.yml
#	Resources/Prototypes/Entities/Clothing/Belt/base_clothingbelt.yml
#	Resources/Prototypes/Entities/Clothing/Neck/misc.yml
#	Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml
#	Resources/Prototypes/Entities/Clothing/OuterClothing/wintercoats.yml
#	Resources/Prototypes/Entities/Mobs/Customization/Markings/gauze.yml
#	Resources/Prototypes/Entities/Objects/Devices/Electronics/door.yml
#	Resources/Prototypes/Entities/Objects/Magic/books.yml
#	Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml
#	Resources/Prototypes/Entities/Objects/Materials/Sheets/metal.yml
#	Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml
#	Resources/Prototypes/Entities/Objects/Misc/tiles.yml
#	Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/shotgun.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml
#	Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml
#	Resources/Prototypes/Entities/Structures/Doors/Airlocks/base_assembly.yml
#	Resources/Prototypes/Entities/Structures/Doors/Airlocks/base_structureairlocks.yml
#	Resources/Prototypes/Entities/Structures/Doors/Airlocks/highsec.yml
#	Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml
#	Resources/Prototypes/Entities/Structures/Doors/Firelocks/frame.yml
#	Resources/Prototypes/Entities/Structures/Doors/MaterialDoors/material_doors.yml
#	Resources/Prototypes/Entities/Structures/Doors/SecretDoor/secret_door.yml
#	Resources/Prototypes/Entities/Structures/Doors/Windoors/assembly.yml
#	Resources/Prototypes/Entities/Structures/Lighting/base_lighting.yml
#	Resources/Prototypes/Entities/Structures/Machines/lathe.yml
#	Resources/Prototypes/Entities/Structures/Power/cable_terminal.yml
#	Resources/Prototypes/Entities/Structures/Storage/Tanks/base_structuretanks.yml
#	Resources/Prototypes/Entities/Structures/Walls/grille.yml
#	Resources/Prototypes/Recipes/Construction/Graphs/structures/shutter.yml
#	Resources/Prototypes/Recipes/Crafting/Graphs/improvised/flowercrown.yml
#	Resources/Prototypes/Recipes/Crafting/improvised.yml
#	Resources/Prototypes/Roles/Jobs/Security/detective.yml
#	Resources/Prototypes/Roles/Jobs/Security/head_of_security.yml
#	Resources/Prototypes/Roles/Jobs/Security/security_officer.yml
#	Resources/Prototypes/Roles/Jobs/Security/warden.yml
#	Resources/Prototypes/StatusEffects/health.yml
#	Resources/Prototypes/Voice/speech_emotes.yml
#	Resources/Prototypes/lobbyscreens.yml
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertchaplain.rsi/equipped-OUTERCLOTHING-body-slim.png
#	Resources/Textures/Decals/bricktile.rsi/white_box.png
#	Resources/Textures/Objects/Misc/books.rsi/meta.json
#	Resources/migration.yml
2024-04-13 11:29:33 +07:00

131 lines
4.5 KiB
C#

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;
/// <summary>
/// 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.
/// </summary>
[RegisterComponent]
public sealed partial class StoreComponent : Component
{
/// <summary>
/// The default preset for the store. Is overriden by default values specified on the component.
/// </summary>
[DataField("preset", customTypeSerializer: typeof(PrototypeIdSerializer<StorePresetPrototype>))]
public string? Preset;
/// <summary>
/// All the listing categories that are available on this store.
/// The available listings are partially based on the categories.
/// </summary>
[DataField("categories", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<StoreCategoryPrototype>))]
public HashSet<string> Categories = new();
/// <summary>
/// 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.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("balance", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, CurrencyPrototype>))]
public Dictionary<string, FixedPoint2> Balance = new();
/// <summary>
/// The list of currencies that can be inserted into this store.
/// </summary>
[ViewVariables(VVAccess.ReadOnly), DataField("currencyWhitelist", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<CurrencyPrototype>))]
public HashSet<string> CurrencyWhitelist = new();
/// <summary>
/// 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.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public EntityUid? AccountOwner = null;
/// <summary>
/// All listings, including those that aren't available to the buyer
/// </summary>
public HashSet<ListingData> Listings = new();
/// <summary>
/// All available listings from the last time that it was checked.
/// </summary>
[ViewVariables]
public HashSet<ListingData> LastAvailableListings = new();
/// <summary>
/// All current entities bought from this shop. Useful for keeping track of refunds and upgrades.
/// </summary>
[ViewVariables, DataField]
public List<EntityUid> BoughtEntities = new();
/// <summary>
/// The total balance spent in this store. Used for refunds.
/// </summary>
[ViewVariables, DataField]
public Dictionary<string, FixedPoint2> BalanceSpent = new();
/// <summary>
/// Controls if the store allows refunds
/// </summary>
[ViewVariables, DataField]
public bool RefundAllowed;
/// <summary>
/// Checks if store can be opened by the account owner only.
/// Not meant to be used with uplinks.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public bool OwnerOnly;
/// <summary>
/// The map the store was originally from, used to block refunds if the map is changed
/// </summary>
[DataField]
public EntityUid? StartingMap;
// Miracle
[DataField]
public bool Refunds;
#region audio
/// <summary>
/// The sound played to the buyer when a purchase is succesfully made.
/// </summary>
[DataField("buySuccessSound")]
public SoundSpecifier BuySuccessSound = new SoundPathSpecifier("/Audio/Effects/kaching.ogg");
#endregion
}
/// <summary>
/// Event that is broadcast when a store is added to an entity
/// </summary>
[ByRefEvent]
public readonly record struct StoreAddedEvent;
/// <summary>
/// Event that is broadcast when a store is removed from an entity
/// </summary>
[ByRefEvent]
public readonly record struct StoreRemovedEvent;
/// <summary>
/// Broadcast when an Entity with the <see cref="StoreRefundComponent"/> is deleted
/// </summary>
[ByRefEvent]
public readonly struct RefundEntityDeletedEvent
{
public EntityUid Uid { get; }
public RefundEntityDeletedEvent(EntityUid uid)
{
Uid = uid;
}
}