From f22f9c2a7c4e2890aef460af5533152f848969de Mon Sep 17 00:00:00 2001
From: Spatison <137375981+Spatison@users.noreply.github.com>
Date: Fri, 28 Feb 2025 19:59:30 +0300
Subject: [PATCH] fix discount
---
Content.Server/StoreDiscount/Systems/StoreDiscountSystem.cs | 6 ++++--
.../StoreDiscount/Components/StoreDiscountComponent.cs | 3 +++
.../Prototypes/Entities/Objects/Specific/syndicate.yml | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Content.Server/StoreDiscount/Systems/StoreDiscountSystem.cs b/Content.Server/StoreDiscount/Systems/StoreDiscountSystem.cs
index f76948f12a..987e657ec3 100644
--- a/Content.Server/StoreDiscount/Systems/StoreDiscountSystem.cs
+++ b/Content.Server/StoreDiscount/Systems/StoreDiscountSystem.cs
@@ -20,6 +20,7 @@ public sealed class StoreDiscountSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+ [Dependency] private readonly StoreSystem _store = default!; // WD EDIT
///
public override void Initialize()
@@ -75,14 +76,15 @@ public sealed class StoreDiscountSystem : EntitySystem
// WD EDIT START
private void OnMapInit(EntityUid uid, StoreDiscountComponent component, MapInitEvent args)
{
- if (!TryComp(uid, out var store) || component.Discounts.Count != 0)
+ if (!TryComp(uid, out var store) || !component.OnSpawn)
return;
var uplinkInitializedEvent = new StoreInitializedEvent(
TargetUser: uid,
Store: uid,
UseDiscounts: true,
- Listings: store.FullListingsCatalog.ToArray());
+ Listings: _store.GetAvailableListings(uid, uid, store)
+ .ToArray());
RaiseLocalEvent(ref uplinkInitializedEvent);
}
// WD EDIT END
diff --git a/Content.Shared/StoreDiscount/Components/StoreDiscountComponent.cs b/Content.Shared/StoreDiscount/Components/StoreDiscountComponent.cs
index 2c159f5843..86259cdfb6 100644
--- a/Content.Shared/StoreDiscount/Components/StoreDiscountComponent.cs
+++ b/Content.Shared/StoreDiscount/Components/StoreDiscountComponent.cs
@@ -24,6 +24,9 @@ public sealed partial class StoreDiscountComponent : Component
[DataField]
public int MaxItems = 8;
+
+ [DataField]
+ public bool OnSpawn;
// WD EDIT END
}
diff --git a/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml b/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml
index 99095bf191..994f2b9947 100644
--- a/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml
+++ b/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml
@@ -75,6 +75,7 @@
Telecrystal: 0
# WD EDIT START
- type: StoreDiscount
+ onSpawn: true
- type: GiftIgnore
# WD EDIT END