1
0

DamageGroupTrigger.cs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. using Content.Shared.Damage;
  2. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  3. using Content.Shared.Damage.Prototypes;
  4. namespace Content.Server.Destructible.Thresholds.Triggers
  5. {
  6. /// <summary>
  7. /// A trigger that will activate when the amount of damage received
  8. /// of the specified class is above the specified threshold.
  9. /// </summary>
  10. [Serializable]
  11. [DataDefinition]
  12. public sealed partial class DamageGroupTrigger : IThresholdTrigger
  13. {
  14. [DataField("damageGroup", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<DamageGroupPrototype>))]
  15. public string DamageGroup { get; set; } = default!;
  16. /// <summary>
  17. /// The amount of damage at which this threshold will trigger.
  18. /// </summary>
  19. [DataField("damage", required: true)]
  20. public int Damage { get; set; } = default!;
  21. public bool Reached(DamageableComponent damageable, DestructibleSystem system)
  22. {
  23. return damageable.DamagePerGroup[DamageGroup] >= Damage;
  24. }
  25. }
  26. }