Optimise navmaps significantly (#27528)

* Optimise navmaps significantly

- Reduce the delta state size significantly.
- Remove AirtightChangedEvent because this will spam them out constantly.

* weh

* review

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
This commit is contained in:
metalgearsloth
2024-05-02 10:18:38 +10:00
committed by GitHub
parent a95b0d000a
commit 7ba228732d
7 changed files with 387 additions and 219 deletions

View File

@@ -1,3 +1,4 @@
using Content.Shared.Atmos;
using Content.Shared.Pinpointer;
using Robust.Shared.GameStates;
@@ -31,7 +32,6 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
component.Beacons.Remove(beacon);
}
}
else
{
foreach (var index in component.Chunks.Keys)
@@ -47,17 +47,26 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
}
}
foreach (var ((category, origin), chunk) in state.Chunks)
foreach (var (origin, chunk) in state.Chunks)
{
var newChunk = new NavMapChunk(origin);
foreach (var (atmosDirection, value) in chunk)
newChunk.TileData[atmosDirection] = value;
for (var i = 0; i < NavMapComponent.Categories; i++)
{
var newData = chunk[i];
component.Chunks[(category, origin)] = newChunk;
if (newData == null)
continue;
newChunk.TileData[i] = new(newData);
}
component.Chunks[origin] = newChunk;
}
foreach (var beacon in state.Beacons)
{
component.Beacons.Add(beacon);
}
}
}