using Content.Shared.Atmos.Consoles;
using Content.Shared.Pinpointer;
using Content.Shared.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
namespace Content.Shared.Atmos.Components;
///
/// Entities capable of opening the atmos monitoring console UI
/// require this component to function correctly
///
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedAtmosMonitoringConsoleSystem))]
public sealed partial class AtmosMonitoringConsoleComponent : Component
{
/*
* Don't need DataFields as this can be reconstructed
*/
///
/// A dictionary of the all the nav map chunks that contain anchored atmos pipes
///
[ViewVariables]
public Dictionary AtmosPipeChunks = new();
///
/// A list of all the atmos devices that will be used to populate the nav map
///
[ViewVariables]
public Dictionary AtmosDevices = new();
///
/// Color of the floor tiles on the nav map screen
///
[DataField, ViewVariables]
public Color NavMapTileColor;
///
/// Color of the wall lines on the nav map screen
///
[DataField, ViewVariables]
public Color NavMapWallColor;
///
/// The next time this component is dirtied, it will force the full state
/// to be sent to the client, instead of just the delta state
///
[ViewVariables]
public bool ForceFullUpdate = false;
}
[Serializable, NetSerializable]
public struct AtmosPipeChunk(Vector2i origin)
{
///
/// Chunk position
///
[ViewVariables]
public readonly Vector2i Origin = origin;
///
/// Bitmask look up for atmos pipes, 1 for occupied and 0 for empty.
/// Indexed by the net ID, layer and color hexcode of the pipe
///
[ViewVariables]
public Dictionary AtmosPipeData = new();
///
/// The last game tick that the chunk was updated
///
[NonSerialized]
public GameTick LastUpdate;
}
[Serializable, NetSerializable]
public struct AtmosDeviceNavMapData
{
///
/// The entity in question
///
public NetEntity NetEntity;
///
/// Location of the entity
///
public NetCoordinates NetCoordinates;
///
/// The associated pipe network ID
///
public int NetId = -1;
///
/// Prototype ID for the nav map blip
///
public ProtoId NavMapBlip;
///
/// Direction of the entity
///
public Direction Direction;
///
/// Color of the attached pipe
///
public Color PipeColor;
///
/// The pipe layer the entity is on
///
public AtmosPipeLayer PipeLayer;
///
/// Populate the atmos monitoring console nav map with a single entity
///
public AtmosDeviceNavMapData(NetEntity netEntity,
NetCoordinates netCoordinates,
int netId,
ProtoId navMapBlip,
Direction direction,
Color pipeColor,
AtmosPipeLayer pipeLayer)
{
NetEntity = netEntity;
NetCoordinates = netCoordinates;
NetId = netId;
NavMapBlip = navMapBlip;
Direction = direction;
PipeColor = pipeColor;
PipeLayer = pipeLayer;
}
}
[Serializable, NetSerializable]
public sealed class AtmosMonitoringConsoleBoundInterfaceState : BoundUserInterfaceState
{
///
/// A list of all entries to populate the UI with
///
public AtmosMonitoringConsoleEntry[] AtmosNetworks;
///
/// Sends data from the server to the client to populate the atmos monitoring console UI
///
public AtmosMonitoringConsoleBoundInterfaceState(AtmosMonitoringConsoleEntry[] atmosNetworks)
{
AtmosNetworks = atmosNetworks;
}
}
[Serializable, NetSerializable]
public struct AtmosMonitoringConsoleEntry
{
///
/// The entity in question
///
public NetEntity NetEntity;
///
/// Location of the entity
///
public NetCoordinates Coordinates;
///
/// The associated pipe network ID
///
public int NetId = -1;
///
/// Localised device name
///
public string EntityName;
///
/// Device network address
///
public string Address;
///
/// Temperature (K)
///
public float TemperatureData;
///
/// Pressure (kPA)
///
public float PressureData;
///
/// Total number of mols of gas
///
public float TotalMolData;
///
/// Mol and percentage for all detected gases
///
public Dictionary GasData = new();
///
/// The color to be associated with the pipe network
///
public Color Color;
///
/// Indicates whether the entity is powered
///
public bool IsPowered = true;
///
/// Used to populate the atmos monitoring console UI with data from a single air alarm
///
public AtmosMonitoringConsoleEntry
(NetEntity entity,
NetCoordinates coordinates,
int netId,
string entityName,
string address)
{
NetEntity = entity;
Coordinates = coordinates;
NetId = netId;
EntityName = entityName;
Address = address;
}
}
///
/// Used to group atmos pipe chunks into subnets based on their properties and
/// improve the efficiency of rendering these chunks on the atmos monitoring console.
///
/// The associated network ID.
/// The associated pipe layer.
/// The color of the pipe.
[Serializable, NetSerializable]
public record AtmosMonitoringConsoleSubnet(int NetId, AtmosPipeLayer PipeLayer, Color Color);
public enum AtmosPipeChunkDataFacing : byte
{
// Values represent bit shift offsets when retrieving data in the tile array.
North = 0,
South = SharedNavMapSystem.ArraySize,
East = SharedNavMapSystem.ArraySize * 2,
West = SharedNavMapSystem.ArraySize * 3,
}
///
/// UI key associated with the atmos monitoring console
///
[Serializable, NetSerializable]
public enum AtmosMonitoringConsoleUiKey
{
Key
}