Skip to content

Commit 7dda531

Browse files
authored
Merge branch 'Starlight' into starlight-dev
2 parents 7723a72 + 20210e1 commit 7dda531

7 files changed

Lines changed: 113 additions & 31 deletions

File tree

Content.Server/GameTicking/Rules/DragonRuleSystem.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,25 @@
66
using Content.Server.Station.Components;
77
using Content.Server.Station.Systems;
88
using Content.Shared.CharacterInfo;
9+
using Content.Shared.Devour.Components;
910
using Content.Shared.Localizations;
11+
using Content.Shared.Mobs;
12+
using Content.Shared.Mobs.Components;
13+
using Prometheus;
1014
using Robust.Server.GameObjects;
1115

1216
namespace Content.Server.GameTicking.Rules;
1317

1418
public sealed class DragonRuleSystem : GameRuleSystem<DragonRuleComponent>
1519
{
20+
#region Starlight
21+
private static readonly Histogram _dragonWinInfo = Metrics.CreateHistogram(
22+
"sl_dragon_winning",
23+
"Contains info on if a dragon won and if so how hard they won",
24+
["alive", "rifts", "eaten"]
25+
);
26+
#endregion
27+
1628
[Dependency] private readonly TransformSystem _transform = default!;
1729
[Dependency] private readonly AntagSelectionSystem _antag = default!;
1830
[Dependency] private readonly StationSystem _station = default!;
@@ -31,7 +43,7 @@ private void UpdateBriefing(Entity<DragonRoleComponent> entity, ref GetBriefingE
3143
{
3244
var ent = args.Mind.Comp.OwnedEntity;
3345

34-
if(ent is null)
46+
if (ent is null)
3547
return;
3648

3749
args.Append(MakeBriefing(ent.Value));
@@ -44,7 +56,7 @@ private void AfterAntagEntitySelected(Entity<DragonRuleComponent> ent, ref After
4456

4557
_roleSystem.MindHasRole<DragonRoleComponent>(mindId, out var dragonRole);
4658

47-
if(dragonRole is null)
59+
if (dragonRole is null)
4860
return;
4961

5062
_antag.SendBriefing(args.EntityUid, MakeBriefing(args.EntityUid), null, null);
@@ -74,4 +86,25 @@ private string MakeBriefing(EntityUid dragon)
7486

7587
return briefing;
7688
}
89+
90+
#region Starlight data collection
91+
private void OnRoundEnded(RoundEndTextAppendEvent _)
92+
{
93+
var query = EntityManager.AllEntities<DragonComponent>();
94+
foreach (var dragon in query)
95+
{
96+
var devoured = 0;
97+
if (TryComp<DevourerComponent>(dragon.Owner, out var devour))
98+
devoured = devour.Devoured;
99+
var alive = false;
100+
if (TryComp<MobStateComponent>(dragon.Owner, out var state))
101+
alive = state.CurrentState == MobState.Alive;
102+
_dragonWinInfo.WithLabels([
103+
alive.ToString(),
104+
dragon.Comp.Rifts?.ToString() ?? "0",
105+
devoured.ToString()
106+
]);
107+
}
108+
}
109+
#endregion
77110
}

Content.Server/Materials/MaterialReclaimerSystem.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ public override void Reclaim(EntityUid uid,
205205
else
206206
{
207207
SpawnChemicalsFromComposition(uid, item, completion, true, component, xform);
208-
}
209-
//Starlight
210-
if (!ev.Handled)
208+
//Starlight
211209
QueueDel(item);
212-
//Starlight
210+
//Starlight
211+
}
212+
213213
}
214214

215215
private void SpawnMaterialsFromComposition(EntityUid reclaimer,

Content.Server/Store/Systems/StoreSystem.Ui.cs

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@
2222
using Robust.Shared.Audio.Systems;
2323
using Robust.Shared.Player;
2424
using Robust.Shared.Prototypes;
25+
using Prometheus; //Starlight
26+
2527

2628
namespace Content.Server.Store.Systems;
2729

2830
public sealed partial class StoreSystem
2931
{
32+
#region Starlight
33+
private static readonly Gauge _storePurchasesMetric = Metrics.CreateGauge(
34+
"sl_store_purchases",
35+
"Everything bounght from a \"store\" which include ling upgrades, traitor uplinks, wizard grimoires",
36+
["store_name", "purchased_item"]
37+
);
38+
#endregion
39+
3040
[Dependency] private readonly IAdminLogManager _admin = default!;
3141
[Dependency] private readonly SharedHandsSystem _hands = default!;
3242
[Dependency] private readonly ActionsSystem _actions = default!;
@@ -83,17 +93,17 @@ public void CloseUi(EntityUid uid, StoreComponent? component = null)
8393
_ui.CloseUi(uid, StoreUiKey.Key);
8494
}
8595

86-
/// <summary>
87-
/// STARLIGHT: Updates the user interface for a store and refreshes the listings
88-
/// </summary>
89-
/// <param name="user">The person who if opening the store ui. Listings are filtered based on this.</param>
90-
/// <param name="store">The store entity itself</param>
91-
/// <param name="component">The store component being refreshed.</param>
92-
public void UpdateUserInterface(EntityUid? user, EntityUid store, StoreComponent? component = null)
96+
/// <summary>
97+
/// STARLIGHT: Updates the user interface for a store and refreshes the listings
98+
/// </summary>
99+
/// <param name="user">The person who if opening the store ui. Listings are filtered based on this.</param>
100+
/// <param name="store">The store entity itself</param>
101+
/// <param name="component">The store component being refreshed.</param>
102+
public void UpdateUserInterface(EntityUid? user, EntityUid store, StoreComponent? component = null)
93103
{
94104
if (!Resolve(store, ref component))
95105
return;
96-
106+
97107
// STARLIGHT: Check if a rift has been destroyed and update the listing accordingly
98108
// This ensures the rift listing remains unavailable even when the UI is refreshed
99109
_revSupplyRift.CheckRiftDestroyedAndUpdateListing(component);
@@ -149,11 +159,11 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
149159
}
150160

151161
var buyer = msg.Actor;
152-
162+
153163
// STARLIGHT: Raise an event to allow other systems to potentially cancel this purchase
154164
var purchaseAttemptEvent = new StorePurchaseAttemptEvent(listing.ID, uid, buyer);
155165
RaiseLocalEvent(ref purchaseAttemptEvent);
156-
166+
157167
// STARLIGHT: If the event handler requested cancellation, cancel the purchase
158168
if (purchaseAttemptEvent.Cancel)
159169
return;
@@ -171,7 +181,7 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
171181
if (!conditionsMet)
172182
return;
173183
}
174-
184+
175185
// Starlight: Check if the listing is unavailable (e.g., out of stock)
176186
// We still want to show the listing in the UI, but prevent purchase
177187
if (listing.Unavailable)
@@ -288,13 +298,13 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
288298
//log dat shit.
289299
// Starlight: Get the resolved name without any placeholders
290300
var resolvedName = ListingLocalisationHelpers.GetLocalisedNameOrEntityName(listing, _proto);
291-
301+
292302
// Remove any stock count or "Out of Stock" text for the log
293303
if (resolvedName.Contains(" ("))
294304
{
295305
resolvedName = resolvedName.Substring(0, resolvedName.IndexOf(" ("));
296306
}
297-
307+
298308
_admin.Add(LogType.StorePurchase,
299309
LogImpact.Low,
300310
$"{ToPrettyString(buyer):player} purchased listing \"{resolvedName}\" from {ToPrettyString(uid)}"); // Starlight
@@ -315,7 +325,7 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
315325
{
316326
buyerName = metadata.EntityName;
317327
}
318-
328+
319329
// Update the stock count and last purchaser
320330
StockLimitedListingCondition.OnItemPurchased(listing.ID, buyerName, stockCondition.StockLimit);
321331
break;
@@ -324,20 +334,20 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
324334
}
325335

