Make the round end summary use recursive PVS overrides (#19083)
This commit is contained in:
@@ -7,7 +7,6 @@ using Content.Shared.GameTicking;
|
|||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Prometheus;
|
using Prometheus;
|
||||||
using Robust.Server.GameStates;
|
|
||||||
using Robust.Server.Maps;
|
using Robust.Server.Maps;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -46,22 +45,6 @@ namespace Content.Server.GameTicking
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private bool _startingRound;
|
private bool _startingRound;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is a list of players that are going to appear in the round-end
|
|
||||||
/// crew manifest so their children entities can be collected each update
|
|
||||||
/// and sent to far-away players.
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables]
|
|
||||||
private HashSet<EntityUid> _expandPvsPlayers = new();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is the list of the children entities that should be sent to
|
|
||||||
/// all players at the end of the round, to keep distant characters from
|
|
||||||
/// looking naked in the crew manifest.
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables]
|
|
||||||
private HashSet<EntityUid> _expandPvsEntities = new();
|
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private GameRunLevel _runLevel;
|
private GameRunLevel _runLevel;
|
||||||
|
|
||||||
@@ -81,16 +64,6 @@ namespace Content.Server.GameTicking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeRoundFlow()
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<ExpandPvsEvent>(OnExpandPvs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEntityDeleted(EntityUid uid)
|
|
||||||
{
|
|
||||||
_expandPvsEntities.Remove(uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if the round's map is eligible to be updated.
|
/// Returns true if the round's map is eligible to be updated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -332,14 +305,6 @@ namespace Content.Server.GameTicking
|
|||||||
ShowRoundEndScoreboard(text);
|
ShowRoundEndScoreboard(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExpandPvs(ref ExpandPvsEvent args)
|
|
||||||
{
|
|
||||||
if (RunLevel != GameRunLevel.PostRound)
|
|
||||||
return;
|
|
||||||
|
|
||||||
args.Entities.AddRange(_expandPvsEntities);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowRoundEndScoreboard(string text = "")
|
public void ShowRoundEndScoreboard(string text = "")
|
||||||
{
|
{
|
||||||
// Log end of round
|
// Log end of round
|
||||||
@@ -357,11 +322,6 @@ namespace Content.Server.GameTicking
|
|||||||
//Get the timespan of the round.
|
//Get the timespan of the round.
|
||||||
var roundDuration = RoundDuration();
|
var roundDuration = RoundDuration();
|
||||||
|
|
||||||
// Should already be empty, but just in case.
|
|
||||||
_expandPvsEntities.Clear();
|
|
||||||
_expandPvsPlayers.Clear();
|
|
||||||
EntityManager.EntityDeleted += OnEntityDeleted;
|
|
||||||
|
|
||||||
//Generate a list of basic player info to display in the end round summary.
|
//Generate a list of basic player info to display in the end round summary.
|
||||||
var listOfPlayerInfo = new List<RoundEndMessageEvent.RoundEndPlayerInfo>();
|
var listOfPlayerInfo = new List<RoundEndMessageEvent.RoundEndPlayerInfo>();
|
||||||
// Grab the great big book of all the Minds, we'll need them for this.
|
// Grab the great big book of all the Minds, we'll need them for this.
|
||||||
@@ -395,8 +355,9 @@ namespace Content.Server.GameTicking
|
|||||||
else if (mind.CurrentEntity != null && TryName(mind.CurrentEntity.Value, out var icName))
|
else if (mind.CurrentEntity != null && TryName(mind.CurrentEntity.Value, out var icName))
|
||||||
playerIcName = icName;
|
playerIcName = icName;
|
||||||
|
|
||||||
if (Exists(mind.OriginalOwnedEntity))
|
var entity = mind.OriginalOwnedEntity;
|
||||||
_expandPvsPlayers.Add(mind.OriginalOwnedEntity.Value);
|
if (Exists(entity))
|
||||||
|
_pvsOverride.AddGlobalOverride(entity.Value, recursive: true);
|
||||||
|
|
||||||
var playerEndRoundInfo = new RoundEndMessageEvent.RoundEndPlayerInfo()
|
var playerEndRoundInfo = new RoundEndMessageEvent.RoundEndPlayerInfo()
|
||||||
{
|
{
|
||||||
@@ -405,7 +366,7 @@ namespace Content.Server.GameTicking
|
|||||||
PlayerOOCName = contentPlayerData?.Name ?? "(IMPOSSIBLE: REGISTERED MIND WITH NO OWNER)",
|
PlayerOOCName = contentPlayerData?.Name ?? "(IMPOSSIBLE: REGISTERED MIND WITH NO OWNER)",
|
||||||
// Character name takes precedence over current entity name
|
// Character name takes precedence over current entity name
|
||||||
PlayerICName = playerIcName,
|
PlayerICName = playerIcName,
|
||||||
PlayerEntityUid = mind.OriginalOwnedEntity,
|
PlayerEntityUid = entity,
|
||||||
Role = antag
|
Role = antag
|
||||||
? mind.AllRoles.First(role => role.Antagonist).Name
|
? mind.AllRoles.First(role => role.Antagonist).Name
|
||||||
: mind.AllRoles.FirstOrDefault()?.Name ?? Loc.GetString("game-ticker-unknown-role"),
|
: mind.AllRoles.FirstOrDefault()?.Name ?? Loc.GetString("game-ticker-unknown-role"),
|
||||||
@@ -416,20 +377,6 @@ namespace Content.Server.GameTicking
|
|||||||
listOfPlayerInfo.Add(playerEndRoundInfo);
|
listOfPlayerInfo.Add(playerEndRoundInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively collect entities for the crew manifest.
|
|
||||||
void RecursePvsEntities(IEnumerable<EntityUid> entities)
|
|
||||||
{
|
|
||||||
_expandPvsEntities.UnionWith(entities);
|
|
||||||
|
|
||||||
foreach (var entity in entities)
|
|
||||||
{
|
|
||||||
if (TryComp<TransformComponent>(entity, out var xform))
|
|
||||||
RecursePvsEntities(xform.ChildEntities);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RecursePvsEntities(_expandPvsPlayers);
|
|
||||||
|
|
||||||
// This ordering mechanism isn't great (no ordering of minds) but functions
|
// This ordering mechanism isn't great (no ordering of minds) but functions
|
||||||
var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray();
|
var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray();
|
||||||
|
|
||||||
@@ -527,10 +474,6 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
_allPreviousGameRules.Clear();
|
_allPreviousGameRules.Clear();
|
||||||
|
|
||||||
EntityManager.EntityDeleted -= OnEntityDeleted;
|
|
||||||
_expandPvsPlayers.Clear();
|
|
||||||
_expandPvsEntities.Clear();
|
|
||||||
|
|
||||||
// Round restart cleanup event, so entity systems can reset.
|
// Round restart cleanup event, so entity systems can reset.
|
||||||
var ev = new RoundRestartCleanupEvent();
|
var ev = new RoundRestartCleanupEvent();
|
||||||
RaiseLocalEvent(ev);
|
RaiseLocalEvent(ev);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using Content.Shared.Mobs.Systems;
|
|||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
using Robust.Server;
|
using Robust.Server;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Server.GameStates;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
#if EXCEPTION_TOLERANCE
|
#if EXCEPTION_TOLERANCE
|
||||||
@@ -40,6 +41,7 @@ namespace Content.Server.GameTicking
|
|||||||
[Dependency] private readonly MindSystem _mind = default!;
|
[Dependency] private readonly MindSystem _mind = default!;
|
||||||
[Dependency] private readonly MindTrackerSystem _mindTracker = default!;
|
[Dependency] private readonly MindTrackerSystem _mindTracker = default!;
|
||||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||||
|
[Dependency] private readonly PvsOverrideSystem _pvsOverride = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogs = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogs = default!;
|
||||||
|
|
||||||
[ViewVariables] private bool _initialized;
|
[ViewVariables] private bool _initialized;
|
||||||
@@ -70,7 +72,6 @@ namespace Content.Server.GameTicking
|
|||||||
"Overflow role does not have the correct name!");
|
"Overflow role does not have the correct name!");
|
||||||
InitializeGameRules();
|
InitializeGameRules();
|
||||||
InitializeReplays();
|
InitializeReplays();
|
||||||
InitializeRoundFlow();
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user