private DecalOverlay _overlay = default!;
+ private HashSet<uint> _removedUids = new();
+ private readonly List<Vector2i> _removedChunks = new();
+
public override void Initialize()
{
base.Initialize();
return;
// is this a delta or full state?
- var removedChunks = new List<Vector2i>();
+ _removedChunks.Clear();
+
if (!state.FullState)
{
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
{
if (!state.AllChunks!.Contains(key))
- removedChunks.Add(key);
+ _removedChunks.Add(key);
}
}
else
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
{
if (!state.Chunks.ContainsKey(key))
- removedChunks.Add(key);
+ _removedChunks.Add(key);
}
}
- if (removedChunks.Count > 0)
- RemoveChunks(gridUid, gridComp, removedChunks);
+ if (_removedChunks.Count > 0)
+ RemoveChunks(gridUid, gridComp, _removedChunks);
if (state.Chunks.Count > 0)
UpdateChunks(gridUid, gridComp, state.Chunks);
{
if (chunkCollection.TryGetValue(indices, out var chunk))
{
- var removedUids = new HashSet<uint>(chunk.Decals.Keys);
- removedUids.ExceptWith(newChunkData.Decals.Keys);
- foreach (var removedUid in removedUids)
+ _removedUids.Clear();
+ _removedUids.UnionWith(chunk.Decals.Keys);
+ _removedUids.ExceptWith(newChunkData.Decals.Keys);
+ foreach (var removedUid in _removedUids)
{
OnDecalRemoved(gridId, removedUid, gridComp, indices, chunk);
gridComp.DecalIndex.Remove(removedUid);
foreach (var index in chunks)
{
- if (!chunkCollection.TryGetValue(index, out var chunk)) continue;
+ if (!chunkCollection.TryGetValue(index, out var chunk))
+ continue;
foreach (var decalId in chunk.Decals.Keys)
{