326336
// STARLIGHT END
327-
337+
328338
var buyFinished = new StoreBuyFinishedEvent
329339
{
330340
PurchasedItem = listing,
331341
StoreUid = uid
332342
};
333343
RaiseLocalEvent(ref buyFinished);
334-
344+
335345
// STARLIGHT: Raise an event to notify other systems that a purchase was completed
336346
var purchaseCompletedEvent = new StorePurchaseCompletedEvent(listing.ID, uid, buyer);
337347
RaiseLocalEvent(ref purchaseCompletedEvent);
338348

339349
UpdateUserInterface(buyer, uid, component);
340-
350+
341351
// STARLIGHT START: If this was a stock-limited item, update all USSP uplink UIs
342352
if (listing.Conditions != null)
343353
{
@@ -350,8 +360,15 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
350360
}
351361
}
352362
}
363+
364+
#region Starlight statistics
365+
_storePurchasesMetric.WithLabels([
366+
ToPrettyString(uid),
367+
resolvedName
368+
]).Inc();
369+
#endregion
353370
}
354-
371+
355372
/// <summary>
356373
/// Updates all USSP uplink UIs to ensure they show the latest stock counts and last purchaser information.
357374
/// </summary>
@@ -364,25 +381,25 @@ public void UpdateAllUSSPUplinkUIs()
364381
// Skip if this is not a USSP uplink
365382
if (!storeComp.CurrencyWhitelist.Contains("Telebond"))
366383
continue;
367-
384+
368385
// Refresh all listings to ensure they have the latest stock count and last purchaser information
369386
RefreshAllListings(storeComp);
370-
387+
371388
// Force a refresh of the available listings
372389
if (storeComp.AccountOwner != null)
373390
{
374391
storeComp.LastAvailableListings = GetAvailableListings(storeComp.AccountOwner.Value, storeComp.Owner, storeComp)
375392
.ToHashSet();
376393
}
377-
394+
378395
// Update the UI to reflect the changes
379396
// We'll just update it with a null user to ensure the listings are refreshed
380397
// The next time someone opens the UI, they'll see the updated listings
381398
UpdateUserInterface(null, storeComp.Owner, storeComp);
382-
399+
383400
// Force update the UI for all currently connected sessions
384401
ForceUpdateUiForAllSessions(storeComp.Owner, storeComp);
385-
402+
386403
Logger.DebugS("store", $"Updated USSP uplink UI for {ToPrettyString(storeComp.Owner)}");
387404
}
388405
}
@@ -460,9 +477,9 @@ private void OnRequestWithdraw(EntityUid uid, StoreComponent component, StoreReq
460477
foreach (var value in sortedCashValues)
461478
{
462479
var cashId = proto.Cash[value];
463-
var amountToSpawn = (int) MathF.Floor((float) (amountRemaining / value));
480+
var amountToSpawn = (int)MathF.Floor((float)(amountRemaining / value));
464481
var ents = _stack.SpawnMultiple(cashId, amountToSpawn, coordinates);
465-
if (ents.FirstOrDefault() is {} ent)
482+
if (ents.FirstOrDefault() is { } ent)
466483
_hands.PickupOrDrop(buyer, ent);
467484
amountRemaining -= value * amountToSpawn;
468485
}

Content.Shared/Devour/Components/DevourerComponent.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,14 @@ public sealed partial class DevourerComponent : Component
111111
[DataField, AutoNetworkedField]
112112
public float HealRate = 15f;
113113

114+
#region Starlight
115+
116+
/// <summary>
117+
/// how many people (things that grant reward chem) were eaten
118+
/// </summary>
119+
[ViewVariables]
120+
public int Devoured = 0;
121+
#endregion
122+
114123
}
115124

