fix discount

This commit is contained in:
Spatison
2025-02-28 19:59:30 +03:00
parent edb7da67be
commit f22f9c2a7c
3 changed files with 8 additions and 2 deletions

View File

@@ -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
/// <inheritdoc />
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<StoreComponent>(uid, out var store) || component.Discounts.Count != 0)
if (!TryComp<StoreComponent>(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

View File

@@ -24,6 +24,9 @@ public sealed partial class StoreDiscountComponent : Component
[DataField]
public int MaxItems = 8;
[DataField]
public bool OnSpawn;
// WD EDIT END
}

View File

@@ -75,6 +75,7 @@
Telecrystal: 0
# WD EDIT START
- type: StoreDiscount
onSpawn: true
- type: GiftIgnore
# WD EDIT END