mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Pause entities that leave PVS range (#5878)
* Pause entities that leave PVS range * Fix merge --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -651,19 +651,30 @@ public abstract partial class SharedTransformSystem
|
||||
if (newMapId == ent.Comp1.MapID)
|
||||
return;
|
||||
|
||||
EntityUid? newMap = newMapId == MapId.Nullspace ? null : _map.GetMap(newMapId);
|
||||
var mapPaused = _map.IsPaused(newMapId);
|
||||
EntityUid? newUid = newMapId == MapId.Nullspace ? null : _map.GetMap(newMapId);
|
||||
bool? mapPaused = null;
|
||||
|
||||
ChangeMapIdRecursive(ent, newMap, newMapId, mapPaused);
|
||||
// Client may be moving entities across maps due to things leaving or entering PVS range.
|
||||
// In that case, we don't want to pause or unpause entities.
|
||||
if (!_gameTiming.ApplyingState)
|
||||
{
|
||||
mapPaused = _map.IsPaused(newMapId);
|
||||
_metaData.SetEntityPaused(ent.Owner, mapPaused.Value, ent.Comp2);
|
||||
}
|
||||
|
||||
ChangeMapIdRecursive(ent, newUid, newMapId, mapPaused);
|
||||
}
|
||||
|
||||
private void ChangeMapIdRecursive(
|
||||
Entity<TransformComponent, MetaDataComponent> ent,
|
||||
EntityUid? newMap,
|
||||
MapId newMapId,
|
||||
bool paused)
|
||||
bool? paused)
|
||||
{
|
||||
_metaData.SetEntityPaused(ent.Owner, paused, ent.Comp2);
|
||||
if (paused is { } p)
|
||||
{
|
||||
_metaData.SetEntityPaused(ent.Owner, p, ent.Comp2);
|
||||
}
|
||||
|
||||
if ((ent.Comp2.Flags & MetaDataFlags.ExtraTransformEvents) != 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user