Harmbaton rework + remove MeleeInteractEvent (#8157)

This commit is contained in:
Kara
2022-05-14 19:10:34 -07:00
committed by GitHub
parent c3f0f4625b
commit 65445711e0
4 changed files with 4 additions and 95 deletions

View File

@@ -34,7 +34,6 @@ namespace Content.Server.Stunnable
base.Initialize();
SubscribeLocalEvent<StunbatonComponent, MeleeHitEvent>(OnMeleeHit);
SubscribeLocalEvent<StunbatonComponent, MeleeInteractEvent>(OnMeleeInteract);
SubscribeLocalEvent<StunbatonComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<StunbatonComponent, ThrowDoHitEvent>(OnThrowCollide);
SubscribeLocalEvent<StunbatonComponent, PowerCellChangedEvent>(OnPowerCellChanged);
@@ -43,7 +42,7 @@ namespace Content.Server.Stunnable
private void OnMeleeHit(EntityUid uid, StunbatonComponent comp, MeleeHitEvent args)
{
if (!comp.Activated || !args.HitEntities.Any())
if (!comp.Activated || !args.HitEntities.Any() || args.Handled)
return;
if (!_cellSystem.TryGetBatteryFromSlot(uid, out var battery) || !battery.TryUseCharge(comp.EnergyPerUse))
@@ -54,19 +53,9 @@ namespace Content.Server.Stunnable
StunEntity(entity, comp);
SendPowerPulse(entity, args.User, uid);
}
}
private void OnMeleeInteract(EntityUid uid, StunbatonComponent comp, MeleeInteractEvent args)
{
if (!comp.Activated)
return;
if (!_cellSystem.TryGetBatteryFromSlot(uid, out var battery) || !battery.TryUseCharge(comp.EnergyPerUse))
return;
args.CanInteract = true;
StunEntity(args.Entity, comp);
SendPowerPulse(args.Entity, args.User, uid);
// No combat should occur if we successfully stunned.
args.Handled = true;
}
private void OnUseInHand(EntityUid uid, StunbatonComponent comp, UseInHandEvent args)