-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5ddcec
commit 9f3b949
Showing
32 changed files
with
1,208 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Content.Server/SimpleStation14/EndOfRoundStats/BloodLost/BloodLostStatEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Content.Server.SimpleStation14.EndOfRoundStats.BloodLost; | ||
|
||
public sealed class BloodLostStatEvent : EntityEventArgs | ||
{ | ||
public float BloodLost; | ||
|
||
public BloodLostStatEvent(float bloodLost) | ||
{ | ||
BloodLost = bloodLost; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Content.Server/SimpleStation14/EndOfRoundStats/BloodLost/BloodLostStatSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Content.Server.GameTicking; | ||
using Content.Shared.GameTicking; | ||
using Robust.Shared.Configuration; | ||
using Content.Shared.SimpleStation14.CCVar; | ||
using Content.Shared.FixedPoint; | ||
|
||
namespace Content.Server.SimpleStation14.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>(SimpleStationCCVars.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; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Content.Server/SimpleStation14/EndOfRoundStats/Command/CommandStatSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Content.Server.GameTicking; | ||
using Content.Shared.GameTicking; | ||
|
||
namespace Content.Server.SimpleStation14.EndOfRoundStats.Command; | ||
|
||
public sealed class CommandStatSystem : EntitySystem | ||
{ | ||
public List<(string, string)> eorStats = new(); | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEnd); | ||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart); | ||
} | ||
|
||
private void OnRoundEnd(RoundEndTextAppendEvent ev) | ||
{ | ||
foreach (var (stat, color) in eorStats) | ||
{ | ||
ev.AddLine($"[color={color}]{stat}[/color]"); | ||
} | ||
} | ||
|
||
private void OnRoundRestart(RoundRestartCleanupEvent ev) | ||
{ | ||
eorStats.Clear(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
Content.Server/SimpleStation14/EndOfRoundStats/Command/EORStatsAddCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Linq; | ||
using Content.Server.Administration; | ||
using Content.Shared.Administration; | ||
using Content.Shared.Administration.Logs; | ||
using Content.Shared.Database; | ||
using Robust.Shared.Console; | ||
|
||
namespace Content.Server.SimpleStation14.EndOfRoundStats.Command; | ||
|
||
[AdminCommand(AdminFlags.Admin)] | ||
public sealed class EORStatsAddCommmand : IConsoleCommand | ||
{ | ||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; | ||
|
||
public string Command => "eorstatsadd"; | ||
public string Description => "Adds an end of round stat to be displayed."; | ||
public string Help => $"Usage: {Command} <stat> <color?>"; | ||
|
||
public void Execute(IConsoleShell shell, string argStr, string[] args) | ||
{ | ||
var _stats = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<CommandStatSystem>(); | ||
|
||
if (args.Length < 1 || args.Length > 2) | ||
{ | ||
shell.WriteError("Invalid amount of arguments."); | ||
return; | ||
} | ||
|
||
if (args.Length == 2 && !Color.TryFromName(args[1], out _)) | ||
{ | ||
shell.WriteError("Invalid color."); | ||
return; | ||
} | ||
|
||
_stats.eorStats.Add((args[0], args.Length == 2 ? args[1] : "Green")); | ||
|
||
shell.WriteLine($"Added {args[0]} to end of round stats."); | ||
|
||
_adminLogger.Add(LogType.AdminMessage, LogImpact.Low, | ||
$"{shell.Player!.Name} added '{args[0]}' to end of round stats."); | ||
} | ||
|
||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) | ||
{ | ||
if (args.Length == 1) | ||
{ | ||
return CompletionResult.FromHint("<Stat>"); | ||
} | ||
|
||
if (args.Length == 2) | ||
{ | ||
var options = Color.GetAllDefaultColors().Select(o => new CompletionOption(o.Key)); | ||
|
||
return CompletionResult.FromHintOptions(options, "<Color?>"); | ||
} | ||
|
||
return CompletionResult.Empty; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Content.Server/SimpleStation14/EndOfRoundStats/Command/EORStatsListCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Content.Server.Administration; | ||
using Content.Shared.Administration; | ||
using Robust.Shared.Console; | ||
|
||
namespace Content.Server.SimpleStation14.EndOfRoundStats.Command; | ||
|
||
[AdminCommand(AdminFlags.Admin)] | ||
public sealed class EORStatsCommand : IConsoleCommand | ||
{ | ||
public string Command => "eorstatslist"; | ||
public string Description => "Lists the current command-added end of round stats to be displayed."; | ||
public string Help => $"Usage: {Command}"; | ||
|
||
public void Execute(IConsoleShell shell, string argStr, string[] args) | ||
{ | ||
var _stats = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<CommandStatSystem>(); | ||
|
||
if (args.Length != 0) | ||
{ | ||
shell.WriteError("Invalid amount of arguments."); | ||
return; | ||
} | ||
|
||
if (_stats.eorStats.Count == 0) | ||
{ | ||
shell.WriteLine("No command-added end of round stats to display."); | ||
return; | ||
} | ||
|
||
shell.WriteLine("End of round stats:"); | ||
|
||
foreach (var (stat, color) in _stats.eorStats) | ||
{ | ||
shell.WriteLine($"'{stat}' - {color}"); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
Content.Server/SimpleStation14/EndOfRoundStats/Command/EROStatsRemoveCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System.Linq; | ||
using Content.Server.Administration; | ||
using Content.Shared.Administration; | ||
using Robust.Shared.Console; | ||
|
||
namespace Content.Server.SimpleStation14.EndOfRoundStats.Command; | ||
|
||
[AdminCommand(AdminFlags.Admin)] | ||
public sealed class EORStatsRemoveCommand : IConsoleCommand | ||
{ | ||
public string Command => "eorstatsremove"; | ||
public string Description => "Removes a previously added end of round stat. Defaults to last added stat."; | ||
public string Help => $"Usage: {Command} <stat index?>"; | ||
|
||
public void Execute(IConsoleShell shell, string argStr, string[] args) | ||
{ | ||
var _stats = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<CommandStatSystem>(); | ||
|
||
if (args.Length > 1) | ||
{ | ||
shell.WriteError("Invalid amount of arguments."); | ||
return; | ||
} | ||
|
||
if (_stats.eorStats.Count == 0) | ||
{ | ||
shell.WriteError("No stats to remove."); | ||
return; | ||
} | ||
|
||
int index = _stats.eorStats.Count; | ||
|
||
if (args.Length == 1) | ||
{ | ||
if (!int.TryParse(args[0], out index)) | ||
{ | ||
shell.WriteError("Invalid index."); | ||
return; | ||
} | ||
|
||
if (index < 0 || index > _stats.eorStats.Count) | ||
{ | ||
shell.WriteError("Index out of range."); | ||
return; | ||
} | ||
} | ||
|
||
index--; | ||
|
||
shell.WriteLine($"Removed '{_stats.eorStats[index].Item1}' from end of round stats."); | ||
|
||
_stats.eorStats.RemoveAt(index); | ||
} | ||
|
||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) | ||
{ | ||
var _stats = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<CommandStatSystem>(); | ||
|
||
if (args.Length == 1) | ||
{ | ||
var options = _stats.eorStats.Select(o => new CompletionOption | ||
((_stats.eorStats.LastIndexOf((o.Item1, o.Item2)) + 1).ToString(), o.Item1)); | ||
|
||
if (options.Count() == 0) | ||
return CompletionResult.FromHint("No stats to remove."); | ||
|
||
return CompletionResult.FromOptions(options); | ||
} | ||
|
||
return CompletionResult.Empty; | ||
} | ||
} |
Oops, something went wrong.