Content.Shared/Devour/DevourSystem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ private void OnDoAfter(Entity<DevourerComponent> ent, ref DevourDoAfterEvent arg
109109
if (args.Args.Target != null && _whitelistSystem.IsWhitelistPassOrNull(ent.Comp.FoodPreferenceWhitelist, (EntityUid)args.Args.Target))
110110
{
111111
_bloodstreamSystem.TryAddToChemicals(ent.Owner, ichorInjection);
112+
ent.Comp.Devoured++; //Starlight devour counter.
112113
}
113114

114115
// If the devoured thing meets the stomach whitelist criteria, add it to the stomach

Resources/Changelog/ChangelogStarlight.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11458,6 +11458,27 @@ Entries:
1145811458
id: 1528
1145911459
time: '2025-08-11T21:13:32.000000+00:00'
1146011460
url: https://github.com/ss14Starlight/space-station-14/pull/1306
11461+
- author: Arkanic
11462+
changes:
11463+
- message: recycler dupe
11464+
type: Fix
11465+
id: 133600
11466+
time: '2025-08-14T03:42:38.000000+00:00'
11467+
url: https://github.com/ss14Starlight/space-station-14/pull/1336
11468+
- author: Trep_Maul
11469+
changes:
11470+
- message: Leth to Map pool
11471+
type: Add
11472+
id: 134500
11473+
time: '2025-08-14T19:52:34.000000+00:00'
11474+
url: https://github.com/ss14Starlight/space-station-14/pull/1345
11475+
- author: walksanatora
11476+
changes:
11477+
- message: Added dragon consumption and uplink purchase statistics tracking
11478+
type: Add
11479+
id: 133900
11480+
time: '2025-08-14T20:07:43.000000+00:00'
11481+
url: https://github.com/ss14Starlight/space-station-14/pull/1339
1146111482
- author: CrazyPhantom
1146211483
changes:
1146311484
- message: Zookeeper name displaying wrong

Resources/Prototypes/_StarLight/Maps/Pools/default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- StarlightFland
1010
- StarlightHotel
1111
- Lagan
12+
- Leth
1213
- Lobster
1314
- Manor
1415
- StarlightOasis

0 commit comments

Comments
 (0)