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
{
/*
* 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 Dictionary Beacons = new();
///
/// Describes the properties of a region on the station.
/// It is indexed by the entity assigned as the region owner.
///
[ViewVariables(VVAccess.ReadOnly)]
public Dictionary RegionProperties = new();
///
/// All flood filled regions, ready for display on a NavMapControl.
/// It is indexed by the entity assigned as the region owner.
///
///
/// For client use only
///
[ViewVariables(VVAccess.ReadOnly)]
public Dictionary RegionOverlays = new();
///
/// A queue of all region owners that are waiting their associated regions to be floodfilled.
///
///
/// For client use only
///
[ViewVariables(VVAccess.ReadOnly)]
public Queue QueuedRegionsToFlood = new();
///
/// A look up table to get a list of region owners associated with a flood filled chunk.
///
///
/// For client use only
///
[ViewVariables(VVAccess.ReadOnly)]
public Dictionary> ChunkToRegionOwnerTable = new();
///
/// A look up table to find flood filled chunks associated with a given region owner.
///
///
/// For client use only
///
[ViewVariables(VVAccess.ReadOnly)]
public Dictionary> RegionOwnerToChunkTable = new();
}
[Serializable, NetSerializable]
public sealed class NavMapChunk(Vector2i origin)
{
///
/// The chunk origin
///
[ViewVariables]
public readonly Vector2i Origin = origin;
///
/// Array containing the chunk's data. The
///
[ViewVariables]
public int[] TileData = new int[SharedNavMapSystem.ArraySize];
///
/// The last game tick that the chunk was updated
///
[NonSerialized]
public GameTick LastUpdate;
}
[Serializable, NetSerializable]
public sealed class NavMapRegionOverlay(Enum uiKey, List<(Vector2i, Vector2i)> gridCoords)
{
///
/// The key to the UI that will be displaying this region on its navmap
///
public Enum UiKey = uiKey;
///
/// The local grid coordinates of the rectangles that make up the region
/// Item1 is the top left corner, Item2 is the bottom right corner
///
public List<(Vector2i, Vector2i)> GridCoords = gridCoords;
///
/// Color of the region
///
public Color Color = Color.White;
}
public enum NavMapChunkType : byte
{
// Values represent bit shift offsets when retrieving data in the tile array.
Invalid = byte.MaxValue,
Floor = 0, // I believe floors have directional information for diagonal tiles?
Wall = SharedNavMapSystem.Directions,
Airlock = 2 * SharedNavMapSystem.Directions,
}