Atmos pipe rework (#3833)

* Initial

* Cleanup a bunch of things

* some changes dunno

* RequireAnchored

* a

* stuff

* more work

* Lots of progress

* delete pipe visualizer

* a

* b

* pipenet and pipenode cleanup

* Fixes

* Adds GasValve

* Adds GasMiner

* Fix stuff, maybe?

* More fixes

* Ignored components on the client

* Adds thermomachine behavior, change a bunch of stuff

* Remove Anchored

* some work, but it's shitcode

* significantly more ECS

* ECS AtmosDevices

* Cleanup

* fix appearance

* when the pipe direction is sus

* Gas tanks and canisters

* pipe anchoring and stuff

* coding is my passion

* Unsafe pipes take longer to unanchor

* turns out we're no longer using eris canisters

* Gas canister inserted tank appearance, improvements

* Work on a bunch of appearances

* Scrubber appearance

* Reorganize AtmosphereSystem.Piping into a bunch of different systems

* Appearance for vent/scrubber/pump turns off when leaving atmosphere

* ThermoMachine appearance

* Cleanup gas tanks

* Remove passive gate unused imports

* remove old canister UI functionality

* PipeNode environment air, make everything use AssumeAir instead of merging manually

* a

* Reorganize atmos to follow new structure

* ?????

* Canister UI, restructure client

* Restructure shared

* Fix build tho

* listen, at least the canister UI works entirely...

* fix build : )

* Atmos device prototypes have names and descriptions

* gas canister ui slider doesn't jitter

* trinary prototypes

* sprite for miners

* ignore components

* fix YAML

* Fix port system doing useless thing

* Fix build

* fix thinking moment

* fix build again because

* canister direction

* pipenode is a word

* GasTank Air will throw on invalid states

* fix build....

* Unhardcode volume pump thresholds

* Volume pump and filter take time into account

* Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event

* Gas tank node volume is set by initial mixtuer

* I love node container
This commit is contained in:
Vera Aguilera Puerto
2021-06-19 13:25:05 +02:00
committed by GitHub
parent cfc3f2e7fc
commit a2b737d945
250 changed files with 3964 additions and 3163 deletions

View File

