Files
crystall-punk-14/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs
Julian Giebel 1d0bf979fb Adds the pressure medipen and adds the emergency suit to emergency lockers (#7880)
* Implement pressure medipen
Add the emergency suit to emergency lockers
Increase leporazine temperature change

* Fix typo in translation file

* Fix ignored component name

* Address reviews

* Revert changes to submodule commit
2022-05-06 14:44:29 -07:00

53 lines
1.7 KiB
C#

using Content.Server.Chemistry.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Weapons.Melee;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
namespace Content.Server.Chemistry.EntitySystems
{
public sealed partial class ChemistrySystem
{
private void InitializeHypospray()
{
SubscribeLocalEvent<HyposprayComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<HyposprayComponent, ClickAttackEvent>(OnClickAttack);
SubscribeLocalEvent<HyposprayComponent, SolutionChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<HyposprayComponent, UseInHandEvent>(OnUseInHand);
}
private void OnUseInHand(EntityUid uid, HyposprayComponent component, UseInHandEvent args)
{
if (args.Handled) return;
component.TryDoInject(args.User, args.User);
args.Handled = true;
}
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);
}
}
}