fish-station/Content.Server/_Sunrise/OnHit/OnHitSystem.cs
iertis 6541699296
Абдукторы from Starlight (#1141)
Co-authored-by: ss14-Starlight <ss14-Starlight@outlook.com>
Co-authored-by: Rinary <rinary.super@gmail.com>
Co-authored-by: SplikZerys <136282037+SplikZerys@users.noreply.github.com>
2025-07-08 05:26:28 -04:00

37 lines
1.2 KiB
C#

using Content.Shared._Sunrise.Antags.Abductor;
using Content.Shared._Sunrise.Medical.Surgery;
using Content.Shared.Actions;
using Content.Shared.DoAfter;
using Robust.Shared.Prototypes;
using Content.Shared.Cuffs.Components;
using Content.Shared.Damage.Components;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared._Sunrise.OnHit;
namespace Content.Server._Sunrise.Combat.OnHit;
public sealed partial class OnHitSystem : SharedOnHitSystem
{
public override void Initialize()
{
SubscribeLocalEvent<CuffsOnHitComponent, CuffsOnHitDoAfter>(OnCuffsOnHitDoAfter);
base.Initialize();
}
private void OnCuffsOnHitDoAfter(Entity<CuffsOnHitComponent> ent, ref CuffsOnHitDoAfter args)
{
if (!args.Args.Target.HasValue || args.Handled || args.Cancelled) return;
var user = args.Args.User;
var target = args.Args.Target.Value;
if (!TryComp<CuffableComponent>(target, out var cuffable) || cuffable.Container.Count != 0)
return;
args.Handled = true;
var handcuffs = SpawnNextToOrDrop(ent.Comp.HandcuffProtorype, args.User);
if (!_cuffs.TryAddNewCuffs(target, user, handcuffs, cuffable))
QueueDel(handcuffs);
}
}