2021-11-15 18:14:34 +00:00
|
|
|
using Content.Server.Mind.Components;
|
|
|
|
|
using Content.Shared.GameTicking;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Mind
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This is absolutely evil.
|
|
|
|
|
/// It tracks all mind changes and logs all the Mind objects.
|
|
|
|
|
/// This is so that when round end comes around, there's a coherent list of all Minds that were in play during the round.
|
|
|
|
|
/// The Minds themselves contain metadata about their owners.
|
|
|
|
|
/// Anyway, this is because disconnected people and ghost roles have been breaking round end statistics for way too long.
|
|
|
|
|
/// </summary>
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class MindTrackerSystem : EntitySystem
|
2021-11-15 18:14:34 +00:00
|
|
|
{
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public readonly HashSet<Mind> AllMinds = new();
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
2023-06-18 11:33:19 -07:00
|
|
|
SubscribeLocalEvent<MindContainerComponent, MindAddedMessage>(OnMindAdded);
|
2021-11-15 18:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Reset(RoundRestartCleanupEvent ev)
|
|
|
|
|
{
|
|
|
|
|
AllMinds.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 11:33:19 -07:00
|
|
|
void OnMindAdded(EntityUid uid, MindContainerComponent mc, MindAddedMessage args)
|
2021-11-15 18:14:34 +00:00
|
|
|
{
|
|
|
|
|
var mind = mc.Mind;
|
|
|
|
|
if (mind != null)
|
|
|
|
|
AllMinds.Add(mind);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|