2023-06-29 12:27:08 -07:00
|
|
|
using Content.Server.Damage.Components;
|
|
|
|
|
using Content.Shared.Damage;
|
|
|
|
|
using Robust.Shared.Player;
|
|
|
|
|
using Content.Shared.Weapons.Melee.Events;
|
2023-07-01 12:01:50 -07:00
|
|
|
using System.Linq;
|
2023-06-29 12:27:08 -07:00
|
|
|
|
|
|
|
|
namespace Content.Server.Damage.Systems;
|
|
|
|
|
|
|
|
|
|
public sealed class DamageOnHitSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly 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)
|
|
|
|
|
{
|
2023-07-01 12:01:50 -07:00
|
|
|
if (args.HitEntities.Any()) {
|
|
|
|
|
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
|
|
|
|
|
}
|
2023-06-29 12:27:08 -07:00
|
|
|
}
|
|
|
|
|
}
|