mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-15 03:32:07 +01:00
* it's now impossible to unbuckle when cuffed, cuffs must be removed first * can't unbuckle if any hand is handcuffed * fixed hand count check * added popup message
62 lines
2.7 KiB
C#
62 lines
2.7 KiB
C#
using Content.Shared.Cuffs;
|
|
using JetBrains.Annotations;
|
|
using Content.Shared.Cuffs.Components;
|
|
using Robust.Shared.GameStates;
|
|
using Content.Shared.Buckle.Components;
|
|
using Content.Shared.Hands.Components;
|
|
using Robust.Shared.Network;
|
|
using Content.Server.Popups;
|
|
|
|
namespace Content.Server.Cuffs
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class CuffableSystem : SharedCuffableSystem
|
|
{
|
|
[Dependency] private readonly INetManager _netManager = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<HandcuffComponent, ComponentGetState>(OnHandcuffGetState);
|
|
SubscribeLocalEvent<CuffableComponent, ComponentGetState>(OnCuffableGetState);
|
|
SubscribeLocalEvent<CuffableComponent, BuckleAttemptEvent>(OnBuckleAttemptEvent);
|
|
}
|
|
|
|
private void OnHandcuffGetState(EntityUid uid, HandcuffComponent component, ref ComponentGetState args)
|
|
{
|
|
args.State = new HandcuffComponentState(component.OverlayIconState);
|
|
}
|
|
|
|
private void OnCuffableGetState(EntityUid uid, CuffableComponent component, ref ComponentGetState args)
|
|
{
|
|
// there are 2 approaches i can think of to handle the handcuff overlay on players
|
|
// 1 - make the current RSI the handcuff type that's currently active. all handcuffs on the player will appear the same.
|
|
// 2 - allow for several different player overlays for each different cuff type.
|
|
// approach #2 would be more difficult/time consuming to do and the payoff doesn't make it worth it.
|
|
// right now we're doing approach #1.
|
|
HandcuffComponent? cuffs = null;
|
|
if (component.CuffedHandCount > 0)
|
|
TryComp(component.LastAddedCuffs, out cuffs);
|
|
args.State = new CuffableComponentState(component.CuffedHandCount,
|
|
component.CanStillInteract,
|
|
cuffs?.CuffedRSI,
|
|
$"{cuffs?.OverlayIconState}-{component.CuffedHandCount}",
|
|
cuffs?.Color);
|
|
// the iconstate is formatted as blah-2, blah-4, blah-6, etc.
|
|
// the number corresponds to how many hands are cuffed.
|
|
}
|
|
|
|
private void OnBuckleAttemptEvent(EntityUid uid, CuffableComponent component, ref BuckleAttemptEvent args)
|
|
{
|
|
if (TryComp<HandsComponent>(uid, out var hands) && component.CuffedHandCount == hands.Count)
|
|
{
|
|
args.Cancelled = true;
|
|
var message = Loc.GetString("handcuff-component-cuff-interrupt-buckled-message");
|
|
if (_netManager.IsServer)
|
|
_popupSystem.PopupEntity(message, uid);
|
|
}
|
|
}
|
|
}
|
|
}
|