using Content.Shared.Damage.Prototypes;
using Content.Shared.Damage.Systems;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs;
using Content.Shared.StatusIcon;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Damage.Components;
///
/// Component that allows entities to take damage.
///
///
/// The supported damage types are specified using a s. DamageContainers
/// may also have resistances to certain damage types, defined via a .
///
[RegisterComponent]
[NetworkedComponent]
[Access(typeof(DamageableSystem), Other = AccessPermissions.ReadExecute)]
public sealed partial class DamageableComponent : Component
{
///
/// This specifies what damage types are supported by this component.
/// If null, all damage types will be supported.
///
[DataField("damageContainer")]
// ReSharper disable once InconsistentNaming - This is wrong but fixing it is potentially annoying for downstreams.
public ProtoId? DamageContainerID;
///
/// This will be applied to any damage that is dealt to this container,
/// unless the damage explicitly ignores resistances.
///
///
/// Though DamageModifierSets can be deserialized directly, we only want to use the prototype version here
/// to reduce duplication.
///
[DataField("damageModifierSet")]
public ProtoId? DamageModifierSetId;
///
/// All the damage information is stored in this .
///
///
/// If this data-field is specified, this allows damageable components to be initialized with non-zero damage.
///
[DataField(readOnly: true)] //TODO FULL GAME SAVE
public DamageSpecifier Damage = new();
///
/// Damage, indexed by ID keys.
///
///
/// Groups which have no members that are supported by this component will not be present in this
/// dictionary.
///
[ViewVariables] public Dictionary DamagePerGroup = new();
///
/// The sum of all damages in the DamageableComponent.
///
[ViewVariables]
public FixedPoint2 TotalDamage;
[DataField("radiationDamageTypes")]
// ReSharper disable once UseCollectionExpression - Cannot refactor this as it's a potential sandbox violation.
public List> RadiationDamageTypeIDs = new() { "Radiation" };
///
/// Group types that affect the pain overlay.
///
/// TODO: Add support for adding damage types specifically rather than whole damage groups
[DataField]
// ReSharper disable once UseCollectionExpression - Cannot refactor this as it's a potential sandbox volation.
public List> PainDamageGroups = new() { "Brute", "Burn" };
[DataField]
public Dictionary> HealthIcons = new()
{
{ MobState.Alive, "HealthIconFine" },
{ MobState.Critical, "HealthIconCritical" },
{ MobState.Dead, "HealthIconDead" },
};
[DataField]
public ProtoId RottingIcon = "HealthIconRotting";
[DataField]
public FixedPoint2? HealthBarThreshold;
}
[Serializable, NetSerializable]
public sealed class DamageableComponentState(
Dictionary damageDict,
ProtoId? damageContainerId,
ProtoId? modifierSetId,
FixedPoint2? healthBarThreshold)
: ComponentState
{
public readonly Dictionary DamageDict = damageDict;
public readonly ProtoId? DamageContainerId = damageContainerId;
public readonly ProtoId? ModifierSetId = modifierSetId;
public readonly FixedPoint2? HealthBarThreshold = healthBarThreshold;
}