Ghost roles create new minds, better tracking of roles at round end screen (#5175)
* Ghost roles now get new Minds
* Some round start/end button stuff
* Mind tracking for better round end reports
* Make traitor kill objectives use mind CharacterName rather than actual occupied entity ("kill brain" prevention)
* Transition over to EntityUid for mind stuff because that's the only way to do it
* BrainSystem fix for PR rebase
This commit is contained in:
46
Content.Server/Mind/MindTrackerSystem.cs
Normal file
46
Content.Server/Mind/MindTrackerSystem.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
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>
|
||||
public class MindTrackerSystem : EntitySystem
|
||||
{
|
||||
[ViewVariables]
|
||||
public readonly HashSet<Mind> AllMinds = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||
SubscribeLocalEvent<MindComponent, MindAddedMessage>(OnMindAdded);
|
||||
}
|
||||
|
||||
void Reset(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
AllMinds.Clear();
|
||||
}
|
||||
|
||||
void OnMindAdded(EntityUid uid, MindComponent mc, MindAddedMessage args)
|
||||
{
|
||||
var mind = mc.Mind;
|
||||
if (mind != null)
|
||||
AllMinds.Add(mind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user