Replace NavMap dictionaries with int[] (#27602)

* Replace NavMap dictionaries with int[]

* Remove badly named const

* Remove unnecessary offset

* Prioritize airlocks
This commit is contained in:
Leon Friedrich
2024-05-02 14:51:21 +12:00
committed by GitHub
parent 11a4f9d21f
commit a7e6337cbd
10 changed files with 395 additions and 640 deletions

View File

@@ -1,4 +1,3 @@
using Content.Shared.Atmos;
using Content.Shared.Pinpointer;
using Robust.Shared.GameStates;
@@ -25,12 +24,6 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
if (!state.AllChunks!.Contains(index))
component.Chunks.Remove(index);
}
foreach (var beacon in component.Beacons)
{
if (!state.AllBeacons!.Contains(beacon))
component.Beacons.Remove(beacon);
}
}
else
{
@@ -39,34 +32,19 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
if (!state.Chunks.ContainsKey(index))
component.Chunks.Remove(index);
}
foreach (var beacon in component.Beacons)
{
if (!state.Beacons.Contains(beacon))
component.Beacons.Remove(beacon);
}
}
foreach (var (origin, chunk) in state.Chunks)
{
var newChunk = new NavMapChunk(origin);
for (var i = 0; i < NavMapComponent.Categories; i++)
{
var newData = chunk[i];
if (newData == null)
continue;
newChunk.TileData[i] = new(newData);
}
Array.Copy(chunk, newChunk.TileData, chunk.Length);
component.Chunks[origin] = newChunk;
}
foreach (var beacon in state.Beacons)
component.Beacons.Clear();
foreach (var (nuid, beacon) in state.Beacons)
{
component.Beacons.Add(beacon);
component.Beacons[nuid] = beacon;
}
}
}