Files
OldThink/Content.Server/White/EndOfRoundStats/BloodLost/BloodLostStatSystem.cs
rhailrake 484c8a8d9b stats (#103)
* OH YES

* хули мне хедкодеру
# Conflicts:
#	Content.Server/Instruments/InstrumentComponent.cs
#	Content.Server/Instruments/InstrumentSystem.cs
#	Content.Shared/Cuffs/SharedCuffableSystem.cs
#	Content.Shared/White/WhiteCVars.cs
#	Resources/Prototypes/tags.yml
2024-01-17 19:13:14 +07:00

47 lines
1.2 KiB
C#

using Content.Server.GameTicking;
using Content.Shared.GameTicking;
using Robust.Shared.Configuration;
using Content.Shared.FixedPoint;
using Content.Shared.White;
namespace Content.Server.White.EndOfRoundStats.BloodLost;
public sealed class BloodLostStatSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _config = default!;
FixedPoint2 totalBloodLost = 0;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BloodLostStatEvent>(OnBloodLost);
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEnd);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
}
private void OnBloodLost(BloodLostStatEvent args)
{
totalBloodLost += args.BloodLost;
}
private void OnRoundEnd(RoundEndTextAppendEvent ev)
{
var line = String.Empty;
if (totalBloodLost < _config.GetCVar<float>(WhiteCVars.BloodLostThreshold))
return;
line += $"[color=maroon]{Loc.GetString("eorstats-bloodlost-total", ("bloodLost", totalBloodLost.Int()))}[/color]";
ev.AddLine("\n" + line);
}
private void OnRoundRestart(RoundRestartCleanupEvent ev)
{
totalBloodLost = 0;
}
}