2021-06-23 11:35:30 +02:00
|
|
|
using Content.Server.Atmos.EntitySystems;
|
2021-12-05 04:18:30 +01:00
|
|
|
using Content.Server.Fluids.EntitySystems;
|
2024-04-30 14:31:05 -07:00
|
|
|
using Content.Shared.Atmos;
|
|
|
|
|
using Content.Shared.Atmos.Reactions;
|
2021-09-06 15:49:44 +02:00
|
|
|
using Content.Shared.Chemistry.Components;
|
2021-11-03 16:48:03 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2021-03-05 22:15:37 +01:00
|
|
|
using Content.Shared.Maps;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Atmos.Reactions
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2021-03-06 00:13:25 +01:00
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class WaterVaporReaction : IGasReactionEffect
|
2021-03-05 22:15:37 +01:00
|
|
|
{
|
2023-08-22 18:14:33 -07:00
|
|
|
[DataField("reagent")] public string? Reagent { get; private set; } = null;
|
2021-03-05 22:15:37 +01:00
|
|
|
|
2023-08-22 18:14:33 -07:00
|
|
|
[DataField("gas")] public int GasId { get; private set; } = 0;
|
2021-03-05 22:15:37 +01:00
|
|
|
|
2023-08-22 18:14:33 -07:00
|
|
|
[DataField("molesPerUnit")] public float MolesPerUnit { get; private set; } = 1;
|
2021-03-05 22:15:37 +01:00
|
|
|
|
2023-12-15 17:02:21 -05:00
|
|
|
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
|
2021-03-05 22:15:37 +01:00
|
|
|
{
|
|
|
|
|
// If any of the prototypes is invalid, we do nothing.
|
2023-04-10 15:37:03 +10:00
|
|
|
if (string.IsNullOrEmpty(Reagent))
|
|
|
|
|
return ReactionResult.NoReaction;
|
2021-03-05 22:15:37 +01:00
|
|
|
|
|
|
|
|
// If we're not reacting on a tile, do nothing.
|
2023-04-10 15:37:03 +10:00
|
|
|
if (holder is not TileAtmosphere tile)
|
|
|
|
|
return ReactionResult.NoReaction;
|
2021-03-05 22:15:37 +01:00
|
|
|
|
|
|
|
|
// If we don't have enough moles of the specified gas, do nothing.
|
2023-04-10 15:37:03 +10:00
|
|
|
if (mixture.GetMoles(GasId) < MolesPerUnit)
|
|
|
|
|
return ReactionResult.NoReaction;
|
2021-03-05 22:15:37 +01:00
|
|
|
|
|
|
|
|
// Remove the moles from the mixture...
|
|
|
|
|
mixture.AdjustMoles(GasId, -MolesPerUnit);
|
|
|
|
|
|
2023-12-15 17:02:21 -05:00
|
|
|
var tileRef = atmosphereSystem.GetTileRef(tile);
|
|
|
|
|
atmosphereSystem.Puddle.TrySpillAt(tileRef, new Solution(Reagent, FixedPoint2.New(MolesPerUnit)), out _, sound: false);
|
2021-03-05 22:15:37 +01:00
|
|
|
|
|
|
|
|
return ReactionResult.Reacting;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|