Files
tbd-station-14/Content.Shared/Atmos/Piping/Binary/Components/GasPressureRegulatorComponent.cs
ArtisticRoomba f874459092 Pressure Relief Valve (#36708)
* initial system (this math is probably WRONG)

* General code cleanup and OnExamined support
(holy moly this code sucks)

* UICode and related events foundation
TODO:
- Actually write the XAML UI and the underlying system
- Un-shitcode the entire thing
- Actually test everything...

* Working UI code
TODO: Make predicted, as this certainly isn't predicted. Even though I said it was. It isn't.

* Remove one TODO for unshitcoding the examine code

* Add reminder
yea

* Make predicted (defenitely isn't)
(also defenitely isn't a copypaste from pressure pump code)

* It's predicted!
TODO:
- Give it snazzy predicted visuals!
- Have a different field for pressure entry, lest it gets bulldozed every UI update.

* Improve gas pressure relief valve UI
TODO: Reminder to reduce amount of dirties using deltafields

* Implement DirtyField prediction

* Entity<T> cleanup
A lot of Entity<T> conversions and lukewarm cleanup.

Also got caught copy pasting code in 4K UHD but it's not like you couldn't tell.

* More cleanup and comments

* Remove TODO comment on bulldozing window title

* """refactoring"""
- Move appearance out of shared and finally fix it. Pointless to predict appearance in this instance.
- More Entity<T> conversions because I like them.
- Move UI creation handling over entirely to the ActivatableUI system.
- Fix a hardcoded locale string (why????).

* Add visuals

* Revert debugging variable replacememt
yea

* Revert skissue

* Remove unused using directives and remove TODO

* Localize, cleanup, document

* Fix adminlogging discrepancy

* Add ability to construct, add guidebook entry

* Clear up comment

* Add guidebook tooltip to valve

* Convert GasPressureReliefValveBoundUserInterface declaration into primary constructor

* Adds more input handling and adds autofill on open

* Un-deepfry input validator shitcode
Genuinely what was I smoking

* improve visuals logic

* Refactor again
- Update math to the correct implementation
- Moved code that could be re-used in the future into a helper method under AtmosphereSystem.Gases.cs

* I'm sorry but I hate warnings

* Remove unused using directive in AtmosphereSystem.Gases.cs

* Review and cleanup

* Lukewarm UI glossup

* Maintainer for the upstream project btw

* Remove redundant state sets and messy logic

* Unduplicate valve updater code

* Redo UI (im sorry Slarti)

* run tests

* Test refactored UI messaging

* Second round of UI improvements
- God please find a way to improve this system. Feels bad.

* Update loop implementation

* Further predict UI

* Clear up SetToCurrentThreshold

* cleanup

* Update to master + pipe layers and bug fixes
want to run tests

* fixes

* Deploy rename pipebomb

* Documentation and requested changes

* Rename the method that wiggled away

* Undo rounding changes

* Fix comment

* Rename and cleanup

* Apply suggestions from code review

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2025-07-03 18:00:34 +02:00

89 lines
2.6 KiB
C#

using Content.Shared.Guidebook;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Atmos.Piping.Binary.Components;
/// <summary>
/// Defines a gas pressure regulator,
/// which releases gas depending on a set pressure threshold between two pipe nodes.
/// </summary>
[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState(true, true), AutoGenerateComponentPause]
public sealed partial class GasPressureRegulatorComponent : Component
{
/// <summary>
/// Determines whether the valve is open or closed.
/// Used for showing the valve animation, the UI,
/// and on examine.
/// </summary>
[DataField, AutoNetworkedField]
public bool Enabled;
/// <summary>
/// Specifies the pipe node name to be treated as the inlet.
/// </summary>
[DataField]
public string InletName = "inlet";
/// <summary>
/// Specifies the pipe node name to be treated as the outlet.
/// </summary>
[DataField]
public string OutletName = "outlet";
/// <summary>
/// The max transfer rate of the pressure regulator.
/// </summary>
[GuidebookData]
[DataField]
public float MaxTransferRate = Atmospherics.MaxTransferRate;
/// <summary>
/// The server time at which the next UI update will be sent.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextUiUpdate = TimeSpan.Zero;
/// <summary>
/// Sets the opening threshold of the pressure regulator.
/// </summary>
/// <example> If set to 500 kPa, the regulator will only
/// open if the pressure in the inlet side is above
/// 500 kPa. </example>
[DataField, AutoNetworkedField]
public float Threshold;
/// <summary>
/// How often the UI update is sent.
/// </summary>
[DataField]
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(1);
#region UI/Examine Info
/// <summary>
/// The current flow rate of the pressure regulator.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField, AutoNetworkedField]
public float FlowRate;
/// <summary>
/// Current inlet pressure the pressure regulator.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField, AutoNetworkedField]
public float InletPressure;
/// <summary>
/// Current outlet pressure of the pressure regulator.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField, AutoNetworkedField]
public float OutletPressure;
#endregion
}