Skip to content

Commit f1aef2e

Browse files
authored
Статистика конца раунда (#239)
1 parent d28db84 commit f1aef2e

File tree

22 files changed

+1079
-3
lines changed

22 files changed

+1079
-3
lines changed

Content.Client/RoundEnd/RoundEndSummaryUIController.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public sealed class RoundEndSummaryUIController : UIController,
1414
IOnSystemLoaded<ClientGameTicker>
1515
{
1616
[Dependency] private readonly IInputManager _input = default!;
17+
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
1718

1819
private RoundEndSummaryWindow? _window;
1920

@@ -40,7 +41,7 @@ public void OpenRoundEndSummaryWindow(RoundEndMessageEvent message)
4041
return;
4142

4243
_window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText,
43-
message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, EntityManager);
44+
message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, message.RoundEndStats, message.StatisticEntries, EntityManager, _playerManager); // Sunrise-Edit
4445
}
4546

4647
public void OnSystemLoaded(ClientGameTicker system)

Content.Client/RoundEnd/RoundEndSummaryWindow.cs

+80-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System.Linq;
22
using System.Numerics;
3+
using Content.Client._Sunrise.StatsBoard;
34
using Content.Client.Message;
5+
using Content.Shared._Sunrise.StatsBoard;
46
using Content.Shared.GameTicking;
57
using Robust.Client.UserInterface.Controls;
68
using Robust.Client.UserInterface.CustomControls;
9+
using Robust.Shared.Player;
710
using Robust.Shared.Utility;
811
using static Robust.Client.UserInterface.Controls.BoxContainer;
912

