2022-05-13 00:59:03 -07:00
|
|
|
|
using Content.Server.Body.Components;
|
2022-02-10 17:53:10 +13:00
|
|
|
|
using Content.Shared.Atmos;
|
|
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2023-06-04 16:45:02 -04:00
|
|
|
|
using Robust.Shared.Prototypes;
|
2022-02-10 17:53:10 +13:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Chemistry.ReagentEffects;
|
|
|
|
|
|
|
2023-08-22 18:14:33 -07:00
|
|
|
|
public sealed partial class ModifyLungGas : ReagentEffect
|
2022-02-10 17:53:10 +13:00
|
|
|
|
{
|
|
|
|
|
|
[DataField("ratios", required: true)]
|
|
|
|
|
|
private Dictionary<Gas, float> _ratios = default!;
|
|
|
|
|
|
|
2023-06-04 16:45:02 -04:00
|
|
|
|
// JUSTIFICATION: This is internal magic that players never directly interact with.
|
|
|
|
|
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
|
|
|
|
|
=> null;
|
|
|
|
|
|
|
2022-02-10 17:53:10 +13:00
|
|
|
|
public override void Effect(ReagentEffectArgs args)
|
|
|
|
|
|
{
|
2024-03-24 03:34:56 +11:00
|
|
|
|
if (!args.EntityManager.TryGetComponent<LungComponent>(args.OrganEntity, out var lung))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var (gas, ratio) in _ratios)
|
2022-02-10 17:53:10 +13:00
|
|
|
|
{
|
2024-03-24 03:34:56 +11:00
|
|
|
|
var quantity = ratio * args.Quantity.Float() / Atmospherics.BreathMolesToReagentMultiplier;
|
|
|
|
|
|
if (quantity < 0)
|
|
|
|
|
|
quantity = Math.Max(quantity, -lung.Air[(int)gas]);
|
|
|
|
|
|
lung.Air.AdjustMoles(gas, quantity);
|
2022-02-10 17:53:10 +13:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|