private int _thresholds;
- private bool _pvsEnabled;
-
public override void Initialize()
{
base.Initialize();
_confMan.OnValueChanged(CVars.NetPVS, OnPvsToggle, true);
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
- SubscribeLocalEvent<GasTileOverlayComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<GasTileOverlayComponent, ComponentStartup>(OnStartup);
}
private void OnPvsToggle(bool value)
{
- if (value == _pvsEnabled)
+ if (value == PvsEnabled)
return;
- _pvsEnabled = value;
+ PvsEnabled = value;
if (value)
return;
// First, update per-chunk visual data for any invalidated tiles.
UpdateOverlayData(curTick);
- if (!_pvsEnabled)
+ if (!PvsEnabled)
return;
// Now we'll go through each player, then through each chunk in range of that player checking if the player is still in range
data.Clear();
}
}
-
- private void OnGetState(EntityUid uid, GasTileOverlayComponent component, ref ComponentGetState args)
- {
- if (_pvsEnabled && !args.ReplayState)
- return;
-
- // Should this be a full component state or a delta-state?
- if (args.FromTick <= component.CreationTick || args.FromTick <= component.ForceTick)
- {
- args.State = new GasTileOverlayState(component.Chunks);
- return;
- }
-
- var data = new Dictionary<Vector2i, GasOverlayChunk>();
- foreach (var (index, chunk) in component.Chunks)
- {
- if (chunk.LastUpdate >= args.FromTick)
- data[index] = chunk;
- }
-
- args.State = new GasTileOverlayState(data) { AllChunks = new(component.Chunks.Keys) };
- }
}
}
private ObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>> _chunkViewerPool =
new DefaultObjectPool<Dictionary<EntityUid, HashSet<Vector2i>>>(
new DefaultPooledObjectPolicy<Dictionary<EntityUid, HashSet<Vector2i>>>(), 64);
- private bool _pvsEnabled;
public override void Initialize()
{
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
- SubscribeLocalEvent<DecalGridComponent, ComponentGetState>(OnGetState);
SubscribeNetworkEvent<RequestDecalPlacementEvent>(OnDecalPlacementRequest);
SubscribeNetworkEvent<RequestDecalRemovalEvent>(OnDecalRemovalRequest);
private void OnPvsToggle(bool value)
{
- if (value == _pvsEnabled)
+ if (value == PvsEnabled)
return;
- _pvsEnabled = value;
+ PvsEnabled = value;
if (value)
return;
}
}
- private void OnGetState(EntityUid uid, DecalGridComponent component, ref ComponentGetState args)
- {
- if (_pvsEnabled && !args.ReplayState)
- return;
-
- // Should this be a full component state or a delta-state?
- if (args.FromTick <= component.CreationTick || args.FromTick <= component.ForceTick)
- {
- args.State = new DecalGridState(component.ChunkCollection.ChunkCollection);
- return;
- }
-
- var data = new Dictionary<Vector2i, DecalChunk>();
- foreach (var (index, chunk) in component.ChunkCollection.ChunkCollection)
- {
- if (chunk.LastModified >= args.FromTick)
- data[index] = chunk;
- }
-
- args.State = new DecalGridState(data) { AllChunks = new(component.ChunkCollection.ChunkCollection.Keys) };
- }
-
private void OnGridSplit(ref PostGridSplitEvent ev)
{
if (!TryComp(ev.OldGrid, out DecalGridComponent? oldComp))
Dirty(decals);
}
- if (!_pvsEnabled)
+ if (!PvsEnabled)
{
_dirtyChunks.Clear();
return;
}
- if (_pvsEnabled)
+ if (PvsEnabled)
{
var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount };
+using Content.Shared.Atmos.Components;
using Content.Shared.Atmos.Prototypes;
+using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
{
public const byte ChunkSize = 8;
protected float AccumulatedFrameTime;
+ protected bool PvsEnabled;
[Dependency] protected readonly IPrototypeManager ProtoMan = default!;
public override void Initialize()
{
base.Initialize();
+ SubscribeLocalEvent<GasTileOverlayComponent, ComponentGetState>(OnGetState);
List<int> visibleGases = new();
VisibleGasId = visibleGases.ToArray();
}
+ private void OnGetState(EntityUid uid, GasTileOverlayComponent component, ref ComponentGetState args)
+ {
+ if (PvsEnabled && !args.ReplayState)
+ return;
+
+ // Should this be a full component state or a delta-state?
+ if (args.FromTick <= component.CreationTick || args.FromTick <= component.ForceTick)
+ {
+ args.State = new GasTileOverlayState(component.Chunks);
+ return;
+ }
+
+ var data = new Dictionary<Vector2i, GasOverlayChunk>();
+ foreach (var (index, chunk) in component.Chunks)
+ {
+ if (chunk.LastUpdate >= args.FromTick)
+ data[index] = chunk;
+ }
+
+ args.State = new GasTileOverlayState(data) { AllChunks = new(component.Chunks.Keys) };
+ }
+
public static Vector2i GetGasChunkIndices(Vector2i indices)
{
return new((int) MathF.Floor((float) indices.X / ChunkSize), (int) MathF.Floor((float) indices.Y / ChunkSize));
using System.Diagnostics.CodeAnalysis;
+using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
[Dependency] protected readonly IMapManager MapManager = default!;
+ protected bool PvsEnabled;
+
// Note that this constant is effectively baked into all map files, because of how they save the grid decal component.
// So if this ever needs changing, the maps need converting.
public const int ChunkSize = 32;
SubscribeLocalEvent<GridInitializeEvent>(OnGridInitialize);
SubscribeLocalEvent<DecalGridComponent, ComponentStartup>(OnCompStartup);
+ SubscribeLocalEvent<DecalGridComponent, ComponentGetState>(OnGetState);
+ }
+
+ private void OnGetState(EntityUid uid, DecalGridComponent component, ref ComponentGetState args)
+ {
+ if (PvsEnabled && !args.ReplayState)
+ return;
+
+ // Should this be a full component state or a delta-state?
+ if (args.FromTick <= component.CreationTick || args.FromTick <= component.ForceTick)
+ {
+ args.State = new DecalGridState(component.ChunkCollection.ChunkCollection);
+ return;
+ }
+
+ var data = new Dictionary<Vector2i, DecalChunk>();
+ foreach (var (index, chunk) in component.ChunkCollection.ChunkCollection)
+ {
+ if (chunk.LastModified >= args.FromTick)
+ data[index] = chunk;
+ }
+
+ args.State = new DecalGridState(data) { AllChunks = new(component.ChunkCollection.ChunkCollection.Keys) };
}
private void OnGridInitialize(GridInitializeEvent msg)
{
EnsureComp<DecalGridComponent>(msg.EntityUid);
}
-
+
private void OnCompStartup(EntityUid uid, DecalGridComponent component, ComponentStartup args)
{
foreach (var (indices, decals) in component.ChunkCollection.ChunkCollection)