using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityConditions.Conditions;
///
/// Returns true if this entity can take damage and if its damage of a given damage group is within a specified minimum and maximum.
///
///
public sealed partial class DamageGroupEntityConditionSystem : EntityConditionSystem
{
protected override void Condition(Entity entity, ref EntityConditionEvent args)
{
var value = entity.Comp.DamagePerGroup[args.Condition.DamageGroup];
args.Result = value >= args.Condition.Min && value <= args.Condition.Max;
}
}
///
public sealed partial class DamageGroupCondition : EntityConditionBase
{
[DataField]
public FixedPoint2 Max = FixedPoint2.MaxValue;
[DataField]
public FixedPoint2 Min = FixedPoint2.Zero;
[DataField(required: true)]
public ProtoId DamageGroup;
public override string EntityConditionGuidebookText(IPrototypeManager prototype) =>
Loc.GetString("reagent-effect-condition-guidebook-group-damage",
("max", Max == FixedPoint2.MaxValue ? int.MaxValue : Max.Float()),
("min", Min.Float()),
("type", prototype.Index(DamageGroup).LocalizedName));
}