* Optimized the drawing of lines and tracked entities * Optimized nav map updating and added thin wall support * Added support for thin doors * Removed floor tile seams, more line drawing optimizations * Fixed split grids not updating correctly * Cleaned up NavMapControl code * Fix nav map header * Converted nav map updates from system network messages to delta-states * Addressed review comments * Fixed timing issue where NavMapSystem would update before AirtightSystem did
64 lines
1.7 KiB
C#
64 lines
1.7 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);
|
|
}
|
|
|
|
foreach (var beacon in component.Beacons)
|
|
{
|
|
if (!state.AllBeacons!.Contains(beacon))
|
|
component.Beacons.Remove(beacon);
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
foreach (var index in component.Chunks.Keys)
|
|
{
|
|
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 ((category, origin), chunk) in state.Chunks)
|
|
{
|
|
var newChunk = new NavMapChunk(origin);
|
|
|
|
foreach (var (atmosDirection, value) in chunk)
|
|
newChunk.TileData[atmosDirection] = value;
|
|
|
|
component.Chunks[(category, origin)] = newChunk;
|
|
}
|
|
|
|
foreach (var beacon in state.Beacons)
|
|
component.Beacons.Add(beacon);
|
|
}
|
|
}
|