Files
OldThink/Content.Client/Pinpointer/NavMapSystem.cs
Jabak dbc492f3f3 Revert "Upstream (#148)"
This reverts commit 9f00d4b9aa.
2024-10-22 22:47:57 +03:00

51 lines
1.4 KiB
C#

using Content.Shared.Pinpointer;
using Robust.Shared.GameStates;
namespace Content.Client.Pinpointer;
public sealed partial class NavMapSystem : SharedNavMapSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NavMapComponent, ComponentHandleState>(OnHandleState);
}
private void OnHandleState(EntityUid uid, NavMapComponent component, ref ComponentHandleState args)
{
if (args.Current is not NavMapComponentState state)
return;
if (!state.FullState)
{
foreach (var index in component.Chunks.Keys)
{
if (!state.AllChunks!.Contains(index))
component.Chunks.Remove(index);
}
}
else
{
foreach (var index in component.Chunks.Keys)
{
if (!state.Chunks.ContainsKey(index))
component.Chunks.Remove(index);
}
}
foreach (var (origin, chunk) in state.Chunks)
{
var newChunk = new NavMapChunk(origin);
Array.Copy(chunk, newChunk.TileData, chunk.Length);
component.Chunks[origin] = newChunk;
}
component.Beacons.Clear();
foreach (var (nuid, beacon) in state.Beacons)
{
component.Beacons[nuid] = beacon;
}
}
}