Chem injectors ECS (#6366)

This commit is contained in:
metalgearsloth
2022-02-07 00:34:13 +11:00
committed by GitHub
parent 7bc7ec8cb0
commit da1007b7f1
6 changed files with 421 additions and 376 deletions

View File

@@ -1,44 +0,0 @@
using Content.Server.Chemistry.Components;
using Content.Shared.Interaction;
using Content.Shared.Weapons.Melee;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
namespace Content.Server.Chemistry.EntitySystems
{
[UsedImplicitly]
public class HypospraySystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HyposprayComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<HyposprayComponent, ClickAttackEvent>(OnClickAttack);
SubscribeLocalEvent<HyposprayComponent, SolutionChangedEvent>(OnSolutionChange);
}
private void OnSolutionChange(EntityUid uid, HyposprayComponent component, SolutionChangedEvent args)
{
Dirty(component);
}
public void OnAfterInteract(EntityUid uid, HyposprayComponent comp, AfterInteractEvent args)
{
if (!args.CanReach)
return;
var target = args.Target;
var user = args.User;
comp.TryDoInject(target, user);
}
public void OnClickAttack(EntityUid uid, HyposprayComponent comp, ClickAttackEvent args)
{
if (args.Target == null)
return;
comp.TryDoInject(args.Target.Value, args.User);
}
}
}