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 TileSystem _tile = default!;
|
||||
|
||||
private const float ExposedUpdateDelay = 1f;
|
||||
public const float ExposedUpdateDelay = 1f;
|
||||
private float _exposedTimer = 0f;
|
||||
|
||||
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
|
||||
solutions:
|
||||
puddle: { maxVol: 1000 }
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: puddle
|
||||
- type: Puddle
|
||||
- type: Appearance
|
||||
- type: EdgeSpreader
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
solution: drink
|
||||
- type: DrainableSolution
|
||||
solution: drink
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: drink
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.TransferAmountUiKey.Key
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
solution: drink
|
||||
- type: DrainableSolution
|
||||
solution: drink
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: drink
|
||||
- type: Appearance
|
||||
- type: GenericVisualizer
|
||||
visuals:
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
- type: SolutionTransfer
|
||||
canChangeTransferAmount: true
|
||||
maxTransferAmount: 10
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: drink
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.TransferAmountUiKey.Key
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
canChangeTransferAmount: true
|
||||
- type: Spillable
|
||||
solution: drink
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: drink
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/shaker.rsi
|
||||
state: icon
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
solution: drink
|
||||
- type: DrainableSolution
|
||||
solution: drink
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: drink
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.TransferAmountUiKey.Key
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
solution: beaker
|
||||
- type: SolutionTransfer
|
||||
canChangeTransferAmount: true
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: beaker
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.TransferAmountUiKey.Key
|
||||
@@ -131,6 +134,9 @@
|
||||
solution: beaker
|
||||
- type: SolutionTransfer
|
||||
canChangeTransferAmount: true
|
||||
- type: AtmosExposed
|
||||
- type: SolutionGasHeatConductivity
|
||||
solution: beaker
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.TransferAmountUiKey.Key
|
||||
|
||||
Reference in New Issue
Block a user