@@ -12,14 +15,16 @@ namespace Content.Client.RoundEnd
1215
public sealed class RoundEndSummaryWindow : DefaultWindow
1316
{
1417
private readonly IEntityManager _entityManager;
18+
private readonly ISharedPlayerManager _playerManager;
1519
public int RoundId;
1620

1721
public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan, int roundId,
18-
RoundEndMessageEvent.RoundEndPlayerInfo[] info, IEntityManager entityManager)
22+
RoundEndMessageEvent.RoundEndPlayerInfo[] info, string roundEndStats, StatisticEntry[] statisticEntries, IEntityManager entityManager, ISharedPlayerManager playerManager) // Sunrise-Edit
1923
{
2024
_entityManager = entityManager;
25+
_playerManager = playerManager; // Sunrise-Edit
2126

22-
MinSize = SetSize = new Vector2(520, 580);
27+
MinSize = SetSize = new Vector2(700, 600); // Sunrise-Edit
2328

2429
Title = Loc.GetString("round-end-summary-window-title");
2530

@@ -31,6 +36,8 @@ public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan,
3136

3237
RoundId = roundId;
3338
var roundEndTabs = new TabContainer();
39+
roundEndTabs.AddChild(MakeRoundEndStatsTab(roundEndStats)); // Sunrise-End
40+
roundEndTabs.AddChild(MakeRoundEndMyStatsTab(statisticEntries)); // Sunrise-End
3441
roundEndTabs.AddChild(MakeRoundEndSummaryTab(gm, roundEnd, roundTimeSpan, roundId));
3542
roundEndTabs.AddChild(MakePlayerManifestTab(info));
3643

@@ -166,6 +173,77 @@ private BoxContainer MakePlayerManifestTab(RoundEndMessageEvent.RoundEndPlayerIn
166173

167174
return playerManifestTab;
168175
}
176+
177+
// Sunrise-Start
178+
private BoxContainer MakeRoundEndStatsTab(string stats)
179+
{
180+
var roundEndSummaryTab = new BoxContainer
181+
{
182+
Orientation = LayoutOrientation.Vertical,
183+
Name = Loc.GetString("round-end-summary-window-stats-tab-title")
184+
};
185+
186+
var roundEndSummaryContainerScrollbox = new ScrollContainer
187+
{
188+
VerticalExpand = true,
189+
Margin = new Thickness(10)
190+
};
191+
var roundEndSummaryContainer = new BoxContainer
192+
{
193+
Orientation = LayoutOrientation.Vertical
194+
};
195+
196+
//Round end text
197+
if (!string.IsNullOrEmpty(stats))
198+
{
199+
var statsLabel = new RichTextLabel();
200+
statsLabel.SetMarkup(stats);
201+
roundEndSummaryContainer.AddChild(statsLabel);
202+
}
203+
204+
roundEndSummaryContainerScrollbox.AddChild(roundEndSummaryContainer);
205+
roundEndSummaryTab.AddChild(roundEndSummaryContainerScrollbox);
206+
207+
return roundEndSummaryTab;
208+
}
209+
210+
private BoxContainer MakeRoundEndMyStatsTab(StatisticEntry[] statisticEntries)
211+
{
212+
var roundEndSummaryTab = new BoxContainer
213+
{
214+
Orientation = LayoutOrientation.Vertical,
215+
Name = Loc.GetString("round-end-summary-window-my-stats-tab-title")
216+
};
217+
218+
var roundEndSummaryContainerScrollbox = new ScrollContainer
219+
{
220+
VerticalExpand = true,
221+
Margin = new Thickness(10),
222+
};
223+
224+
var statsEntries = new StatsEntries();
225+
foreach (var statisticEntry in statisticEntries)
226+
{
227+
if (statisticEntry.FirstActor != _playerManager.LocalSession!.UserId)
228+
continue;
229+
230+
var statsEntry = new StatsEntry(statisticEntry.Name, statisticEntry.TotalTakeDamage,
231+
statisticEntry.TotalTakeHeal, statisticEntry.TotalInflictedDamage,
232+
statisticEntry.TotalInflictedHeal, statisticEntry.SlippedCount,
233+
statisticEntry.CreamedCount, statisticEntry.DoorEmagedCount, statisticEntry.ElectrocutedCount,
234+
statisticEntry.CuffedCount, statisticEntry.AbsorbedPuddleCount, statisticEntry.SpentTk ?? 0,
235+
statisticEntry.DeadCount, statisticEntry.HumanoidKillCount, statisticEntry.KilledMouseCount,
236+
statisticEntry.CuffedTime, statisticEntry.SpaceTime, statisticEntry.SleepTime,
237+
statisticEntry.IsInteractedCaptainCard ? "Да" : "Нет");
238+
statsEntries.AddEntry(statsEntry);
239+
}
240+
241+
roundEndSummaryContainerScrollbox.AddChild(statsEntries);
242+
roundEndSummaryTab.AddChild(roundEndSummaryContainerScrollbox);
243+
244+
return roundEndSummaryTab;
245+
}
246+
// Sunrise-End
169247
}
170248

