SolutionTemperature.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Content.Shared.EntityEffects;
  2. using Robust.Shared.Prototypes;
  3. namespace Content.Server.EntityEffects.EffectConditions;
  4. /// <summary>
  5. /// Requires the solution to be above or below a certain temperature.
  6. /// Used for things like explosives.
  7. /// </summary>
  8. public sealed partial class SolutionTemperature : EntityEffectCondition
  9. {
  10. [DataField]
  11. public float Min = 0.0f;
  12. [DataField]
  13. public float Max = float.PositiveInfinity;
  14. public override bool Condition(EntityEffectBaseArgs args)
  15. {
  16. if (args is EntityEffectReagentArgs reagentArgs)
  17. {
  18. if (reagentArgs.Source == null)
  19. return false;
  20. if (reagentArgs.Source.Temperature < Min)
  21. return false;
  22. if (reagentArgs.Source.Temperature > Max)
  23. return false;
  24. return true;
  25. }
  26. // TODO: Someone needs to figure out how to do this for non-reagent effects.
  27. throw new NotImplementedException();
  28. }
  29. public override string GuidebookExplanation(IPrototypeManager prototype)
  30. {
  31. return Loc.GetString("reagent-effect-condition-guidebook-solution-temperature",
  32. ("max", float.IsPositiveInfinity(Max) ? (float) int.MaxValue : Max),
  33. ("min", Min));
  34. }
  35. }