@@ -244,6 +244,20 @@ namespace Content.Shared.Atmos
public const float HumanProducedOxygen = HumanNeededOxygen * 0.75f;
public const float HumanProducedCarbonDioxide = HumanNeededOxygen * 0.25f;
#region Pipes
/// <summary>
/// The pressure pumps and powered equipment max out at, in kPa.
/// </summary>
public const float MaxOutputPressure = 4500;
/// <summary>
/// The maximum speed powered equipment can work at, in L/s.
/// </summary>
public const float MaxTransferRate = 200;
#endregion
}
/// <summary>
@@ -252,6 +266,7 @@ namespace Content.Shared.Atmos
[Serializable, NetSerializable]
public enum Gas : sbyte
{
Invalid = -1,
Oxygen = 0,
Nitrogen = 1,
CarbonDioxide = 2,

View File

@@ -3,7 +3,7 @@ using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos
namespace Content.Shared.Atmos.Components
{
public class SharedFlammableComponent : Component
{

View File

@@ -4,7 +4,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components
namespace Content.Shared.Atmos.Components
{
public class SharedGasAnalyzerComponent : Component
{
@@ -83,4 +83,19 @@ namespace Content.Shared.GameObjects.Components
}
}
}
[NetSerializable]
[Serializable]
public enum GasAnalyzerVisuals
{
VisualState,
}
[NetSerializable]
[Serializable]
public enum GasAnalyzerVisualState
{
Off,
Working,
}
}

View File

@@ -3,8 +3,25 @@ using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos.GasTank
namespace Content.Shared.Atmos.Components
{
[Serializable, NetSerializable]
public enum SharedGasTankUiKey
{
Key
}
[Serializable, NetSerializable]
public class GasTankToggleInternalsMessage : BoundUserInterfaceMessage
{
}
[Serializable, NetSerializable]
public class GasTankSetPressureMessage : BoundUserInterfaceMessage
{
public float Pressure { get; set; }
}
[Serializable, NetSerializable]
public class GasTankBoundUserInterfaceState : BoundUserInterfaceState
{

View File

@@ -2,11 +2,10 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Content.Shared.Atmos;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.EntitySystems.Atmos
namespace Content.Shared.Atmos.EntitySystems
{
public abstract class SharedAtmosDebugOverlaySystem : EntitySystem
{

View File

@@ -1,12 +1,12 @@
#nullable enable
using System.Collections.Generic;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Prototypes;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.GameObjects.EntitySystems.Atmos
namespace Content.Shared.Atmos.EntitySystems
{
public class SharedAtmosphereSystem : EntitySystem
{

View File

@@ -6,7 +6,7 @@ using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.EntitySystems.Atmos
namespace Content.Shared.Atmos.EntitySystems
{
public abstract class SharedGasTileOverlaySystem : EntitySystem
{

View File

@@ -1,11 +1,12 @@
#nullable enable
using System.Collections.Generic;
using Content.Shared.Atmos.EntitySystems;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Shared.GameObjects.EntitySystems.Atmos
namespace Content.Shared.Atmos
{
public sealed class GasOverlayChunk
{

View File

@@ -1,9 +1,10 @@
#nullable enable
using System;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using System;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Atmos
namespace Content.Shared.Atmos
{
[Serializable, NetSerializable]
public enum PipeVisuals
@@ -14,13 +15,12 @@ namespace Content.Shared.GameObjects.Components.Atmos
[Serializable, NetSerializable]
public class PipeVisualState
{
public readonly PipeShape PipeShape;
// TODO ATMOS: Make this not a class and just be the field below...
[ViewVariables]
public readonly PipeDirection ConnectedDirections;
public PipeVisualState(PipeShape pipeShape, PipeDirection connectedDirections)
public PipeVisualState(PipeDirection connectedDirections)
{
PipeShape = pipeShape;
ConnectedDirections = connectedDirections;
}
}
@@ -34,8 +34,10 @@ namespace Content.Shared.GameObjects.Components.Atmos
//Half of a pipe in a direction
North = 1 << 0,
South = 1 << 1,
West = 1 << 2,
East = 1 << 3,
West = 1 << 2,
East = 1 << 3,
Port = 1 << 4,
Connector = 1 << 5,
//Straight pipes
Longitudinal = North | South,
@@ -47,6 +49,12 @@ namespace Content.Shared.GameObjects.Components.Atmos
SWBend = South | West,
SEBend = South | East,
//Vertical Bends (Port only)
NPBend = North | Port,
SPBend = South | Port,
WPBend = West | Port,
EPBend = East | Port,
//T-Junctions
TNorth = North | Lateral,
TSouth = South | Lateral,
@@ -64,6 +72,7 @@ namespace Content.Shared.GameObjects.Components.Atmos
Half,
Straight,
Bend,
VerticalBend,
TJunction,
Fourway
}
@@ -80,6 +89,7 @@ namespace Content.Shared.GameObjects.Components.Atmos
PipeShape.Half => PipeDirection.South,
PipeShape.Straight => PipeDirection.Longitudinal,
PipeShape.Bend => PipeDirection.SWBend,
PipeShape.VerticalBend => PipeDirection.SPBend,
PipeShape.TJunction => PipeDirection.TSouth,
PipeShape.Fourway => PipeDirection.Fourway,
_ => throw new ArgumentOutOfRangeException(nameof(shape), $"{shape} does not have an associated {nameof(PipeDirection)}."),
@@ -91,6 +101,11 @@ namespace Content.Shared.GameObjects.Components.Atmos
{
public const int PipeDirections = 4;
/// <summary>
/// Includes the Up and Down directions.
/// </summary>
public const int AllPipeDirections = 6;
public static bool HasDirection(this PipeDirection pipeDirection, PipeDirection other)
{
return (pipeDirection & other) == other;
@@ -133,6 +148,8 @@ namespace Content.Shared.GameObjects.Components.Atmos
PipeDirection.South => PipeDirection.North,
PipeDirection.East => PipeDirection.West,
PipeDirection.West => PipeDirection.East,
PipeDirection.Port => PipeDirection.Connector,
PipeDirection.Connector => PipeDirection.Port,
_ => throw new ArgumentOutOfRangeException(nameof(pipeDirection)),
};
}
@@ -154,6 +171,11 @@ namespace Content.Shared.GameObjects.Components.Atmos
PipeDirection.SEBend => PipeShape.Bend,
PipeDirection.SWBend => PipeShape.Bend,
PipeDirection.NPBend => PipeShape.VerticalBend,
PipeDirection.SPBend => PipeShape.VerticalBend,
PipeDirection.WPBend => PipeShape.VerticalBend,
PipeDirection.EPBend => PipeShape.VerticalBend,
PipeDirection.TNorth => PipeShape.TJunction,
PipeDirection.TSouth => PipeShape.TJunction,
PipeDirection.TEast => PipeShape.TJunction,

View File

@@ -0,0 +1,90 @@
#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Piping.Binary.Components
{
/// <summary>
/// Key representing which <see cref="BoundUserInterface"/> is currently open.
/// Useful when there are multiple UI for an object. Here it's future-proofing only.
/// </summary>
[Serializable, NetSerializable]
public enum GasCanisterUiKey
{
Key,
}
#region Enums
/// <summary>
/// Used in <see cref="GasCanisterVisualizer"/> to determine which visuals to update.
/// </summary>
[Serializable, NetSerializable]
public enum GasCanisterVisuals
{
PressureState,
TankInserted,
}
#endregion
/// <summary>
/// Represents a <see cref="GasCanisterComponent"/> state that can be sent to the client
/// </summary>
[Serializable, NetSerializable]
public class GasCanisterBoundUserInterfaceState : BoundUserInterfaceState
{
public string CanisterLabel { get; }
public float CanisterPressure { get; }
public bool PortStatus { get; }
public string? TankLabel { get; }
public float TankPressure { get; }
public float ReleasePressure { get; }
public bool ReleaseValve { get; }
public float ReleasePressureMin { get; }
public float ReleasePressureMax { get; }
public GasCanisterBoundUserInterfaceState(string canisterLabel, float canisterPressure, bool portStatus, string? tankLabel, float tankPressure, float releasePressure, bool releaseValve, float releaseValveMin, float releaseValveMax)
{
CanisterLabel = canisterLabel;
CanisterPressure = canisterPressure;
PortStatus = portStatus;
TankLabel = tankLabel;
TankPressure = tankPressure;
ReleasePressure = releasePressure;
ReleaseValve = releaseValve;
ReleasePressureMin = releaseValveMin;
ReleasePressureMax = releaseValveMax;
}
}
[Serializable, NetSerializable]
public class GasCanisterHoldingTankEjectMessage : BoundUserInterfaceMessage
{
public GasCanisterHoldingTankEjectMessage()
{}
}
[Serializable, NetSerializable]
public class GasCanisterChangeReleasePressureMessage : BoundUserInterfaceMessage
{
public float Pressure { get; }
public GasCanisterChangeReleasePressureMessage(float pressure)
{
Pressure = pressure;
}
}
[Serializable, NetSerializable]
public class GasCanisterChangeReleaseValveMessage : BoundUserInterfaceMessage
{
public bool Valve { get; }
public GasCanisterChangeReleaseValveMessage(bool valve)
{
Valve = valve;
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Piping
{
[Serializable, NetSerializable]
public enum OutletInjectorVisuals
{
Enabled,
}
[Serializable, NetSerializable]
public enum PassiveVentVisuals
{
Enabled,
}
[Serializable, NetSerializable]
public enum VentScrubberVisuals
{
Enabled,
}
[Serializable, NetSerializable]
public enum ThermoMachineVisuals
{
Enabled,
}
[Serializable, NetSerializable]
public enum PressurePumpVisuals
{
Enabled,
}
}

View File

@@ -0,0 +1,14 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Piping.Unary.Components
{
/// <summary>
/// Used in <see cref="GasPortableVisualizer"/> to determine which visuals to update.
/// </summary>
[Serializable, NetSerializable]
public enum GasPortableVisuals
{
ConnectedState,
}
}

View File

@@ -0,0 +1,21 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Piping.Unary.Visuals
{
[Serializable, NetSerializable]
public enum ScrubberVisuals : byte
{
State,
}
[Serializable, NetSerializable]
public enum ScrubberState : byte
{
Off,
Scrub,
Siphon,
WideScrub,
Welded,
}
}

View File

@@ -0,0 +1,20 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Visuals
{
[Serializable, NetSerializable]
public enum VentPumpVisuals : byte
{
State,
}
[Serializable, NetSerializable]
public enum VentPumpState : byte
{
Off,
In,
Out,
Welded,
}
}

View File

@@ -3,7 +3,7 @@ using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Atmos
namespace Content.Shared.Atmos.Prototypes
{
[Prototype("gas")]
public class GasPrototype : IPrototype

View File

@@ -1,7 +1,7 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos
namespace Content.Shared.Atmos.Visuals
{
[Serializable, NetSerializable]
public enum AtmosPlaqueVisuals

View File

@@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.Serialization;
namespace Content.Shared.Damage

View File

@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.Serialization;
namespace Content.Shared.Damage

View File

@@ -1,13 +0,0 @@
#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos.GasTank
{
[Serializable, NetSerializable]
public class GasTankSetPressureMessage : BoundUserInterfaceMessage
{
public float Pressure { get; set; }
}
}

View File

@@ -1,12 +0,0 @@
#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos.GasTank
{
[Serializable, NetSerializable]
public class GasTankToggleInternalsMessage : BoundUserInterfaceMessage
{
}
}

View File

@@ -1,12 +0,0 @@
#nullable enable
using Content.Shared.NetIDs;
using Robust.Shared.GameObjects;
namespace Content.Shared.GameObjects.Components.Atmos.GasTank
{
public class SharedGasTankComponent : Component
{
public override string Name => "GasTank";
public override uint? NetID => ContentNetIDs.GAS_TANK;
}
}

View File

@@ -1,12 +0,0 @@
#nullable enable
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos.GasTank
{
[Serializable, NetSerializable]
public enum SharedGasTankUiKey
{
Key
}
}

View File

@@ -1,23 +0,0 @@
#nullable enable
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos
{
[Serializable, NetSerializable]
public enum FilterVisuals
{
VisualState
}
[Serializable, NetSerializable]
public class FilterVisualState
{
public bool Enabled { get; }
public FilterVisualState(bool enabled)
{
Enabled = enabled;
}
}
}

View File

@@ -1,21 +0,0 @@
#nullable enable
using Robust.Shared.Serialization;
using System;
namespace Content.Shared.GameObjects.Components.Atmos
{
[NetSerializable]
[Serializable]
public enum GasAnalyzerVisuals
{
VisualState,
}
[NetSerializable]
[Serializable]
public enum GasAnalyzerVisualState
{
Off,
Working,
}
}

View File

@@ -1,121 +0,0 @@
#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos
{
public class SharedGasCanisterComponent : Component
{
public override string Name => "GasCanister";
/// <summary>
/// Key representing which <see cref="BoundUserInterface"/> is currently open.
/// Useful when there are multiple UI for an object. Here it's future-proofing only.
/// </summary>
[Serializable, NetSerializable]
public enum GasCanisterUiKey
{
Key,
}
}
#region Enums
/// <summary>
/// Enum representing a UI button.
/// </summary>
[Serializable, NetSerializable]
public enum UiButton
{
ValveToggle
}
/// <summary>
/// Used in <see cref="GasCanisterVisualizer"/> to determine which visuals to update.
/// </summary>
[Serializable, NetSerializable]
public enum GasCanisterVisuals
{
ConnectedState,
PressureState
}
#endregion
/// <summary>
/// Represents a <see cref="GasCanisterComponent"/> state that can be sent to the client
/// </summary>
[Serializable, NetSerializable]
public class GasCanisterBoundUserInterfaceState : BoundUserInterfaceState
{
public readonly string Label;
public readonly float Volume;
public readonly float ReleasePressure;
public readonly bool ValveOpened;
public GasCanisterBoundUserInterfaceState(string newLabel, float volume, float releasePressure, bool valveOpened)
{
Label = newLabel;
Volume = volume;
ReleasePressure = releasePressure;
ValveOpened = valveOpened;
}
public bool Equals(GasCanisterBoundUserInterfaceState? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Label == other.Label &&
Volume.Equals(other.Volume) &&
ReleasePressure.Equals(other.ReleasePressure) &&
ValveOpened == other.ValveOpened;
}
}
#region NetMessages
/// <summary>
/// Message sent from the client to the server when a gas canister button is pressed
/// </summary>
[Serializable, NetSerializable]
public class UiButtonPressedMessage : BoundUserInterfaceMessage
{
public readonly UiButton Button;
public UiButtonPressedMessage(UiButton button)
{
Button = button;
}
}
/// <summary>
/// Message sent when the release pressure is changed client side
/// </summary>
[Serializable, NetSerializable]
public class ReleasePressureButtonPressedMessage : BoundUserInterfaceMessage
{
public readonly float ReleasePressure;
public ReleasePressureButtonPressedMessage(float val) : base()
{
ReleasePressure = val;
}
}
/// <summary>
/// Message sent when the canister label has been changed
/// </summary>
[Serializable, NetSerializable]
public class CanisterLabelChangedMessage : BoundUserInterfaceMessage
{
public readonly string NewLabel;
public CanisterLabelChangedMessage(string newLabel) : base()
{
NewLabel = newLabel;
}
}
#endregion
}

View File

@@ -1,27 +0,0 @@
#nullable enable
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos
{
[Serializable, NetSerializable]
public enum PumpVisuals
{
VisualState
}
[Serializable, NetSerializable]
public class PumpVisualState
{
public readonly PipeDirection InletDirection;
public readonly PipeDirection OutletDirection;
public readonly bool PumpEnabled;
public PumpVisualState(PipeDirection inletDirection, PipeDirection outletDirection, bool pumpEnabled)
{
InletDirection = inletDirection;
OutletDirection = outletDirection;
PumpEnabled = pumpEnabled;
}
}
}

View File

@@ -1,23 +0,0 @@
#nullable enable
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos
{
[Serializable, NetSerializable]
public enum SiphonVisuals
{
VisualState
}
[Serializable, NetSerializable]
public class SiphonVisualState
{
public readonly bool SiphonEnabled;
public SiphonVisualState(bool siphonEnabled)
{
SiphonEnabled = siphonEnabled;
}
}
}

View File

@@ -1,23 +0,0 @@
#nullable enable
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos
{
[Serializable, NetSerializable]
public enum VentVisuals
{
VisualState
}
[Serializable, NetSerializable]
public class VentVisualState
{
public readonly bool VentEnabled;
public VentVisualState(bool ventEnabled)
{
VentEnabled = ventEnabled;
}
}
}