Melee refactor (#10897)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
|
||||
namespace Content.Server.Chemistry.EntitySystems
|
||||
{
|
||||
@@ -10,7 +13,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
private void InitializeHypospray()
|
||||
{
|
||||
SubscribeLocalEvent<HyposprayComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
SubscribeLocalEvent<HyposprayComponent, ClickAttackEvent>(OnClickAttack);
|
||||
SubscribeLocalEvent<HyposprayComponent, MeleeHitEvent>(OnAttack);
|
||||
SubscribeLocalEvent<HyposprayComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||
SubscribeLocalEvent<HyposprayComponent, UseInHandEvent>(OnUseInHand);
|
||||
}
|
||||
@@ -39,12 +42,12 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
comp.TryDoInject(target, user);
|
||||
}
|
||||
|
||||
public void OnClickAttack(EntityUid uid, HyposprayComponent comp, ClickAttackEvent args)
|
||||
public void OnAttack(EntityUid uid, HyposprayComponent comp, MeleeHitEvent args)
|
||||
{
|
||||
if (args.Target == null)
|
||||
if (!args.HitEntities.Any())
|
||||
return;
|
||||
|
||||
comp.TryDoInject(args.Target.Value, args.User);
|
||||
comp.TryDoInject(args.HitEntities.First(), args.User);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user