Melee refactor (#10897)

Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2022-09-29 15:51:59 +10:00
committed by GitHub
parent c583b7b361
commit f51248ecaa
140 changed files with 2440 additions and 1824 deletions

View File

@@ -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);
}
}
}