Atmospheric network monitor (#32294)

* Updated to latest master version

* Added gas pipe analyzer

* Completed prototype

* Playing with UI display

* Refinement of the main UI

* Renamed gas pipe analyzer to gas pipe sensor

* Added focus network highlighting and map icons for gas pipe sensors

* Added construction graph for gas pipe sensor

* Improved efficiency of atmos pipe and focus pipe network data storage

* Added gas pipe sensor variants

* Fixed gas pipe sensor nav map icon not highlighting on focus

* Rendered pipe lines now get merged together

* Set up appearance handling for the gas pipe sensor, but setting the layers is bugged

* Gas pipe sensor lights turn off when the device is unpowered

* Renamed console

* The gas pipe sensor is now a pipe. Redistributed components between it and its assembly

* AtmosMonitors can now optionally monitor their internal pipe network instead of the surrounding atmosphere

* Massive code clean up

* Added delta states to handle pipe net updates, fixed entity deletion handling

* Nav map blip data has been replaced with prototypes

* Nav map blip fixes

* Nav map colors are now set by the console component

* Made the nav map more responsive to changes in focus

* Updated nav map icons

* Reverted unnecessary namespace changes

* Code tidy up

* Updated sprites and construction graph for gas pipe sensor

* Updated localization files

* Misc bug fixes

* Added missing comment

* Fixed issue with the circuit board for the monitor

* Embellished the background of the console network entries

* Updated console to account for PR #32273

* Removed gas pipe sensor

* Fixing merge conflict

* Update

* Addressing reviews part 1

* Addressing review part 2

* Addressing reviews part 3

* Removed unnecessary references

* Side panel values will be grayed out if there is no gas present in the pipe network

* Declaring colors at the start of some files

* Added a colored stripe to the side of the atmos network entries

* Fixed an issue with pipe sensor blip coloration

* Fixed delay that occurs when toggling gas sensors on/off
This commit is contained in:
chromiumboy
2024-12-16 21:53:17 -06:00
committed by GitHub
parent f4765260cb
commit 27e59d35fb
47 changed files with 2486 additions and 66 deletions

View File

@@ -0,0 +1,235 @@
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;
/// <summary>
/// Entities capable of opening the atmos monitoring console UI
/// require this component to function correctly
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedAtmosMonitoringConsoleSystem))]
public sealed partial class AtmosMonitoringConsoleComponent : Component
{
/*
* Don't need DataFields as this can be reconstructed
*/
/// <summary>
/// A dictionary of the all the nav map chunks that contain anchored atmos pipes
/// </summary>
[ViewVariables]
public Dictionary<Vector2i, AtmosPipeChunk> AtmosPipeChunks = new();
/// <summary>
/// A list of all the atmos devices that will be used to populate the nav map
/// </summary>
[ViewVariables]
public Dictionary<NetEntity, AtmosDeviceNavMapData> AtmosDevices = new();
/// <summary>
/// Color of the floor tiles on the nav map screen
/// </summary>
[DataField, ViewVariables]
public Color NavMapTileColor;
/// <summary>
/// Color of the wall lines on the nav map screen
/// </summary>
[DataField, ViewVariables]
public Color NavMapWallColor;
/// <summary>
/// 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
/// </summary>
[ViewVariables]
public bool ForceFullUpdate = false;
}
[Serializable, NetSerializable]
public struct AtmosPipeChunk(Vector2i origin)
{
/// <summary>
/// Chunk position
/// </summary>
[ViewVariables]
public readonly Vector2i Origin = origin;
/// <summary>
/// Bitmask look up for atmos pipes, 1 for occupied and 0 for empty.
/// Indexed by the color hexcode of the pipe
/// </summary>
[ViewVariables]
public Dictionary<(int, string), ulong> AtmosPipeData = new();
/// <summary>
/// The last game tick that the chunk was updated
/// </summary>
[NonSerialized]
public GameTick LastUpdate;
}
[Serializable, NetSerializable]
public struct AtmosDeviceNavMapData
{
/// <summary>
/// The entity in question
/// </summary>
public NetEntity NetEntity;
/// <summary>
/// Location of the entity
/// </summary>
public NetCoordinates NetCoordinates;
/// <summary>
/// The associated pipe network ID
/// </summary>
public int NetId = -1;
/// <summary>
/// Prototype ID for the nav map blip
/// </summary>
public ProtoId<NavMapBlipPrototype> NavMapBlip;
/// <summary>
/// Direction of the entity
/// </summary>
public Direction Direction;
/// <summary>
/// Color of the attached pipe
/// </summary>
public Color PipeColor;
/// <summary>
/// Populate the atmos monitoring console nav map with a single entity
/// </summary>
public AtmosDeviceNavMapData(NetEntity netEntity, NetCoordinates netCoordinates, int netId, ProtoId<NavMapBlipPrototype> navMapBlip, Direction direction, Color pipeColor)
{
NetEntity = netEntity;
NetCoordinates = netCoordinates;
NetId = netId;
NavMapBlip = navMapBlip;
Direction = direction;
PipeColor = pipeColor;
}
}
[Serializable, NetSerializable]
public sealed class AtmosMonitoringConsoleBoundInterfaceState : BoundUserInterfaceState
{
/// <summary>
/// A list of all entries to populate the UI with
/// </summary>
public AtmosMonitoringConsoleEntry[] AtmosNetworks;
/// <summary>
/// Sends data from the server to the client to populate the atmos monitoring console UI
/// </summary>
public AtmosMonitoringConsoleBoundInterfaceState(AtmosMonitoringConsoleEntry[] atmosNetworks)
{
AtmosNetworks = atmosNetworks;
}
}
[Serializable, NetSerializable]
public struct AtmosMonitoringConsoleEntry
{
/// <summary>
/// The entity in question
/// </summary>
public NetEntity NetEntity;
/// <summary>
/// Location of the entity
/// </summary>
public NetCoordinates Coordinates;
/// <summary>
/// The associated pipe network ID
/// </summary>
public int NetId = -1;
/// <summary>
/// Localised device name
/// </summary>
public string EntityName;
/// <summary>
/// Device network address
/// </summary>
public string Address;
/// <summary>
/// Temperature (K)
/// </summary>
public float TemperatureData;
/// <summary>
/// Pressure (kPA)
/// </summary>
public float PressureData;
/// <summary>
/// Total number of mols of gas
/// </summary>
public float TotalMolData;
/// <summary>
/// Mol and percentage for all detected gases
/// </summary>
public Dictionary<Gas, float> GasData = new();
/// <summary>
/// The color to be associated with the pipe network
/// </summary>
public Color Color;
/// <summary>
/// Indicates whether the entity is powered
/// </summary>
public bool IsPowered = true;
/// <summary>
/// Used to populate the atmos monitoring console UI with data from a single air alarm
/// </summary>
public AtmosMonitoringConsoleEntry
(NetEntity entity,
NetCoordinates coordinates,
int netId,
string entityName,
string address)
{
NetEntity = entity;
Coordinates = coordinates;
NetId = netId;
EntityName = entityName;
Address = address;
}
}
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,
}
/// <summary>
/// UI key associated with the atmos monitoring console
/// </summary>
[Serializable, NetSerializable]
public enum AtmosMonitoringConsoleUiKey
{
Key
}