BodyTemperature.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Content.Server.Temperature.Components;
  2. using Content.Shared.EntityEffects;
  3. using Robust.Shared.Prototypes;
  4. namespace Content.Server.EntityEffects.EffectConditions;
  5. /// <summary>
  6. /// Requires the target entity to be above or below a certain temperature.
  7. /// Used for things like cryoxadone and pyroxadone.
  8. /// </summary>
  9. public sealed partial class Temperature : EntityEffectCondition
  10. {
  11. [DataField]
  12. public float Min = 0;
  13. [DataField]
  14. public float Max = float.PositiveInfinity;
  15. public override bool Condition(EntityEffectBaseArgs args)
  16. {
  17. if (args.EntityManager.TryGetComponent(args.TargetEntity, out TemperatureComponent? temp))
  18. {
  19. if (temp.CurrentTemperature > Min && temp.CurrentTemperature < Max)
  20. return true;
  21. }
  22. return false;
  23. }
  24. public override string GuidebookExplanation(IPrototypeManager prototype)
  25. {
  26. return Loc.GetString("reagent-effect-condition-guidebook-body-temperature",
  27. ("max", float.IsPositiveInfinity(Max) ? (float) int.MaxValue : Max),
  28. ("min", Min));
  29. }
  30. }