* Update DamageableSystem to modern standards * DamageContainerId -> DamageContainerID with lint flag * Replace strings with protoids * Make CVar subscription declarations all consistently whitespaced * ChangeDamage -> TryChangeDamage, cope with C# jank * Revert event signature changes * Restore a comment * Re-add two queries * Init the queries * Use appearanceQuery in DamageChanged * Use damageableQuery in TryChangeDamage * Use damageableQuery in SetDamageModifierSetId * Final cleanup, fix sandboxing * Rectify ExplosionSystem:::ProcessEntity's call to TryChangeDamage * Re-organize DamageableSystem * first big fuck you breaking change. * THATS A LOT OF DAMAGE!!! * Fix test fails * test fixes 2 * push it --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using Content.Shared.Damage.Components;
|
|
using Content.Shared.Damage.Prototypes;
|
|
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 damage of a given damage group is within a specified minimum and maximum.
|
|
/// </summary>
|
|
/// <inheritdoc cref="EntityConditionSystem{T, TCondition}"/>
|
|
public sealed partial class DamageGroupEntityConditionSystem : EntityConditionSystem<DamageableComponent, DamageGroupCondition>
|
|
{
|
|
protected override void Condition(Entity<DamageableComponent> entity, ref EntityConditionEvent<DamageGroupCondition> args)
|
|
{
|
|
var value = entity.Comp.DamagePerGroup[args.Condition.DamageGroup];
|
|
args.Result = value >= args.Condition.Min && value <= args.Condition.Max;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc cref="EntityCondition"/>
|
|
public sealed partial class DamageGroupCondition : EntityConditionBase<DamageGroupCondition>
|
|
{
|
|
[DataField]
|
|
public FixedPoint2 Max = FixedPoint2.MaxValue;
|
|
|
|
[DataField]
|
|
public FixedPoint2 Min = FixedPoint2.Zero;
|
|
|
|
[DataField(required: true)]
|
|
public ProtoId<DamageGroupPrototype> DamageGroup;
|
|
|
|
public override string EntityConditionGuidebookText(IPrototypeManager prototype) =>
|
|
Loc.GetString("entity-condition-guidebook-group-damage",
|
|
("max", Max == FixedPoint2.MaxValue ? int.MaxValue : Max.Float()),
|
|
("min", Min.Float()),
|
|
("type", prototype.Index(DamageGroup).LocalizedName));
|
|
}
|