using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared._Offbrand.Wounds;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(BrainDamageSystem))]
public sealed partial class BrainDamageComponent : Component
{
///
/// The maximum amount of damage this entity's brain can take
///
[DataField(required: true)]
public FixedPoint2 MaxDamage;
///
/// The current amount of accrued damage
///
[DataField(required: true), AutoNetworkedField]
public FixedPoint2 Damage;
///
/// The maximum amount of oxygen this entity's brain can store
///
[DataField(required: true)]
public FixedPoint2 MaxOxygen;
///
/// The current amount of stored brain oxygen
///
[DataField(required: true), AutoNetworkedField]
public FixedPoint2 Oxygen;
}
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
[Access(typeof(BrainDamageSystem))]
public sealed partial class BrainDamageOxygenationComponent : Component
{
///
/// The thresholds for how much damage will occur from inadequate oxygenation.
/// - Chance: how much of a chance this threshold will have to trigger
/// - AtMost: this threshold will not trigger if there is more than this amount of brain damage
/// - Amount: how much brain damage will be dealt if it triggers
/// Lowest key is selected.
///
[DataField(required: true)]
public SortedDictionary OxygenationDamageThresholds;
///
/// The thresholds for how much oxygen will be depleted from inadequate oxygenation.
/// - Chance: how much of a chance this threshold will have to trigger
/// - Amount: how much oxygen will be depleted if it triggers
/// Lowest key is selected.
///
[DataField(required: true)]
public SortedDictionary OxygenDepletionThresholds;
///
/// How much oxygen will regenerate if none of the trigger
///
[DataField(required: true)]
public FixedPoint2 OxygenRegeneration;
///
/// How much brain damage can be accumulated before passive healing will stop if none of the trigger
///
[DataField(required: true)]
public FixedPoint2 MaxPassivelyHealableDamage;
///
/// How much damage will be healed if the brain is capable of healing
///
[DataField(required: true)]
public FixedPoint2 DamageHealing;
[DataField, AutoNetworkedField]
public float UpdateIntervalMultiplier = 1f;
[ViewVariables]
public TimeSpan AdjustedUpdateInterval => UpdateInterval * UpdateIntervalMultiplier;
[DataField]
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(2);
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
[AutoNetworkedField]
public TimeSpan? LastUpdate;
}
///
/// Raised on an entity to modify the chance for brain damage to be dealt
///
[ByRefEvent]
public record struct BeforeDealBrainDamage(double Chance);
///
/// Raised on an entity to modify the chance for brain damage to be dealt
///
[ByRefEvent]
public record struct BeforeDepleteBrainOxygen(double Chance);
///
/// Raised on an entity to determine if it should heal brain damage
///
[ByRefEvent]
public record struct BeforeHealBrainDamage(bool Heal);
///
/// Raised on an entity after its brain oxygen has changed
///
[ByRefEvent]
public record struct AfterBrainOxygenChanged;
///
/// Raised on an entity after its brain damage has changed
///
[ByRefEvent]
public record struct AfterBrainDamageChanged;