2024-08-02 13:51:54 +03:00
|
|
|
using Content.Shared._CP14.MeleeWeapon.Components;
|
2024-07-22 12:18:08 +03:00
|
|
|
using Content.Shared.Damage;
|
|
|
|
|
using Content.Shared.Weapons.Melee.Events;
|
|
|
|
|
|
2024-08-02 13:51:54 +03:00
|
|
|
namespace Content.Shared._CP14.MeleeWeapon.EntitySystems;
|
2024-07-22 12:18:08 +03:00
|
|
|
|
|
|
|
|
public sealed class CP14MeleeSelfDamageSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
SubscribeLocalEvent<CP14MeleeSelfDamageComponent, MeleeHitEvent>(OnMeleeHit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMeleeHit(Entity<CP14MeleeSelfDamageComponent> ent, ref MeleeHitEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!args.IsHit)
|
|
|
|
|
return;
|
|
|
|
|
if (args.HitEntities.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
_damageable.TryChangeDamage(ent, ent.Comp.DamageToSelf);
|
|
|
|
|
}
|
|
|
|
|
}
|