using Content.Shared.Administration.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Alert;
+using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Buckle.Components;
using Content.Shared.Cuffs.Components;
using Content.Shared.Damage;
SubscribeLocalEvent<HandcuffComponent, AfterInteractEvent>(OnCuffAfterInteract);
SubscribeLocalEvent<HandcuffComponent, MeleeHitEvent>(OnCuffMeleeHit);
SubscribeLocalEvent<HandcuffComponent, AddCuffDoAfterEvent>(OnAddCuffDoAfter);
+ SubscribeLocalEvent<HandcuffComponent, VirtualItemDeletedEvent>(OnCuffVirtualItemDeleted);
}
private void OnUncuffAttempt(ref UncuffAttemptEvent args)
return;
component.CanStillInteract = canInteract;
- Dirty(component);
+ Dirty(uid, component);
_actionBlocker.UpdateCanMove(uid);
if (component.CanStillInteract)
("otherName", Identity.Name(user, EntityManager, target))), target, target);
}
}
+ }
+ private void OnCuffVirtualItemDeleted(EntityUid uid, HandcuffComponent component, VirtualItemDeletedEvent args)
+ {
+ Uncuff(args.User, null, uid, cuff: component);
}
/// <summary>
{
if (!cuffable.Container.ContainedEntities.Contains(cuffsToRemove.Value))
{
- Logger.Warning("A user is trying to remove handcuffs that aren't in the owner's container. This should never happen!");
+ Log.Warning("A user is trying to remove handcuffs that aren't in the owner's container. This should never happen!");
}
}
_audio.PlayPredicted(isOwner ? cuff.StartBreakoutSound : cuff.StartUncuffSound, target, user);
}
- public void Uncuff(EntityUid target, EntityUid user, EntityUid cuffsToRemove, CuffableComponent? cuffable = null, HandcuffComponent? cuff = null)
+ public void Uncuff(EntityUid target, EntityUid? user, EntityUid cuffsToRemove, CuffableComponent? cuffable = null, HandcuffComponent? cuff = null)
{
if (!Resolve(target, ref cuffable) || !Resolve(cuffsToRemove, ref cuff))
return;
- var attempt = new UncuffAttemptEvent(user, target);
- RaiseLocalEvent(user, ref attempt);
- if (attempt.Cancelled)
- return;
+ if (user != null)
+ {
+ var attempt = new UncuffAttemptEvent(user.Value, target);
+ RaiseLocalEvent(user.Value, ref attempt);
+ if (attempt.Cancelled)
+ return;
+ }
_audio.PlayPredicted(cuff.EndUncuffSound, target, user);
cuffable.Container.Remove(cuffsToRemove);
-
if (_net.IsServer)
{
// Handles spawning broken cuffs on server to avoid client misprediction
// Only play popups on server because popups suck
if (cuffable.CuffedHandCount == 0)
{
- _popup.PopupEntity(Loc.GetString("cuffable-component-remove-cuffs-success-message"), user, user);
+ if (user != null)
+ _popup.PopupEntity(Loc.GetString("cuffable-component-remove-cuffs-success-message"), user.Value, user.Value);
- if (target != user)
+ if (target != user && user != null)
{
_popup.PopupEntity(Loc.GetString("cuffable-component-remove-cuffs-by-other-success-message",
- ("otherName", Identity.Name(user, EntityManager, user))), target, target);
+ ("otherName", Identity.Name(user.Value, EntityManager, user))), target, target);
_adminLog.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(user):player} has successfully uncuffed {ToPrettyString(target):player}");
}
$"{ToPrettyString(user):player} has successfully uncuffed themselves");
}
}
- else
+ else if (user != null)
{
if (user != target)
{
_popup.PopupEntity(Loc.GetString("cuffable-component-remove-cuffs-partial-success-message",
("cuffedHandCount", cuffable.CuffedHandCount),
- ("otherName", Identity.Name(user, EntityManager, user))), user, user);
+ ("otherName", Identity.Name(user.Value, EntityManager, user.Value))), user.Value, user.Value);
_popup.PopupEntity(Loc.GetString(
"cuffable-component-remove-cuffs-by-other-partial-success-message",
- ("otherName", Identity.Name(user, EntityManager, user)),
+ ("otherName", Identity.Name(user.Value, EntityManager, user.Value)),
("cuffedHandCount", cuffable.CuffedHandCount)), target, target);
}
else
{
_popup.PopupEntity(Loc.GetString("cuffable-component-remove-cuffs-partial-success-message",
- ("cuffedHandCount", cuffable.CuffedHandCount)), user, user);
+ ("cuffedHandCount", cuffable.CuffedHandCount)), user.Value, user.Value);
}
}
}