Files
wwdpublic/Content.Server/Cargo/Components/StationStockMarketComponent.cs
sleepyyapril 1e423cabf9 v245.0.0 (and Storage UI V2) (#1799)
Contains:

- Storage UI v2, required for removing DeferredClose.
- Stock market refactor (mostly some basic changes to stock market,
didn't want to make a whole other PR for it)
- Make guidebook remember where you left off
- Any other PRs are purely for fixing issues related to the above PRs or
the engine update.

🆑
- add: Ported Storage UI v2.
- tweak: The guidebook will now remember where you left off.

---------

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: 12rabbits <53499656+12rabbits@users.noreply.github.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Co-authored-by: gluesniffler <159397573+gluesniffler@users.noreply.github.com>
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
(cherry picked from commit 3c37ff1c48637d1cdf8bc3c6b1412dad338ea205)
2025-02-28 16:22:37 +03:00

65 lines
2.1 KiB
C#

using System.Numerics;
using Content.Server.DeltaV.Cargo.Systems;
using Content.Server.DeltaV.CartridgeLoader.Cartridges;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Timing;
namespace Content.Server.DeltaV.Cargo.Components;
[RegisterComponent, AutoGenerateComponentPause]
[Access(typeof(StockMarketSystem), typeof(StockTradingCartridgeSystem))]
public sealed partial class StationStockMarketComponent : Component
{
/// <summary>
/// The list of companies you can invest in
/// </summary>
[DataField]
public List<StockCompany> Companies = [];
/// <summary>
/// The list of shares owned by the station
/// </summary>
[DataField]
public Dictionary<int, int> StockOwnership = new();
/// <summary>
/// The interval at which the stock market updates
/// </summary>
[DataField]
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(600); // 10 minutes
/// <summary>
/// The <see cref="IGameTiming.CurTime"/> timespan of next update.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextUpdate = TimeSpan.Zero;
/// <summary>
/// The sound to play after selling or buying stocks
/// </summary>
[DataField]
public SoundSpecifier ConfirmSound = new SoundPathSpecifier("/Audio/Effects/Cargo/ping.ogg");
/// <summary>
/// The sound to play if the don't have access to buy or sell stocks
/// </summary>
[DataField]
public SoundSpecifier DenySound = new SoundPathSpecifier("/Audio/Effects/Cargo/buzz_sigh.ogg");
// These work well as presets but can be changed in the yaml
[DataField]
public List<MarketChange> MarketChanges =
[
new(0.86f, new Vector2(-0.05f, 0.05f)), // Minor
new(0.10f, new Vector2(-0.3f, 0.2f)), // Moderate
new(0.03f, new Vector2(-0.5f, 1.5f)), // Major
new(0.01f, new Vector2(-0.9f, 4.0f)), // Catastrophic
];
}
[DataRecord]
public record struct MarketChange(float Chance, Vector2 Range);