2023-09-08 18:16:05 -07:00
|
|
|
using System.Linq;
|
2022-08-17 00:34:25 -04:00
|
|
|
using Content.Server.Actions;
|
|
|
|
|
using Content.Server.Administration.Logs;
|
2023-04-29 09:07:50 +00:00
|
|
|
using Content.Server.Stack;
|
2022-08-17 00:34:25 -04:00
|
|
|
using Content.Server.Store.Components;
|
2024-02-03 19:48:51 -05:00
|
|
|
using Content.Shared.Actions;
|
2023-09-08 18:16:05 -07:00
|
|
|
using Content.Shared.Database;
|
2022-08-17 00:34:25 -04:00
|
|
|
using Content.Shared.FixedPoint;
|
|
|
|
|
using Content.Shared.Hands.EntitySystems;
|
2024-02-03 19:48:51 -05:00
|
|
|
using Content.Shared.Mind;
|
2025-04-19 15:55:05 +02:00
|
|
|
using Content.Shared.PDA.Ringer;
|
2022-08-17 00:34:25 -04:00
|
|
|
using Content.Shared.Store;
|
2024-06-01 11:29:17 -04:00
|
|
|
using Content.Shared.Store.Components;
|
2024-02-03 19:48:51 -05:00
|
|
|
using Content.Shared.UserInterface;
|
2022-08-17 00:34:25 -04:00
|
|
|
using Robust.Server.GameObjects;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Shared.Audio.Systems;
|
2023-10-29 04:21:02 +11:00
|
|
|
using Robust.Shared.Player;
|
2024-03-31 05:09:15 +01:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-08-17 00:34:25 -04:00
|
|
|
|
|
|
|
|
namespace Content.Server.Store.Systems;
|
|
|
|
|
|
2023-02-12 07:39:14 -05:00
|
|
|
public sealed partial class StoreSystem
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IAdminLogManager _admin = default!;
|
|
|
|
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
|
|
|
|
[Dependency] private readonly ActionsSystem _actions = default!;
|
2024-02-03 19:48:51 -05:00
|
|
|
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
|
|
|
|
[Dependency] private readonly ActionUpgradeSystem _actionUpgrade = default!;
|
|
|
|
|
[Dependency] private readonly SharedMindSystem _mind = default!;
|
2022-08-17 00:34:25 -04:00
|
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
|
|
|
[Dependency] private readonly StackSystem _stack = default!;
|
2022-09-11 02:54:16 -04:00
|
|
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
2022-08-17 00:34:25 -04:00
|
|
|
|
|
|
|
|
private void InitializeUi()
|
|
|
|
|
{
|
2023-02-12 07:39:14 -05:00
|
|
|
SubscribeLocalEvent<StoreComponent, StoreRequestUpdateInterfaceMessage>(OnRequestUpdate);
|
2022-08-17 00:34:25 -04:00
|
|
|
SubscribeLocalEvent<StoreComponent, StoreBuyListingMessage>(OnBuyRequest);
|
|
|
|
|
SubscribeLocalEvent<StoreComponent, StoreRequestWithdrawMessage>(OnRequestWithdraw);
|
2024-02-03 19:48:51 -05:00
|
|
|
SubscribeLocalEvent<StoreComponent, StoreRequestRefundMessage>(OnRequestRefund);
|
|
|
|
|
SubscribeLocalEvent<StoreComponent, RefundEntityDeletedEvent>(OnRefundEntityDeleted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnRefundEntityDeleted(Entity<StoreComponent> ent, ref RefundEntityDeletedEvent args)
|
|
|
|
|
{
|
|
|
|
|
ent.Comp.BoughtEntities.Remove(args.Uid);
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Toggles the store Ui open and closed
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="user">the person doing the toggling</param>
|
2023-02-12 07:39:14 -05:00
|
|
|
/// <param name="storeEnt">the store being toggled</param>
|
|
|
|
|
/// <param name="component"></param>
|
|
|
|
|
public void ToggleUi(EntityUid user, EntityUid storeEnt, StoreComponent? component = null)
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
2023-02-12 07:39:14 -05:00
|
|
|
if (!Resolve(storeEnt, ref component))
|
|
|
|
|
return;
|
|
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
if (!TryComp<ActorComponent>(user, out var actor))
|
|
|
|
|
return;
|
|
|
|
|
|
2023-02-12 07:39:14 -05:00
|
|
|
if (!_ui.TryToggleUi(storeEnt, StoreUiKey.Key, actor.PlayerSession))
|
2022-09-11 02:54:16 -04:00
|
|
|
return;
|
2022-08-17 00:34:25 -04:00
|
|
|
|
2023-02-12 07:39:14 -05:00
|
|
|
UpdateUserInterface(user, storeEnt, component);
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
2023-05-01 06:30:08 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Closes the store UI for everyone, if it's open
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void CloseUi(EntityUid uid, StoreComponent? component = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return;
|
|
|
|
|
|
2024-04-26 18:16:24 +10:00
|
|
|
_ui.CloseUi(uid, StoreUiKey.Key);
|
2023-05-01 06:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the user interface for a store and refreshes the listings
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="user">The person who if opening the store ui. Listings are filtered based on this.</param>
|
2023-02-12 07:39:14 -05:00
|
|
|
/// <param name="store">The store entity itself</param>
|
2022-08-17 00:34:25 -04:00
|
|
|
/// <param name="component">The store component being refreshed.</param>
|
2024-04-26 18:16:24 +10:00
|
|
|
public void UpdateUserInterface(EntityUid? user, EntityUid store, StoreComponent? component = null)
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
2023-02-12 07:39:14 -05:00
|
|
|
if (!Resolve(store, ref component))
|
|
|
|
|
return;
|
2022-08-17 00:34:25 -04:00
|
|
|
|
|
|
|
|
//this is the person who will be passed into logic for all listing filtering.
|
2022-09-14 19:04:41 +12:00
|
|
|
if (user != null) //if we have no "buyer" for this update, then don't update the listings
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
component.LastAvailableListings = GetAvailableListings(component.AccountOwner ?? user.Value, store, component)
|
|
|
|
|
.ToHashSet();
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//dictionary for all currencies, including 0 values for currencies on the whitelist
|
2024-04-12 03:07:25 -04:00
|
|
|
Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> allCurrency = new();
|
2022-08-17 00:34:25 -04:00
|
|
|
foreach (var supported in component.CurrencyWhitelist)
|
|
|
|
|
{
|
|
|
|
|
allCurrency.Add(supported, FixedPoint2.Zero);
|
|
|
|
|
|
2024-04-12 03:07:25 -04:00
|
|
|
if (component.Balance.TryGetValue(supported, out var value))
|
|
|
|
|
allCurrency[supported] = value;
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
2022-09-14 19:04:41 +12:00
|
|
|
// TODO: if multiple users are supposed to be able to interact with a single BUI & see different
|
|
|
|
|
// stores/listings, this needs to use session specific BUI states.
|
|
|
|
|
|
2023-05-01 06:30:08 +00:00
|
|
|
// only tell operatives to lock their uplink if it can be locked
|
|
|
|
|
var showFooter = HasComp<RingerUplinkComponent>(store);
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
|
2024-02-03 19:48:51 -05:00
|
|
|
var state = new StoreUpdateState(component.LastAvailableListings, allCurrency, showFooter, component.RefundAllowed);
|
2024-04-26 18:16:24 +10:00
|
|
|
_ui.SetUiState(store, StoreUiKey.Key, state);
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
2023-02-12 07:39:14 -05:00
|
|
|
private void OnRequestUpdate(EntityUid uid, StoreComponent component, StoreRequestUpdateInterfaceMessage args)
|
|
|
|
|
{
|
2024-04-26 18:16:24 +10:00
|
|
|
UpdateUserInterface(args.Actor, GetEntity(args.Entity), component);
|
2023-02-12 07:39:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BeforeActivatableUiOpen(EntityUid uid, StoreComponent component, BeforeActivatableUIOpenEvent args)
|
|
|
|
|
{
|
|
|
|
|
UpdateUserInterface(args.User, uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Handles whenever a purchase was made.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListingMessage msg)
|
|
|
|
|
{
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
var listing = component.FullListingsCatalog.FirstOrDefault(x => x.ID.Equals(msg.Listing.Id));
|
2024-02-03 19:48:51 -05:00
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
if (listing == null) //make sure this listing actually exists
|
|
|
|
|
{
|
2023-07-08 09:02:17 -07:00
|
|
|
Log.Debug("listing does not exist");
|
2022-08-17 00:34:25 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-26 18:16:24 +10:00
|
|
|
var buyer = msg.Actor;
|
2022-09-14 19:04:41 +12:00
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
//verify that we can actually buy this listing and it wasn't added
|
|
|
|
|
if (!ListingHasCategory(listing, component.Categories))
|
|
|
|
|
return;
|
2022-09-14 19:04:41 +12:00
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
//condition checking because why not
|
|
|
|
|
if (listing.Conditions != null)
|
|
|
|
|
{
|
2025-03-02 20:40:57 +01:00
|
|
|
var args = new ListingConditionArgs(component.AccountOwner ?? GetBuyerMind(buyer), uid, listing, EntityManager);
|
2022-09-11 02:54:16 -04:00
|
|
|
var conditionsMet = listing.Conditions.All(condition => condition.Condition(args));
|
2022-08-17 00:34:25 -04:00
|
|
|
|
|
|
|
|
if (!conditionsMet)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//check that we have enough money
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
var cost = listing.Cost;
|
|
|
|
|
foreach (var (currency, amount) in cost)
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
if (!component.Balance.TryGetValue(currency, out var balance) || balance < amount)
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-03 19:48:51 -05:00
|
|
|
|
|
|
|
|
if (!IsOnStartingMap(uid, component))
|
2025-02-15 11:17:29 -05:00
|
|
|
DisableRefund(uid, component);
|
2024-02-03 19:48:51 -05:00
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
//subtract the cash
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
foreach (var (currency, amount) in cost)
|
2022-11-08 21:24:23 -05:00
|
|
|
{
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
component.Balance[currency] -= amount;
|
2024-02-03 19:48:51 -05:00
|
|
|
|
|
|
|
|
component.BalanceSpent.TryAdd(currency, FixedPoint2.Zero);
|
|
|
|
|
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
component.BalanceSpent[currency] += amount;
|
2022-11-08 21:24:23 -05:00
|
|
|
}
|
2022-08-17 00:34:25 -04:00
|
|
|
|
|
|
|
|
//spawn entity
|
|
|
|
|
if (listing.ProductEntity != null)
|
|
|
|
|
{
|
2022-09-14 19:04:41 +12:00
|
|
|
var product = Spawn(listing.ProductEntity, Transform(buyer).Coordinates);
|
|
|
|
|
_hands.PickupOrDrop(buyer, product);
|
2024-02-03 19:48:51 -05:00
|
|
|
|
|
|
|
|
HandleRefundComp(uid, component, product);
|
|
|
|
|
|
|
|
|
|
var xForm = Transform(product);
|
|
|
|
|
|
|
|
|
|
if (xForm.ChildCount > 0)
|
|
|
|
|
{
|
|
|
|
|
var childEnumerator = xForm.ChildEnumerator;
|
|
|
|
|
while (childEnumerator.MoveNext(out var child))
|
|
|
|
|
{
|
|
|
|
|
component.BoughtEntities.Add(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//give action
|
2023-09-08 18:16:05 -07:00
|
|
|
if (!string.IsNullOrWhiteSpace(listing.ProductAction))
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
2024-02-03 19:48:51 -05:00
|
|
|
EntityUid? actionId;
|
2023-09-23 04:49:39 -04:00
|
|
|
// I guess we just allow duplicate actions?
|
2024-02-03 19:48:51 -05:00
|
|
|
// Allow duplicate actions and just have a single list buy for the buy-once ones.
|
|
|
|
|
if (!_mind.TryGetMind(buyer, out var mind, out _))
|
|
|
|
|
actionId = _actions.AddAction(buyer, listing.ProductAction);
|
|
|
|
|
else
|
|
|
|
|
actionId = _actionContainer.AddAction(mind, listing.ProductAction);
|
|
|
|
|
|
|
|
|
|
// Add the newly bought action entity to the list of bought entities
|
|
|
|
|
// And then add that action entity to the relevant product upgrade listing, if applicable
|
|
|
|
|
if (actionId != null)
|
|
|
|
|
{
|
|
|
|
|
HandleRefundComp(uid, component, actionId.Value);
|
|
|
|
|
|
Magic Refactor + Wizard Grimoire (#22568)
* Brings over changes from the original magic refactor PR
* Adds Master Spellbook, spellbook categories, WizCoin currency, and locale
* Wiz€oin™
* Adds currency whitelist to Spellbook preset, grants contained actions on action added.
* Adds grant contained action and remove provided action.
* adds a way for actions to be upgraded to the store
* Adds Fireball 3 and fixes action upgrade logic so that it checks if the action can level or if the action can upgrade separately
* Fixes upgrade logic in ActionUpgradeSystem to allow for level ups without an actual upgrade. Fixed action upgrade logic in store system as well
* Removes current action entity from the bought entities list and adds new or old action entity
* Removes Current Entity
* Removes old comments, fixes TransferAllActionsWithNewAttached
* Removes TODO
* Removes Product Action Upgrade Event
* reverts changes to immovablerodrule
* Removes stale event reference
* fixes mind action grant logic
* reverts shared gun system change to projectile anomaly system
* forgor to remove the using
* Reverts unintended changes to action container
* Adds refund button to the store
* Refreshes store back to origin.
* Refund with correct currency
* Init refund
* Check for terminating and update interface
* Disables refund button
* Removes preset allow refund
* dont refund if map changed
* adds refunds to stores
* Adds method to check for starting map
* comments, datafields, some requested changes
* turns event into ref event
* Adds datafields
* Switches to entity terminating event
* Changes store entity to be nullable and checks if store is terminating to remove reference.
* Tryadd instead of containskey
* Adds a refund disable method, disables refund on bought ent container changes if not an action
* Removes duplicate refundcomp
* Removes unintended merges
* Removed another unintended change from merge
* removes extra using statement
* readds using statement
* might as well just remove both usings since it won't leave the PR
* Fixes Action upgrades from stores
* Changes to non obsolete method uses
* Shares spawn code between instant and world
* Adds action entity to action event, adds beforecastspellevent, adds spell requirements to magic component
* puts prereq check in spell methods, sets up template code for before cast event
* checks for required wizard clothes
* Networks Magic Comp and Wizard Clothes Comp. Renames MagicSpawnData to MagicInstantSpawnData.
* Removes posdata from projectiles
* Speech > RequiresSpeech
* Fixes ActionOnInteract
* checks for muted
* popup for missing reqs
* Validate click loc for blink spell
* Checks if doors are in range and not obstructed before opening
* Check ents by map coords
* Adds speak event
* Comments spellbooks
* Removes comments
* Unobsoletes smite spell
* Invert if
* Requirements loc
* Fixes spell reqs
* Inverts an if
* Comment updates
* Starts doafter work
* Removes doafter references
* Balances fireball upgrades to be more reasonable
* Enables refund on master spellbooks
* Spells to do
* update spellbook doafter
* knock toggles bolts
* Touch Spell comments
* Comments for pending spells
* more comments
* adds spider polymorph to spellbook
* TODOs for spells
* reorganizes spellbook categories and adds wands
* fixes spacing and adds limited conditions
* commented owner only for future store PR
* reenables owner only for the grimoire
* fixes grimoire sprite
* Adds wizard rod polymorph
* summon ghosts event
* Moves rod form to offensive category
* Adds charge spell and loc for rod polymorph
* Oops forgor the actual chages
* Item Recall comment
* Fixes UI
* removes extra field for wizard rod
* Cleanup
* New Condition (INCOMPLETE)
* Fix linter
* Fix linter (for real)
* fixed some descriptions
* adds regions to magic
* Adds a non-refund wizard grimoire, fixes blink to deselect after teleporting, reduces force wall despawn time to 12 seconds
* removes limited upgrade condition
---------
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-05-11 19:06:49 -04:00
|
|
|
if (listing.ProductUpgradeId != null)
|
2024-02-03 19:48:51 -05:00
|
|
|
{
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
foreach (var upgradeListing in component.FullListingsCatalog)
|
2024-02-03 19:48:51 -05:00
|
|
|
{
|
Magic Refactor + Wizard Grimoire (#22568)
* Brings over changes from the original magic refactor PR
* Adds Master Spellbook, spellbook categories, WizCoin currency, and locale
* Wiz€oin™
* Adds currency whitelist to Spellbook preset, grants contained actions on action added.
* Adds grant contained action and remove provided action.
* adds a way for actions to be upgraded to the store
* Adds Fireball 3 and fixes action upgrade logic so that it checks if the action can level or if the action can upgrade separately
* Fixes upgrade logic in ActionUpgradeSystem to allow for level ups without an actual upgrade. Fixed action upgrade logic in store system as well
* Removes current action entity from the bought entities list and adds new or old action entity
* Removes Current Entity
* Removes old comments, fixes TransferAllActionsWithNewAttached
* Removes TODO
* Removes Product Action Upgrade Event
* reverts changes to immovablerodrule
* Removes stale event reference
* fixes mind action grant logic
* reverts shared gun system change to projectile anomaly system
* forgor to remove the using
* Reverts unintended changes to action container
* Adds refund button to the store
* Refreshes store back to origin.
* Refund with correct currency
* Init refund
* Check for terminating and update interface
* Disables refund button
* Removes preset allow refund
* dont refund if map changed
* adds refunds to stores
* Adds method to check for starting map
* comments, datafields, some requested changes
* turns event into ref event
* Adds datafields
* Switches to entity terminating event
* Changes store entity to be nullable and checks if store is terminating to remove reference.
* Tryadd instead of containskey
* Adds a refund disable method, disables refund on bought ent container changes if not an action
* Removes duplicate refundcomp
* Removes unintended merges
* Removed another unintended change from merge
* removes extra using statement
* readds using statement
* might as well just remove both usings since it won't leave the PR
* Fixes Action upgrades from stores
* Changes to non obsolete method uses
* Shares spawn code between instant and world
* Adds action entity to action event, adds beforecastspellevent, adds spell requirements to magic component
* puts prereq check in spell methods, sets up template code for before cast event
* checks for required wizard clothes
* Networks Magic Comp and Wizard Clothes Comp. Renames MagicSpawnData to MagicInstantSpawnData.
* Removes posdata from projectiles
* Speech > RequiresSpeech
* Fixes ActionOnInteract
* checks for muted
* popup for missing reqs
* Validate click loc for blink spell
* Checks if doors are in range and not obstructed before opening
* Check ents by map coords
* Adds speak event
* Comments spellbooks
* Removes comments
* Unobsoletes smite spell
* Invert if
* Requirements loc
* Fixes spell reqs
* Inverts an if
* Comment updates
* Starts doafter work
* Removes doafter references
* Balances fireball upgrades to be more reasonable
* Enables refund on master spellbooks
* Spells to do
* update spellbook doafter
* knock toggles bolts
* Touch Spell comments
* Comments for pending spells
* more comments
* adds spider polymorph to spellbook
* TODOs for spells
* reorganizes spellbook categories and adds wands
* fixes spacing and adds limited conditions
* commented owner only for future store PR
* reenables owner only for the grimoire
* fixes grimoire sprite
* Adds wizard rod polymorph
* summon ghosts event
* Moves rod form to offensive category
* Adds charge spell and loc for rod polymorph
* Oops forgor the actual chages
* Item Recall comment
* Fixes UI
* removes extra field for wizard rod
* Cleanup
* New Condition (INCOMPLETE)
* Fix linter
* Fix linter (for real)
* fixed some descriptions
* adds regions to magic
* Adds a non-refund wizard grimoire, fixes blink to deselect after teleporting, reduces force wall despawn time to 12 seconds
* removes limited upgrade condition
---------
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-05-11 19:06:49 -04:00
|
|
|
if (upgradeListing.ID == listing.ProductUpgradeId)
|
2024-02-03 19:48:51 -05:00
|
|
|
{
|
|
|
|
|
upgradeListing.ProductActionEntity = actionId.Value;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Magic Refactor + Wizard Grimoire (#22568)
* Brings over changes from the original magic refactor PR
* Adds Master Spellbook, spellbook categories, WizCoin currency, and locale
* Wiz€oin™
* Adds currency whitelist to Spellbook preset, grants contained actions on action added.
* Adds grant contained action and remove provided action.
* adds a way for actions to be upgraded to the store
* Adds Fireball 3 and fixes action upgrade logic so that it checks if the action can level or if the action can upgrade separately
* Fixes upgrade logic in ActionUpgradeSystem to allow for level ups without an actual upgrade. Fixed action upgrade logic in store system as well
* Removes current action entity from the bought entities list and adds new or old action entity
* Removes Current Entity
* Removes old comments, fixes TransferAllActionsWithNewAttached
* Removes TODO
* Removes Product Action Upgrade Event
* reverts changes to immovablerodrule
* Removes stale event reference
* fixes mind action grant logic
* reverts shared gun system change to projectile anomaly system
* forgor to remove the using
* Reverts unintended changes to action container
* Adds refund button to the store
* Refreshes store back to origin.
* Refund with correct currency
* Init refund
* Check for terminating and update interface
* Disables refund button
* Removes preset allow refund
* dont refund if map changed
* adds refunds to stores
* Adds method to check for starting map
* comments, datafields, some requested changes
* turns event into ref event
* Adds datafields
* Switches to entity terminating event
* Changes store entity to be nullable and checks if store is terminating to remove reference.
* Tryadd instead of containskey
* Adds a refund disable method, disables refund on bought ent container changes if not an action
* Removes duplicate refundcomp
* Removes unintended merges
* Removed another unintended change from merge
* removes extra using statement
* readds using statement
* might as well just remove both usings since it won't leave the PR
* Fixes Action upgrades from stores
* Changes to non obsolete method uses
* Shares spawn code between instant and world
* Adds action entity to action event, adds beforecastspellevent, adds spell requirements to magic component
* puts prereq check in spell methods, sets up template code for before cast event
* checks for required wizard clothes
* Networks Magic Comp and Wizard Clothes Comp. Renames MagicSpawnData to MagicInstantSpawnData.
* Removes posdata from projectiles
* Speech > RequiresSpeech
* Fixes ActionOnInteract
* checks for muted
* popup for missing reqs
* Validate click loc for blink spell
* Checks if doors are in range and not obstructed before opening
* Check ents by map coords
* Adds speak event
* Comments spellbooks
* Removes comments
* Unobsoletes smite spell
* Invert if
* Requirements loc
* Fixes spell reqs
* Inverts an if
* Comment updates
* Starts doafter work
* Removes doafter references
* Balances fireball upgrades to be more reasonable
* Enables refund on master spellbooks
* Spells to do
* update spellbook doafter
* knock toggles bolts
* Touch Spell comments
* Comments for pending spells
* more comments
* adds spider polymorph to spellbook
* TODOs for spells
* reorganizes spellbook categories and adds wands
* fixes spacing and adds limited conditions
* commented owner only for future store PR
* reenables owner only for the grimoire
* fixes grimoire sprite
* Adds wizard rod polymorph
* summon ghosts event
* Moves rod form to offensive category
* Adds charge spell and loc for rod polymorph
* Oops forgor the actual chages
* Item Recall comment
* Fixes UI
* removes extra field for wizard rod
* Cleanup
* New Condition (INCOMPLETE)
* Fix linter
* Fix linter (for real)
* fixed some descriptions
* adds regions to magic
* Adds a non-refund wizard grimoire, fixes blink to deselect after teleporting, reduces force wall despawn time to 12 seconds
* removes limited upgrade condition
---------
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-05-11 19:06:49 -04:00
|
|
|
if (listing is { ProductUpgradeId: not null, ProductActionEntity: not null })
|
2024-02-03 19:48:51 -05:00
|
|
|
{
|
|
|
|
|
if (listing.ProductActionEntity != null)
|
|
|
|
|
{
|
|
|
|
|
component.BoughtEntities.Remove(listing.ProductActionEntity.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_actionUpgrade.TryUpgradeAction(listing.ProductActionEntity, out var upgradeActionId))
|
|
|
|
|
{
|
|
|
|
|
if (listing.ProductActionEntity != null)
|
|
|
|
|
HandleRefundComp(uid, component, listing.ProductActionEntity.Value);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listing.ProductActionEntity = upgradeActionId;
|
|
|
|
|
|
|
|
|
|
if (upgradeActionId != null)
|
|
|
|
|
HandleRefundComp(uid, component, upgradeActionId.Value);
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (listing.ProductEvent != null)
|
|
|
|
|
{
|
2024-03-24 14:07:05 -04:00
|
|
|
if (!listing.RaiseProductEventOnUser)
|
|
|
|
|
RaiseLocalEvent(listing.ProductEvent);
|
|
|
|
|
else
|
|
|
|
|
RaiseLocalEvent(buyer, listing.ProductEvent);
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
2024-11-17 11:46:31 -05:00
|
|
|
if (listing.DisableRefund)
|
|
|
|
|
{
|
|
|
|
|
component.RefundAllowed = false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
//log dat shit.
|
2024-06-01 11:29:17 -04:00
|
|
|
_admin.Add(LogType.StorePurchase,
|
|
|
|
|
LogImpact.Low,
|
2024-09-29 03:25:21 +03:00
|
|
|
$"{ToPrettyString(buyer):player} purchased listing \"{ListingLocalisationHelpers.GetLocalisedNameOrEntityName(listing, _proto)}\" from {ToPrettyString(uid)}");
|
2022-08-17 00:34:25 -04:00
|
|
|
|
|
|
|
|
listing.PurchaseAmount++; //track how many times something has been purchased
|
2024-04-26 18:16:24 +10:00
|
|
|
_audio.PlayEntity(component.BuySuccessSound, msg.Actor, uid); //cha-ching!
|
2022-08-17 00:34:25 -04:00
|
|
|
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
var buyFinished = new StoreBuyFinishedEvent
|
|
|
|
|
{
|
|
|
|
|
PurchasedItem = listing,
|
|
|
|
|
StoreUid = uid
|
|
|
|
|
};
|
|
|
|
|
RaiseLocalEvent(ref buyFinished);
|
|
|
|
|
|
2023-02-12 07:39:14 -05:00
|
|
|
UpdateUserInterface(buyer, uid, component);
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles dispensing the currency you requested to be withdrawn.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// This would need to be done should a currency with decimal values need to use it.
|
|
|
|
|
/// not quite sure how to handle that
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void OnRequestWithdraw(EntityUid uid, StoreComponent component, StoreRequestWithdrawMessage msg)
|
|
|
|
|
{
|
2024-09-30 01:13:22 +13:00
|
|
|
if (msg.Amount <= 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-08-17 00:34:25 -04:00
|
|
|
//make sure we have enough cash in the bank and we actually support this currency
|
|
|
|
|
if (!component.Balance.TryGetValue(msg.Currency, out var currentAmount) || currentAmount < msg.Amount)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//make sure a malicious client didn't send us random shit
|
|
|
|
|
if (!_proto.TryIndex<CurrencyPrototype>(msg.Currency, out var proto))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//we need an actually valid entity to spawn. This check has been done earlier, but just in case.
|
2022-09-11 02:54:16 -04:00
|
|
|
if (proto.Cash == null || !proto.CanWithdraw)
|
2022-08-17 00:34:25 -04:00
|
|
|
return;
|
|
|
|
|
|
2024-04-26 18:16:24 +10:00
|
|
|
var buyer = msg.Actor;
|
2022-11-08 21:24:23 -05:00
|
|
|
|
2022-09-11 02:54:16 -04:00
|
|
|
FixedPoint2 amountRemaining = msg.Amount;
|
2022-09-14 19:04:41 +12:00
|
|
|
var coordinates = Transform(buyer).Coordinates;
|
2022-09-11 02:54:16 -04:00
|
|
|
|
|
|
|
|
var sortedCashValues = proto.Cash.Keys.OrderByDescending(x => x).ToList();
|
|
|
|
|
foreach (var value in sortedCashValues)
|
2022-08-17 00:34:25 -04:00
|
|
|
{
|
2022-09-11 02:54:16 -04:00
|
|
|
var cashId = proto.Cash[value];
|
2022-11-08 21:24:23 -05:00
|
|
|
var amountToSpawn = (int) MathF.Floor((float) (amountRemaining / value));
|
2023-01-11 17:03:18 -05:00
|
|
|
var ents = _stack.SpawnMultiple(cashId, amountToSpawn, coordinates);
|
2024-09-30 01:13:22 +13:00
|
|
|
if (ents.FirstOrDefault() is {} ent)
|
|
|
|
|
_hands.PickupOrDrop(buyer, ent);
|
2022-09-11 02:54:16 -04:00
|
|
|
amountRemaining -= value * amountToSpawn;
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
component.Balance[msg.Currency] -= msg.Amount;
|
2023-02-12 07:39:14 -05:00
|
|
|
UpdateUserInterface(buyer, uid, component);
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
2024-02-03 19:48:51 -05:00
|
|
|
|
|
|
|
|
private void OnRequestRefund(EntityUid uid, StoreComponent component, StoreRequestRefundMessage args)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Remove guardian/holopara
|
|
|
|
|
|
2024-04-26 18:16:24 +10:00
|
|
|
if (args.Actor is not { Valid: true } buyer)
|
2024-02-03 19:48:51 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!IsOnStartingMap(uid, component))
|
|
|
|
|
{
|
2025-02-15 11:17:29 -05:00
|
|
|
DisableRefund(uid, component);
|
2024-02-03 19:48:51 -05:00
|
|
|
UpdateUserInterface(buyer, uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!component.RefundAllowed || component.BoughtEntities.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-03-19 22:46:03 -04:00
|
|
|
_admin.Add(LogType.StoreRefund, LogImpact.Low, $"{ToPrettyString(buyer):player} has refunded their purchases from {ToPrettyString(uid):store}");
|
|
|
|
|
|
2024-03-17 01:06:17 +11:00
|
|
|
for (var i = component.BoughtEntities.Count - 1; i >= 0; i--)
|
2024-02-03 19:48:51 -05:00
|
|
|
{
|
|
|
|
|
var purchase = component.BoughtEntities[i];
|
|
|
|
|
|
|
|
|
|
if (!Exists(purchase))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
component.BoughtEntities.RemoveAt(i);
|
|
|
|
|
|
2025-05-28 19:52:11 +00:00
|
|
|
_actionContainer.RemoveAction(purchase, logMissing: false);
|
2024-02-03 19:48:51 -05:00
|
|
|
|
2025-06-26 19:50:49 -04:00
|
|
|
Del(purchase);
|
2024-02-03 19:48:51 -05:00
|
|
|
}
|
|
|
|
|
|
2024-03-17 01:06:17 +11:00
|
|
|
component.BoughtEntities.Clear();
|
|
|
|
|
|
2024-02-03 19:48:51 -05:00
|
|
|
foreach (var (currency, value) in component.BalanceSpent)
|
|
|
|
|
{
|
|
|
|
|
component.Balance[currency] += value;
|
|
|
|
|
}
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
|
2024-02-03 19:48:51 -05:00
|
|
|
// Reset store back to its original state
|
|
|
|
|
RefreshAllListings(component);
|
|
|
|
|
component.BalanceSpent = new();
|
|
|
|
|
UpdateUserInterface(buyer, uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleRefundComp(EntityUid uid, StoreComponent component, EntityUid purchase)
|
|
|
|
|
{
|
|
|
|
|
component.BoughtEntities.Add(purchase);
|
|
|
|
|
var refundComp = EnsureComp<StoreRefundComponent>(purchase);
|
|
|
|
|
refundComp.StoreEntity = uid;
|
2025-02-15 11:17:29 -05:00
|
|
|
refundComp.BoughtTime = _timing.CurTime;
|
2024-02-03 19:48:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsOnStartingMap(EntityUid store, StoreComponent component)
|
|
|
|
|
{
|
|
|
|
|
var xform = Transform(store);
|
|
|
|
|
return component.StartingMap == xform.MapUid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Disables refunds for this store
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DisableRefund(EntityUid store, StoreComponent? component = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(store, ref component))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
component.RefundAllowed = false;
|
|
|
|
|
}
|
2022-08-17 00:34:25 -04:00
|
|
|
}
|
feat: #26107 uplink discounts for traitors (no nukies for now) (#26297)
* feat: #26107 uplink discounts for traitors and nukies
* refactor: #26107 extracted discount label from price of StoreListingControl
* refactor: minor renaming
* refactor: parametrized adding discounts to uplink store
* fix: #26107 prevent exception on empty discountOptions
* feat: uplink now have 'Discounted' category which contains all discounted items on this session.
* after merge fixups
* rename discount categories according to common sense
* refactor: DiscountOptions is now optional (nullable) on ListingData
* add nullability check ignore for already checked listingData.DiscountOptions
* fix after merge store menu ui
* remove unused using
* final fix after merge conflicts
* [refactor]: #26107 fix variables naming in UplinkSystem
* fix: #26107 fix after merge
* refactor: #26107 now supports discountDownUntil on ListingItem, instead of % of discount
* feat: #26107 support multiple currency discount in store on side of discount message label
* refactor: #26107 extracted discounts initialization to separate system. StoreDiscountData are spread as array and not list now
* refactor: #26107 move more code from storesystem to StoreDiscountComponent
* refactor: #26107 separated StoreSystem and StoreDiscountSystem using events
* fix: #26107 placed not-nullable variable initialization in ListingData for tests
* refactor: #26107 minor renaming, xml-docs
* fix: #26107 changed most of discounts to be down to half price for balance purposes
* ids used in with discounts are now ProtoIds, dicountCategories are now prototypes, code with weights simplified
* decoupled storesystem and store discount system
* xml-docs
* refactor: #26107 xml-doc for StoreDiscountSystem
* is now a thing (tmp)
* fix: compilation errors + StoreDiscountData.DiscountCategoryId
* refactor: rename ListingDataWithCostModifiers, fix all cost related code, enpittyfy performance, uglify uplink_catalog
* refactor: removed unused code, more StoreDiscountSystem docs, simplify code
* refactor: moved discount category logic to respective system, now creating ListingData c-tor clones all mutable fields as expected
* refactor: rename back (its not prototype)
* refactor: move ListingItemsInitializingEvent to file with handling logic
* refactor: comments for StoreBuyFinishedEvent handling, more logging
* refactor: moved StoreInitializedEvent, xml-doc
* refactor: simplify StoreDiscountSystem code (reduce nesting) + xml-doc
* refactor: restore old listing data cost field name
* refactor: fix linter in uplink_catalog.yml
* refactor: xml-doc for ListingDataWithCostModifiers
* refactor: limit usage of ListingData in favour of ListingDataWithCostModifiers
* refactor: purged linq, removed custom datafield names, minor cleanup
* refactor: removed double-allocation on getting available listings
* refactor: StoreSystem.OnBuyRequest now uses component.FullListingsCatalog as reference point (as it was in original code)
* fix: minor discount categories on uplink items changes following design overview
* refactor: StoreBuyListingMessage now uses protoId and not whole object
* refactor: store refund and discount integration test, RefreshAllListings now translates previous cost modifiers to refreshed list, if state previous to refresh had any listing items
---------
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2024-09-05 15:12:39 +03:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Event of successfully finishing purchase in store (<see cref="StoreSystem"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="StoreUid">EntityUid on which store is placed.</param>
|
|
|
|
|
/// <param name="PurchasedItem">ListingItem that was purchased.</param>
|
|
|
|
|
[ByRefEvent]
|
|
|
|
|
public readonly record struct StoreBuyFinishedEvent(
|
|
|
|
|
EntityUid StoreUid,
|
|
|
|
|
ListingDataWithCostModifiers PurchasedItem
|
|
|
|
|
);
|