2023-04-13 16:21:24 +10:00
|
|
|
using Content.Shared.Pinpointer;
|
|
|
|
|
using Robust.Shared.GameStates;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Pinpointer;
|
|
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
public sealed partial class NavMapSystem : SharedNavMapSystem
|
2023-04-13 16:21:24 +10:00
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2024-04-17 12:59:31 -05:00
|
|
|
|
2023-04-13 16:21:24 +10:00
|
|
|
SubscribeLocalEvent<NavMapComponent, ComponentHandleState>(OnHandleState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnHandleState(EntityUid uid, NavMapComponent component, ref ComponentHandleState args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Current is not NavMapComponentState state)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
if (!state.FullState)
|
2023-04-13 16:21:24 +10:00
|
|
|
{
|
2024-04-17 12:59:31 -05:00
|
|
|
foreach (var index in component.Chunks.Keys)
|
2023-04-13 16:21:24 +10:00
|
|
|
{
|
2024-04-17 12:59:31 -05:00
|
|
|
if (!state.AllChunks!.Contains(index))
|
|
|
|
|
component.Chunks.Remove(index);
|
|
|
|
|
}
|
2023-04-13 16:21:24 +10:00
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
foreach (var beacon in component.Beacons)
|
|
|
|
|
{
|
|
|
|
|
if (!state.AllBeacons!.Contains(beacon))
|
|
|
|
|
component.Beacons.Remove(beacon);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-19 12:34:31 -07:00
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
else
|
2023-04-13 16:21:24 +10:00
|
|
|
{
|
2024-04-17 12:59:31 -05:00
|
|
|
foreach (var index in component.Chunks.Keys)
|
2023-04-13 16:21:24 +10:00
|
|
|
{
|
2024-04-17 12:59:31 -05:00
|
|
|
if (!state.Chunks.ContainsKey(index))
|
|
|
|
|
component.Chunks.Remove(index);
|
|
|
|
|
}
|
2023-04-13 16:21:24 +10:00
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
foreach (var beacon in component.Beacons)
|
|
|
|
|
{
|
|
|
|
|
if (!state.Beacons.Contains(beacon))
|
|
|
|
|
component.Beacons.Remove(beacon);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-13 16:21:24 +10:00
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
foreach (var ((category, origin), chunk) in state.Chunks)
|
|
|
|
|
{
|
|
|
|
|
var newChunk = new NavMapChunk(origin);
|
2023-04-13 16:21:24 +10:00
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
foreach (var (atmosDirection, value) in chunk)
|
|
|
|
|
newChunk.TileData[atmosDirection] = value;
|
2023-04-13 16:21:24 +10:00
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
component.Chunks[(category, origin)] = newChunk;
|
2023-04-13 16:21:24 +10:00
|
|
|
}
|
|
|
|
|
|
2024-04-17 12:59:31 -05:00
|
|
|
foreach (var beacon in state.Beacons)
|
|
|
|
|
component.Beacons.Add(beacon);
|
2023-04-13 16:21:24 +10:00
|
|
|
}
|
|
|
|
|
}
|