CatStation/Content.Server/Damage/Systems/DamageOnHitSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

24 lines
803 B
C#

using Content.Server.Damage.Components;
using Content.Shared.Weapons.Melee.Events;
using System.Linq;
using Content.Shared.Damage.Systems;
namespace Content.Server.Damage.Systems;
public sealed partial class DamageOnHitSystem : EntitySystem
{
[Dependency] private DamageableSystem _damageableSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DamageOnHitComponent, MeleeHitEvent>(DamageItem);
}
// Looks for a hit, then damages the held item an appropriate amount.
private void DamageItem(EntityUid uid, DamageOnHitComponent component, MeleeHitEvent args)
{
if (args.HitEntities.Any()) {
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
}
}
}