171249
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<BoxContainer xmlns="https://spacestation14.io"
2+
Margin="0 0 0 0"
3+
HorizontalExpand="True"
4+
Visible="True">
5+
<BoxContainer Name="EntriesContainer"
6+
Orientation="Vertical"
7+
StyleClasses="transparentItemList"
8+
VerticalExpand="True"
9+
HorizontalExpand="True"/>
10+
</BoxContainer>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Robust.Client.AutoGenerated;
2+
using Robust.Client.UserInterface.Controls;
3+
using Robust.Client.UserInterface.XAML;
4+
5+
namespace Content.Client._Sunrise.StatsBoard;
6+
7+
[GenerateTypedNameReferences]
8+
public sealed partial class StatsEntries : BoxContainer
9+
{
10+
public StatsEntries()
11+
{
12+
RobustXamlLoader.Load(this);
13+
IoCManager.InjectDependencies(this);
14+
}
15+
16+
public void AddEntry(StatsEntry entry)
17+
{
18+
EntriesContainer.AddChild(entry);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<BoxContainer xmlns="https://spacestation14.io"
2+
Margin="10 10 10 0"
3+
HorizontalExpand="True"
4+
Visible="True">
5+
<PanelContainer StyleClasses="AngleRect" HorizontalExpand="True">
6+
<BoxContainer Orientation="Vertical" HorizontalExpand="True" HorizontalAlignment="Left">
7+
<BoxContainer Orientation="Horizontal" >
8+
<Label Text="Персонаж: " StyleClasses="LabelKeyText"/>
9+
<RichTextLabel Name="NameLabel"/>
10+
</BoxContainer>
11+
<RichTextLabel Name="StatsLabel"/>
12+
</BoxContainer>
13+
</PanelContainer>
14+
</BoxContainer>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using Content.Client.Message;
2+
using Robust.Client.AutoGenerated;
3+
using Robust.Client.UserInterface.Controls;
4+
using Robust.Client.UserInterface.XAML;
5+
6+
namespace Content.Client._Sunrise.StatsBoard;
7+
8+
[GenerateTypedNameReferences]
9+
public sealed partial class StatsEntry : BoxContainer
10+
{
11+
public StatsEntry(string entityName, float takeDamage, float takeHeal, float inflictedDamage, float inflictedHeal,
12+
float slippedCount, float creamedCount, float doorEmagedCount, float electrocutedCount, float cuffedCount,
13+
float absorbedPuddleCount, int spentTk, float deadCount, float humanoidKillCount, float killedMouseCount,
14+
TimeSpan cuffedTime, TimeSpan spaceTime, TimeSpan sleepTime, string interactedCaptainCard)
15+
{
16+
RobustXamlLoader.Load(this);
17+
IoCManager.InjectDependencies(this);
18+
19+
NameLabel.SetMarkup($"{entityName}");
20+
var statsText = "";
21+
22+
if (takeDamage > 0)
23+
statsText += $"Получил урона: {takeDamage}\n";
24+
if (takeHeal > 0)
25+
statsText += $"Получил лечения: {takeHeal}\n";
26+
if (inflictedDamage > 0)
27+
statsText += $"Нанес урона: {inflictedDamage}\n";
28+
if (inflictedHeal > 0)
29+
statsText += $"Вылечил урона: {inflictedHeal}\n";
30+
if (slippedCount > 0)
31+
statsText += $"Подскользнулся {slippedCount} раз\n";
32+
if (creamedCount > 0)
33+
statsText += $"Кремирован {creamedCount} раз\n";
34+
if (doorEmagedCount > 0)
35+
statsText += $"Емагнул {doorEmagedCount} дверей\n";
36+
if (electrocutedCount > 0)
37+
statsText += $"Шокирован {electrocutedCount} раз\n";
38+
if (cuffedCount > 0)
39+
statsText += $"Закован {cuffedCount} раз\n";
40+
if (absorbedPuddleCount > 0)
41+
statsText += $"Убрано {absorbedPuddleCount} луж\n";
42+
if (spentTk > 0)
43+
statsText += $"Потрачено {spentTk} ТК\n";
44+
if (deadCount > 0)
45+
statsText += $"Погиб {deadCount} раз\n";
46+
if (humanoidKillCount > 0)
47+
statsText += $"Убил {humanoidKillCount} гуманоидов\n";
48+
if (killedMouseCount > 0)
49+
statsText += $"Убито мышей {killedMouseCount}\n";
50+
if (cuffedTime > TimeSpan.Zero)
51+
statsText += $"Был в наручниках [color=yellow]{cuffedTime.ToString("hh\\:mm\\:ss")}[/color]\n";
52+
if (spaceTime > TimeSpan.Zero)
53+
statsText += $"Был в космосе [color=yellow]{spaceTime.ToString("hh\\:mm\\:ss")}[/color]\n";
54+
if (sleepTime > TimeSpan.Zero)
55+
statsText += $"Проспал [color=yellow]{sleepTime.ToString("hh\\:mm\\:ss")}[/color]\n";
56+
57+
statsText += $"Трогал карту капитана: {interactedCaptainCard}";
58+
59+
StatsLabel.SetMarkup($"{statsText}");
60+
}
61+
}

Content.Server/Construction/ConstructionSystem.Initial.cs

+5
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ public async Task<bool> TryStartItemConstruction(string prototype, EntityUid use
395395
Transform(user).Coordinates) is not { Valid: true } item)
396396
return false;
397397

398+
// Sunrise-Start
399+
var ev = new ItemConstructionCreated(item);
400+
RaiseLocalEvent(user, ref ev);
401+
// Sunrise-End
402+
398403
// Just in case this is a stack, attempt to merge it. If it isn't a stack, this will just normally pick up
399404
// or drop the item as normal.
400405
_stackSystem.TryMergeToHands(item, user);

Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs

+5
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ private bool TryPuddleInteract(EntityUid user, EntityUid used, EntityUid target,
323323

324324
_melee.DoLunge(user, used, Angle.Zero, localPos, null, false);
325325

326+
// Sunrise-Start
327+
var ev = new AbsorberPudleEvent(user);
328+
RaiseLocalEvent(user, ref ev);
329+
// Sunrise-End
330+
326331
return true;
327332
}
328333
}

