Add chem solution atmos heating and cooling (#17854)
This commit is contained in:
@@ -31,7 +31,7 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
|
|||||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||||
[Dependency] private readonly TileSystem _tile = default!;
|
[Dependency] private readonly TileSystem _tile = default!;
|
||||||
|
|
||||||
private const float ExposedUpdateDelay = 1f;
|
public const float ExposedUpdateDelay = 1f;
|
||||||
private float _exposedTimer = 0f;
|
private float _exposedTimer = 0f;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace Content.Server.Chemistry.Components.SolutionManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lets the solution conduct heat to/from atmos gases.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class SolutionGasHeatConductivityComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Solution that conducts heat.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("solution")]
|
||||||
|
public string Solution { get; set; } = "default";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The heat conductivity between the gas and solution.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("wattsPerKelvin")]
|
||||||
|
public float WattsPerKelvin = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using Content.Server.Atmos.EntitySystems;
|
||||||
|
using Content.Server.Chemistry.Components.SolutionManager;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
|
namespace Content.Server.Chemistry.EntitySystems;
|
||||||
|
|
||||||
|
public sealed class SolutionGasHeatConductivitySystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
|
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<SolutionGasHeatConductivityComponent, AtmosExposedUpdateEvent>(AtmosUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AtmosUpdate(EntityUid uid, SolutionGasHeatConductivityComponent solutionGasHeatConductivity, ref AtmosExposedUpdateEvent args)
|
||||||
|
{
|
||||||
|
if (!_solutionContainerSystem.TryGetSolution(uid, solutionGasHeatConductivity.Solution, out var solution) || solution.Volume == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var heatDifferenceKelvin = args.GasMixture.Temperature - solution.Temperature;
|
||||||
|
if (Math.Abs(heatDifferenceKelvin) < 0.5)
|
||||||
|
return; // close enough
|
||||||
|
|
||||||
|
var thermalEnergyTransferWatts = heatDifferenceKelvin * solutionGasHeatConductivity.WattsPerKelvin;
|
||||||
|
var thermalEnergyTransferJoules = thermalEnergyTransferWatts * AtmosphereSystem.ExposedUpdateDelay;
|
||||||
|
|
||||||
|
_solutionContainerSystem.AddThermalEnergy(uid, solution, thermalEnergyTransferJoules);
|
||||||
|
var gasHeatCapacity = _atmosphereSystem.GetHeatCapacity(args.GasMixture);
|
||||||
|
args.GasMixture.Temperature += gasHeatCapacity == 0 ? 0 : -thermalEnergyTransferJoules / gasHeatCapacity;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -142,6 +142,9 @@
|
|||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
puddle: { maxVol: 1000 }
|
puddle: { maxVol: 1000 }
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: puddle
|
||||||
- type: Puddle
|
- type: Puddle
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: EdgeSpreader
|
- type: EdgeSpreader
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
solution: drink
|
solution: drink
|
||||||
- type: DrainableSolution
|
- type: DrainableSolution
|
||||||
solution: drink
|
solution: drink
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: drink
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.TransferAmountUiKey.Key
|
- key: enum.TransferAmountUiKey.Key
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
solution: drink
|
solution: drink
|
||||||
- type: DrainableSolution
|
- type: DrainableSolution
|
||||||
solution: drink
|
solution: drink
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: drink
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: GenericVisualizer
|
- type: GenericVisualizer
|
||||||
visuals:
|
visuals:
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
- type: SolutionTransfer
|
- type: SolutionTransfer
|
||||||
canChangeTransferAmount: true
|
canChangeTransferAmount: true
|
||||||
maxTransferAmount: 10
|
maxTransferAmount: 10
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: drink
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.TransferAmountUiKey.Key
|
- key: enum.TransferAmountUiKey.Key
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
canChangeTransferAmount: true
|
canChangeTransferAmount: true
|
||||||
- type: Spillable
|
- type: Spillable
|
||||||
solution: drink
|
solution: drink
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: drink
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Consumable/Drinks/shaker.rsi
|
sprite: Objects/Consumable/Drinks/shaker.rsi
|
||||||
state: icon
|
state: icon
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
solution: drink
|
solution: drink
|
||||||
- type: DrainableSolution
|
- type: DrainableSolution
|
||||||
solution: drink
|
solution: drink
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: drink
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.TransferAmountUiKey.Key
|
- key: enum.TransferAmountUiKey.Key
|
||||||
|
|||||||
@@ -40,6 +40,9 @@
|
|||||||
solution: beaker
|
solution: beaker
|
||||||
- type: SolutionTransfer
|
- type: SolutionTransfer
|
||||||
canChangeTransferAmount: true
|
canChangeTransferAmount: true
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: beaker
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.TransferAmountUiKey.Key
|
- key: enum.TransferAmountUiKey.Key
|
||||||
@@ -131,6 +134,9 @@
|
|||||||
solution: beaker
|
solution: beaker
|
||||||
- type: SolutionTransfer
|
- type: SolutionTransfer
|
||||||
canChangeTransferAmount: true
|
canChangeTransferAmount: true
|
||||||
|
- type: AtmosExposed
|
||||||
|
- type: SolutionGasHeatConductivity
|
||||||
|
solution: beaker
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.TransferAmountUiKey.Key
|
- key: enum.TransferAmountUiKey.Key
|
||||||
|
|||||||
Reference in New Issue
Block a user