Un-revert IPlayerManager refactor (#21244)

This commit is contained in:
Leon Friedrich
2023-10-28 09:59:53 +11:00
committed by GitHub
parent c55e1dcafd
commit e685cb626b
245 changed files with 781 additions and 943 deletions

View File

@@ -16,6 +16,7 @@ using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Player;
using Robust.Shared.Threading;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -36,7 +37,7 @@ namespace Content.Server.Decals
[Dependency] private readonly MapSystem _mapSystem = default!;
private readonly Dictionary<NetEntity, HashSet<Vector2i>> _dirtyChunks = new();
private readonly Dictionary<IPlayerSession, Dictionary<NetEntity, HashSet<Vector2i>>> _previousSentChunks = new();
private readonly Dictionary<ICommonSession, Dictionary<NetEntity, HashSet<Vector2i>>> _previousSentChunks = new();
private static readonly Vector2 _boundsMinExpansion = new(0.01f, 0.01f);
private static readonly Vector2 _boundsMaxExpansion = new(1.01f, 1.01f);
@@ -197,7 +198,7 @@ namespace Content.Server.Decals
private void OnDecalPlacementRequest(RequestDecalPlacementEvent ev, EntitySessionEventArgs eventArgs)
{
if (eventArgs.SenderSession is not IPlayerSession session)
if (eventArgs.SenderSession is not { } session)
return;
// bad
@@ -226,7 +227,7 @@ namespace Content.Server.Decals
private void OnDecalRemovalRequest(RequestDecalRemovalEvent ev, EntitySessionEventArgs eventArgs)
{
if (eventArgs.SenderSession is not IPlayerSession session)
if (eventArgs.SenderSession is not { } session)
return;
// bad
@@ -427,7 +428,7 @@ namespace Content.Server.Decals
if (PvsEnabled)
{
var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
var players = _playerManager.Sessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount };
Parallel.ForEach(players, opts, UpdatePlayer);
}
@@ -435,7 +436,7 @@ namespace Content.Server.Decals
_dirtyChunks.Clear();
}
public void UpdatePlayer(IPlayerSession player)
public void UpdatePlayer(ICommonSession player)
{
var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, _chunkIndexPool, _chunkViewerPool);
var staleChunks = _chunkViewerPool.Get();
@@ -530,7 +531,7 @@ namespace Content.Server.Decals
}
private void SendChunkUpdates(
IPlayerSession session,
ICommonSession session,
Dictionary<NetEntity, HashSet<Vector2i>> updatedChunks,
Dictionary<NetEntity, HashSet<Vector2i>> staleChunks)
{