WaterVaporReaction.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Content.Server.Atmos.EntitySystems;
  2. using Content.Server.Fluids.EntitySystems;
  3. using Content.Shared.Atmos;
  4. using Content.Shared.Atmos.Reactions;
  5. using Content.Shared.Chemistry.Components;
  6. using Content.Shared.FixedPoint;
  7. using Content.Shared.Maps;
  8. using JetBrains.Annotations;
  9. namespace Content.Server.Atmos.Reactions
  10. {
  11. [UsedImplicitly]
  12. [DataDefinition]
  13. public sealed partial class WaterVaporReaction : IGasReactionEffect
  14. {
  15. [DataField("reagent")] public string? Reagent { get; private set; } = null;
  16. [DataField("gas")] public int GasId { get; private set; } = 0;
  17. [DataField("molesPerUnit")] public float MolesPerUnit { get; private set; } = 1;
  18. public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
  19. {
  20. // If any of the prototypes is invalid, we do nothing.
  21. if (string.IsNullOrEmpty(Reagent))
  22. return ReactionResult.NoReaction;
  23. // If we're not reacting on a tile, do nothing.
  24. if (holder is not TileAtmosphere tile)
  25. return ReactionResult.NoReaction;
  26. // If we don't have enough moles of the specified gas, do nothing.
  27. if (mixture.GetMoles(GasId) < MolesPerUnit)
  28. return ReactionResult.NoReaction;
  29. // Remove the moles from the mixture...
  30. mixture.AdjustMoles(GasId, -MolesPerUnit);
  31. var tileRef = atmosphereSystem.GetTileRef(tile);
  32. atmosphereSystem.Puddle.TrySpillAt(tileRef, new Solution(Reagent, FixedPoint2.New(MolesPerUnit)), out _, sound: false);
  33. return ReactionResult.Reacting;
  34. }
  35. }
  36. }