mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Expand PVS event (#2287)
This commit is contained in:
committed by
GitHub
parent
8e5eb6ebbb
commit
7b1bb7df47
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user