Files
wwdpublic/Content.Server/_Goobstation/Weapons/Ranged/SyringeGunSystem.cs
Kutosss 76bf1599b1 [PORT] Шприцеметы (#439)
* шприцеметы епта

* Update PacifismAllowedGunComponent.cs

* фикс

* Update tags.yml

* Update lathe.yml
2025-04-12 08:55:59 +03:00

40 lines
1.5 KiB
C#

using Content.Server.Chemistry.Components;
using Content.Shared._Goobstation.Weapons.Ranged;
using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Weapons.Ranged.Systems;
namespace Content.Server._Goobstation.Weapons.Ranged;
/// <summary>
/// System for handling projectiles and altering their properties when fired from a Syringe Gun.
/// </summary>
public sealed class SyringeGunSystem : EntitySystem
{
public override void Initialize()
{
SubscribeLocalEvent<SyringeGunComponent, AmmoShotEvent>(OnFire);
SubscribeLocalEvent<SyringeGunComponent, AttemptShootEvent>(OnShootAttempt);
}
private void OnShootAttempt(Entity<SyringeGunComponent> ent, ref AttemptShootEvent args)
{
args.ThrowItems = true;
}
private void OnFire(Entity<SyringeGunComponent> gun, ref AmmoShotEvent args)
{
foreach (var projectile in args.FiredProjectiles)
{
if (TryComp(projectile, out SolutionInjectWhileEmbeddedComponent? whileEmbedded))
{
whileEmbedded.Injections = null; // uncap the injection maximum
whileEmbedded.PierceArmorOverride = gun.Comp.PierceArmor;
whileEmbedded.SpeedMultiplier = gun.Comp.InjectionSpeedMultiplier; // store it in the component to reset it
whileEmbedded.UpdateInterval /= whileEmbedded.SpeedMultiplier;
}
if (TryComp(projectile, out SolutionInjectOnEmbedComponent? onEmbed))
onEmbed.PierceArmorOverride = gun.Comp.PierceArmor;
}
}
}