Files
crystall-punk-14/Content.Server/_CP14/Trading/CP14StationEconomySystem.cs
Red cde388f5dd Another Merchant gameplay attempt (#1308)
* setup UI

* setup debug data

* graph control setup

* reputation trade component

* unlocking logic

* smoe real reputation costing

* remove sponsors part, add trading specific UI nodes

* port to default pricing system

* buy cooldown

* fuck off trading cabinets

* real good cooldown UI

* Cool unlock sound

* reputation earning

* cool purchare sound

* coin & sprite work

* delete old guidebooks

* cool purcharing VFX

* better ui

* victoria gardens

* Update migration.yml

* Update migration.yml

* cooldown removed

* contracts

* Update migration.yml

* remove CP14Material

* materials appraise

* food appraise

* auto economy pricing system

* alchemy reagents appraise

* coins resprite

* alchemy appraise 2

* modular weapon appraise

* selling platform

* Update PricingSystem.cs

* Update CP14TradingPlatformSystem.cs

* merchants returns + map update

* Update CP14StationEconomySystem.Price.cs
2025-05-29 00:22:47 +03:00

55 lines
1.8 KiB
C#

using Content.Server.Cargo.Systems;
using Content.Server.Station.Events;
using Content.Shared._CP14.Trading.BuyServices;
using Content.Shared._CP14.Trading.Components;
using Content.Shared._CP14.Trading.Prototypes;
using Content.Shared._CP14.Trading.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server._CP14.Trading;
public sealed partial class CP14StationEconomySystem : CP14SharedStationEconomySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly PricingSystem _price = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
InitPriceEvents();
SubscribeLocalEvent<CP14StationEconomyComponent, StationPostInitEvent>(OnStationPostInit);
}
private void OnStationPostInit(Entity<CP14StationEconomyComponent> ent, ref StationPostInitEvent args)
{
UpdatePricing(ent);
}
private void UpdatePricing(Entity<CP14StationEconomyComponent> ent)
{
ent.Comp.Pricing.Clear();
foreach (var trade in _proto.EnumeratePrototypes<CP14TradingPositionPrototype>())
{
double price = 0;
switch (trade.Service)
{
case CP14BuyItemsService buyItems:
if (!_proto.TryIndex(buyItems.Product, out var indexedProduct))
break;
price += _price.GetEstimatedPrice(indexedProduct) * buyItems.Count;
break;
}
price += trade.PriceMarkup;
//Random fluctuation
price *= 1 + _random.NextFloat(trade.PriceFluctuation);
ent.Comp.Pricing.TryAdd(trade, (int) price);
}
Dirty(ent);
}
}