Content.Server/GameTicking/GameTicker.RoundFlow.cs

+9
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
using Robust.Shared.Player;
2121
using Robust.Shared.Random;
2222
using Robust.Shared.Utility;
23+
using Content.Server.StatsBoard;
2324

2425
namespace Content.Server.GameTicking
2526
{
2627
public sealed partial class GameTicker
2728
{
2829
[Dependency] private readonly DiscordWebhook _discord = default!;
2930
[Dependency] private readonly ITaskManager _taskManager = default!;
31+
[Dependency] private readonly StatsBoardSystem _statsBoardSystem = default!;
3032

3133
private static readonly Counter RoundNumberMetric = Metrics.CreateCounter(
3234
"ss14_round_number",
@@ -428,13 +430,20 @@ public void ShowRoundEndScoreboard(string text = "")
428430
var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray();
429431
var sound = RoundEndSoundCollection == null ? null : _audio.GetSound(new SoundCollectionSpecifier(RoundEndSoundCollection));
430432

433+
// Sunrise-Start
434+
var roundStats = _statsBoardSystem.GetRoundStats();
435+
var statisticEntries = _statsBoardSystem.GetStatisticEntries();
436+
// Sunrise-End
437+
431438
var roundEndMessageEvent = new RoundEndMessageEvent(
432439
gamemodeTitle,
433440
roundEndText,
434441
roundDuration,
435442
RoundId,
436443
listOfPlayerInfoFinal.Length,
437444
listOfPlayerInfoFinal,
445+
roundStats, // Sunrise-Edit
446+
statisticEntries, // Sunrise-Edit
438447
sound
439448
);
440449
RaiseNetworkEvent(roundEndMessageEvent);

Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs

+10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ protected override void CreamedEntity(EntityUid uid, CreamPiedComponent creamPie
9696
{
9797
otherPlayers.RemovePlayer(actor.PlayerSession);
9898
}
99+
100+
// Sunrise-Start
101+
var ev = new CreamedEvent(args.Target);
102+
RaiseLocalEvent(args.Target, ref ev);
103+
// Sunrise-End
104+
99105
_popup.PopupEntity(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", uid), ("thrower", args.Thrown)), uid, otherPlayers, false);
100106
}
101107

@@ -105,3 +111,7 @@ private void OnRejuvenate(Entity<CreamPiedComponent> entity, ref RejuvenateEvent
105111
}
106112
}
107113
}
114+
115+
// Sunrise-Edit
116+
[ByRefEvent]
117+
public readonly record struct CreamedEvent(EntityUid Target);

0 commit comments

Comments
 (0)