Replace NavMap dictionaries with int[] (#27602)

* Replace NavMap dictionaries with int[]

* Remove badly named const

* Remove unnecessary offset

* Prioritize airlocks

Signed-off-by: null <56081759+NullWanderer@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2024-05-04 17:59:37 +02:00
committed by null
parent 7e80e49ce5
commit 381ee31ef5
10 changed files with 399 additions and 641 deletions
+4 -26
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;
}
}
}