GasReactionPrototype.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Content.Server.Atmos.EntitySystems;
  2. using Content.Shared.Atmos;
  3. using Content.Shared.Atmos.Reactions;
  4. using Robust.Shared.Prototypes;
  5. namespace Content.Server.Atmos.Reactions
  6. {
  7. [Prototype]
  8. public sealed partial class GasReactionPrototype : IPrototype
  9. {
  10. [ViewVariables]
  11. [IdDataField]
  12. public string ID { get; private set; } = default!;
  13. /// <summary>
  14. /// Minimum gas amount requirements.
  15. /// </summary>
  16. [DataField("minimumRequirements")]
  17. public float[] MinimumRequirements { get; private set; } = new float[Atmospherics.TotalNumberOfGases];
  18. /// <summary>
  19. /// Maximum temperature requirement.
  20. /// </summary>
  21. [DataField("maximumTemperature")]
  22. public float MaximumTemperatureRequirement { get; private set; } = float.MaxValue;
  23. /// <summary>
  24. /// Minimum temperature requirement.
  25. /// </summary>
  26. [DataField("minimumTemperature")]
  27. public float MinimumTemperatureRequirement { get; private set; } = Atmospherics.TCMB;
  28. /// <summary>
  29. /// Minimum energy requirement.
  30. /// </summary>
  31. [DataField("minimumEnergy")]
  32. public float MinimumEnergyRequirement { get; private set; } = 0f;
  33. /// <summary>
  34. /// Lower numbers are checked/react later than higher numbers.
  35. /// If two reactions have the same priority, they may happen in either order.
  36. /// </summary>
  37. [DataField("priority")]
  38. public int Priority { get; private set; } = int.MinValue;
  39. /// <summary>
  40. /// A list of effects this will produce.
  41. /// </summary>
  42. [DataField("effects")] private List<IGasReactionEffect> _effects = new();
  43. /// <summary>
  44. /// Process all reaction effects.
  45. /// </summary>
  46. /// <param name="mixture">The gas mixture to react</param>
  47. /// <param name="holder">The container of this gas mixture</param>
  48. /// <param name="atmosphereSystem">The atmosphere system</param>
  49. /// <param name="heatScale">Scaling factor that should be applied to all heat input or outputs.</param>
  50. public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
  51. {
  52. var result = ReactionResult.NoReaction;
  53. foreach (var effect in _effects)
  54. {
  55. result |= effect.React(mixture, holder, atmosphereSystem, heatScale);
  56. }
  57. return result;
  58. }
  59. }
  60. }