* Commit * ploop * borger --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using Content.Shared.Damage;
|
|
using Content.Shared.FixedPoint;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.EntityConditions.Conditions;
|
|
|
|
/// <summary>
|
|
/// Returns true if this entity can take damage and if its total damage is within a specified minimum and maximum.
|
|
/// </summary>
|
|
/// <inheritdoc cref="EntityConditionSystem{T, TCondition}"/>
|
|
public sealed partial class TotalDamageEntityConditionSystem : EntityConditionSystem<DamageableComponent, TotalDamageCondition>
|
|
{
|
|
protected override void Condition(Entity<DamageableComponent> entity, ref EntityConditionEvent<TotalDamageCondition> args)
|
|
{
|
|
var total = entity.Comp.TotalDamage;
|
|
args.Result = total >= args.Condition.Min && total <= args.Condition.Max;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc cref="EntityCondition"/>
|
|
public sealed partial class TotalDamageCondition : EntityConditionBase<TotalDamageCondition>
|
|
{
|
|
[DataField]
|
|
public FixedPoint2 Max = FixedPoint2.MaxValue;
|
|
|
|
[DataField]
|
|
public FixedPoint2 Min = FixedPoint2.Zero;
|
|
|
|
public override string EntityConditionGuidebookText(IPrototypeManager prototype) =>
|
|
Loc.GetString("entity-condition-guidebook-total-damage",
|
|
("max", Max == FixedPoint2.MaxValue ? int.MaxValue : Max.Float()),
|
|
("min", Min.Float()));
|
|
}
|