SatiateThirst.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. using Content.Shared.Chemistry.Reagent;
  2. using Content.Shared.EntityEffects;
  3. using Content.Shared.Nutrition.Components;
  4. using Content.Shared.Nutrition.EntitySystems;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Server.EntityEffects.Effects;
  7. /// <summary>
  8. /// Default metabolism for drink reagents. Attempts to find a ThirstComponent on the target,
  9. /// and to update it's thirst values.
  10. /// </summary>
  11. public sealed partial class SatiateThirst : EntityEffect
  12. {
  13. private const float DefaultHydrationFactor = 3.0f;
  14. /// How much thirst is satiated each tick. Not currently tied to
  15. /// rate or anything.
  16. [DataField("factor")]
  17. public float HydrationFactor { get; set; } = DefaultHydrationFactor;
  18. /// Satiate thirst if a ThirstComponent can be found
  19. public override void Effect(EntityEffectBaseArgs args)
  20. {
  21. var uid = args.TargetEntity;
  22. if (args.EntityManager.TryGetComponent(uid, out ThirstComponent? thirst))
  23. args.EntityManager.System<ThirstSystem>().ModifyThirst(uid, thirst, HydrationFactor);
  24. }
  25. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  26. => Loc.GetString("reagent-effect-guidebook-satiate-thirst", ("chance", Probability), ("relative", HydrationFactor / DefaultHydrationFactor));
  27. }