using System.Linq;
using Content.Shared.Atmos;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
namespace Content.Shared.Pinpointer;
///
/// Used to store grid data to be used for UIs.
///
[RegisterComponent, NetworkedComponent]
public sealed partial class NavMapComponent : Component
{
public const int Categories = 4;
/*
* Don't need DataFields as this can be reconstructed
*/
///
/// Bitmasks that represent chunked tiles.
///
[ViewVariables]
public Dictionary Chunks = new();
///
/// List of station beacons.
///
[ViewVariables]
public HashSet Beacons = new();
}
[Serializable, NetSerializable]
public sealed class NavMapChunk
{
///
/// The chunk origin
///
public readonly Vector2i Origin;
///
/// Array with each entry corresponding to a .
/// Uses a bitmask for tiles, 1 for occupied and 0 for empty. There is a bitmask for each cardinal direction,
/// representing each edge of the tile, in case the entities inside it do not entirely fill it
///
public Dictionary?[] TileData;
///
/// The last game tick that the chunk was updated
///
[NonSerialized]
public GameTick LastUpdate;
public NavMapChunk(Vector2i origin)
{
Origin = origin;
TileData = new Dictionary?[NavMapComponent.Categories];
}
public Dictionary EnsureType(NavMapChunkType chunkType)
{
var data = TileData[(int) chunkType];
if (data == null)
{
data = new Dictionary()
{
[AtmosDirection.North] = 0,
[AtmosDirection.East] = 0,
[AtmosDirection.South] = 0,
[AtmosDirection.West] = 0,
};
TileData[(int) chunkType] = data;
}
return data;
}
}
public enum NavMapChunkType : byte
{
Invalid,
Floor,
Wall,
Airlock,
// Update the categories const if you update this.
}