Expand PVS event (#2287)

This commit is contained in:
Pieter-Jan Briers
2021-11-28 23:43:05 +01:00
committed by GitHub
parent 8e5eb6ebbb
commit 7b1bb7df47
2 changed files with 47 additions and 1 deletions

View File

@@ -258,10 +258,10 @@ namespace Robust.Server.GameStates
IncludeMapCriticalEntities(visibleEnts);
// if you don't have an attached entity, you don't see the world.
var chunksSeen = _playerChunks[session];
if (session.AttachedEntityUid is not null)
{
var viewers = GetSessionViewers(session);
var chunksSeen = _playerChunks[session];
foreach (var eyeEuid in viewers)
{
@@ -305,6 +305,35 @@ namespace Robust.Server.GameStates
_viewerEntsPool.Return(viewers);
}
var expandEvent = new ExpandPvsEvent((IPlayerSession) session, new List<EntityUid>());
RaiseLocalEvent(ref expandEvent);
if (expandEvent.Entities.Count > 0)
{
var includedChunks = _includedChunksPool.Get();
const uint visMask = uint.MaxValue;
foreach (var expanded in expandEvent.Entities)
{
RecursiveAdd(expanded, visibleEnts, includedChunks, chunksSeen, visMask);
}
GetAnchoredEntityStates(includedChunks, visibleEnts, visMask, chunksSeen, session, entityStates, fromTick);
/*// To fix pop-in we'll go through nearby chunks and send them little-by-little
StreamChunks(newChunkCount, session, chunksSeen, entityStates, viewBox, fromTick, mapId);
*/
foreach (var (_, chunks) in includedChunks)
{
chunks.Clear();
_chunkPool.Return(chunks);
}
includedChunks.Clear();
_includedChunksPool.Return(includedChunks);
}
deletions = GetDeletedEntities(fromTick);
GenerateEntityStates(entityStates, session, fromTick, visibleEnts, deletions);
@@ -680,4 +709,16 @@ namespace Robust.Server.GameStates
}
}
public readonly struct ExpandPvsEvent
{
public readonly IPlayerSession Session;
public readonly List<EntityUid> Entities;
public ExpandPvsEvent(IPlayerSession session, List<EntityUid> entities)
{
Session = session;
Entities = entities;
}
}
}

View File

@@ -58,6 +58,11 @@ namespace Robust.Shared.GameObjects
EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
}
protected void RaiseLocalEvent<T>(ref T message) where T : notnull
{
EntityManager.EventBus.RaiseEvent(EventSource.Local, ref message);
}
protected void RaiseLocalEvent(object message)
{
EntityManager.EventBus.RaiseEvent(EventSource.Local, message);