Skip to content

Commit 221b8c7

Browse files
committed
IT'S FINALLY REAL
1 parent 599d0c9 commit 221b8c7

File tree

7 files changed

+49
-8
lines changed

7 files changed

+49
-8
lines changed

Content.Server/DeltaV/Cargo/Components/StationStockMarketComponent.cs

+20-4
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,39 @@ public sealed partial class StationStockMarketComponent : Component
2121
DisplayName = "Nanotrasen [NT]",
2222
CurrentPrice = 100f,
2323
BasePrice = 100f,
24-
PriceHistory = [100f, 100f, 100f, 100f, 100f], // look somewhere else
24+
PriceHistory = [],
2525
},
2626
["Gorlex"] = new StockCompanyStruct
2727
{
2828
Name = "Gorlex",
2929
DisplayName = "Gorlex [GRX]",
3030
CurrentPrice = 75f,
3131
BasePrice = 75f,
32-
PriceHistory = [75f, 75f, 75f, 75f, 75f],
32+
PriceHistory = [],
33+
},
34+
["Interdyne"] = new StockCompanyStruct
35+
{
36+
Name = "Interdyne",
37+
DisplayName = "Interdyne Pharmaceuticals [INTP]",
38+
CurrentPrice = 300f,
39+
BasePrice = 300f,
40+
PriceHistory = [],
3341
},
3442
["FishInc"] = new StockCompanyStruct
3543
{
3644
Name = "FishInc",
3745
DisplayName = "Fish Inc. [FIN]",
3846
CurrentPrice = 25f,
3947
BasePrice = 25f,
40-
PriceHistory = [25f, 25f, 25f, 25f, 25f],
48+
PriceHistory = [],
49+
},
50+
["Donk"] = new StockCompanyStruct
51+
{
52+
Name = "Donk",
53+
DisplayName = "Donk Co. [DONK]",
54+
CurrentPrice = 90f,
55+
BasePrice = 90f,
56+
PriceHistory = [90f, 90f, 90f, 90f, 90f],
4157
},
4258
};
4359

@@ -51,7 +67,7 @@ public sealed partial class StationStockMarketComponent : Component
5167
/// The interval at which the stock market updates
5268
/// </summary>
5369
[DataField]
54-
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(10); // 5 minutes
70+
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(600); // 10 minutes
5571

5672
/// <summary>
5773
/// The <see cref="IGameTiming.CurTime"/> timespan of next update.

Content.Server/DeltaV/Cargo/StocksCommands.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
8181
DisplayName = displayName,
8282
CurrentPrice = basePrice,
8383
BasePrice = basePrice,
84-
PriceHistory = [basePrice, basePrice, basePrice, basePrice, basePrice],
84+
PriceHistory = [],
8585
};
8686

8787
var stockMarket = _entitySystemManager.GetEntitySystem<StockMarketSystem>();

Content.Server/DeltaV/Cargo/Systems/StockMarketSystem.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ public override void Initialize()
4343
_sawmill = _log.GetSawmill("admin.stock_market");
4444

4545
SubscribeLocalEvent<StockTradingCartridgeComponent, CartridgeMessageEvent>(OnStockTradingMessage);
46+
SubscribeLocalEvent<StationStockMarketComponent, ComponentInit>(OnInit);
47+
}
48+
49+
private static void OnInit(Entity<StationStockMarketComponent> ent, ref ComponentInit args)
50+
{
51+
foreach (var company in ent.Comp.Companies.Values)
52+
{
53+
UpdatePriceHistory(company);
54+
}
4655
}
4756

4857
public override void Update(float frameTime)
@@ -369,11 +378,18 @@ public bool TryAddCompany(EntityUid station,
369378

370379
private static void UpdatePriceHistory(StockCompanyStruct company)
371380
{
381+
// Make sure it has at least 5 entries
382+
while (company.PriceHistory.Count < 5)
383+
{
384+
company.PriceHistory.Add(company.BasePrice);
385+
}
386+
387+
372388
// Store previous price in history
373389
company.PriceHistory.Add(company.CurrentPrice);
374390

375391
if (company.PriceHistory.Count > 5) // Keep last 5 prices
376-
company.PriceHistory.RemoveAt(0);
392+
company.PriceHistory.RemoveAt(1); // Always keep the base price
377393
}
378394

379395
private StockChangeType DetermineChangeType(StationStockMarketComponent stockMarket)

Resources/Prototypes/DeltaV/Entities/Objects/Devices/cartridges.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
components:
6969
- type: Sprite
7070
sprite: DeltaV/Objects/Devices/cartridge.rsi
71-
state: cart-mail
71+
state: cart-stonk
7272
- type: Icon
7373
sprite: DeltaV/Objects/Devices/cartridge.rsi
7474
state: cart-mail

Resources/Prototypes/Entities/Objects/Devices/pda.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@
398398
- NotekeeperCartridge
399399
- NewsReaderCartridge
400400
- MailMetricsCartridge # DeltaV - MailMetrics courier tracker
401-
- StockTradingCartridge # DeltaV - StockTrading for the LO
401+
- StockTradingCartridge # DeltaV - StockTrading
402402

403403
- type: entity
404404
parent: BasePDA
@@ -413,6 +413,12 @@
413413
borderColor: "#e39751"
414414
- type: Icon
415415
state: pda-cargo
416+
- type: CartridgeLoader # DeltaV
417+
preinstalled:
418+
- CrewManifestCartridge
419+
- NotekeeperCartridge
420+
- NewsReaderCartridge
421+
- StockTradingCartridge # DeltaV - StockTrading
416422

417423
- type: entity
418424
parent: BasePDA
Loading

Resources/Textures/DeltaV/Objects/Devices/cartridge.rsi/meta.json

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
},
1616
{
1717
"name": "cart-psi"
18+
},
19+
{
20+
"name": "cart-stonk"
1821
}
1922
]
2023
}

0 commit comments

Comments
 (0)