using Content.Server.Body.Systems;
using Content.Shared.Atmos;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Damage;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Body.Components
{
[RegisterComponent, Access(typeof(RespiratorSystem)), AutoGenerateComponentPause]
public sealed partial class RespiratorComponent : Component
{
///
/// Gas container for this entity
///
[DataField]
public GasMixture Air = new()
{
Volume = 6, // 6 liters, the average lung capacity for a human according to Google
Temperature = Atmospherics.NormalBodyTemperature
};
///
/// Volume of our breath in liters
///
[DataField]
public float BreathVolume = Atmospherics.BreathVolume;
///
/// How much of the gas we inhale is metabolized? Value range is (0, 1]
///
[DataField]
public float Ratio = 1.0f;
///
/// The next time that this body will inhale or exhale.
///
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
public TimeSpan NextUpdate;
///
/// The interval between updates. Each update is either inhale or exhale,
/// so a full cycle takes twice as long.
///
[DataField]
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(2);
///
/// Multiplier applied to for adjusting based on metabolic rate multiplier.
///
[DataField]
public float UpdateIntervalMultiplier = 1f;
///
/// Adjusted update interval based off of the multiplier value.
///
[ViewVariables]
public TimeSpan AdjustedUpdateInterval => UpdateInterval * UpdateIntervalMultiplier;
///
/// Saturation level. Reduced by UpdateInterval each tick.
/// Can be thought of as 'how many seconds you have until you start suffocating' in this configuration.
///
[DataField]
public float Saturation = 5.0f;
///
/// At what level of saturation will you begin to suffocate?
///
[DataField]
public float SuffocationThreshold;
[DataField]
public float MaxSaturation = 5.0f;
[DataField]
public float MinSaturation = -2.0f;
// TODO HYPEROXIA?
[DataField(required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier Damage = default!;
[DataField(required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier DamageRecovery = default!;
[DataField]
public TimeSpan GaspEmoteCooldown = TimeSpan.FromSeconds(8);
[ViewVariables]
public TimeSpan LastGaspEmoteTime;
///
/// The emote when gasps
///
[DataField]
public ProtoId GaspEmote = "Gasp";
///
/// How many cycles in a row has the mob been under-saturated?
///
[ViewVariables]
public int SuffocationCycles = 0;
///
/// How many cycles in a row does it take for the suffocation alert to pop up?
///
[ViewVariables]
public int SuffocationCycleThreshold = 3;
[ViewVariables]
public RespiratorStatus Status = RespiratorStatus.Inhaling;
}
}
public enum RespiratorStatus
{
Inhaling,
Exhaling
}