Remove server-sprite references from handcuffs (#13515)
This commit is contained in:
@@ -18,6 +18,7 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Server.Recycling.Components;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Cuffs.Components
|
||||
{
|
||||
@@ -271,22 +272,16 @@ namespace Content.Server.Cuffs.Components
|
||||
SoundSystem.Play(cuff.EndUncuffSound.GetSound(), Filter.Pvs(Owner), Owner);
|
||||
|
||||
_entMan.EntitySysManager.GetEntitySystem<HandVirtualItemSystem>().DeleteInHandsMatching(user, cuffsToRemove);
|
||||
_entMan.EntitySysManager.GetEntitySystem<SharedHandsSystem>().PickupOrDrop(user, cuffsToRemove);
|
||||
|
||||
if (cuff.BreakOnRemove)
|
||||
{
|
||||
cuff.Broken = true;
|
||||
|
||||
var meta = _entMan.GetComponent<MetaDataComponent>(cuffsToRemove);
|
||||
meta.EntityName = Loc.GetString(cuff.BrokenName);
|
||||
meta.EntityDescription = Loc.GetString(cuff.BrokenDesc);
|
||||
|
||||
if (_entMan.TryGetComponent<SpriteComponent>(cuffsToRemove, out var sprite) && cuff.BrokenState != null)
|
||||
{
|
||||
sprite.LayerSetState(0, cuff.BrokenState); // TODO: safety check to see if RSI contains the state?
|
||||
}
|
||||
|
||||
_entMan.EnsureComponent<RecyclableComponent>(cuffsToRemove);
|
||||
_entMan.QueueDeleteEntity(cuffsToRemove);
|
||||
var trash = _entMan.SpawnEntity(cuff.BrokenPrototype, MapCoordinates.Nullspace);
|
||||
_entMan.EntitySysManager.GetEntitySystem<SharedHandsSystem>().PickupOrDrop(user, trash);
|
||||
}
|
||||
else
|
||||
{
|
||||
_entMan.EntitySysManager.GetEntitySystem<SharedHandsSystem>().PickupOrDrop(user, cuffsToRemove);
|
||||
}
|
||||
|
||||
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? handsComponent) && handsComponent.SortedHands.Count() > CuffedHandCount;
|
||||
|
||||
@@ -7,6 +7,8 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Stunnable;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Cuffs.Components
|
||||
{
|
||||
@@ -47,6 +49,12 @@ namespace Content.Server.Cuffs.Components
|
||||
[DataField("breakOnRemove")]
|
||||
public bool BreakOnRemove { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Will the cuffs break when removed?
|
||||
/// </summary>
|
||||
[DataField("brokenPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string? BrokenPrototype { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The path of the RSI file used for the player cuffed overlay.
|
||||
/// </summary>
|
||||
@@ -59,42 +67,6 @@ namespace Content.Server.Cuffs.Components
|
||||
[DataField("bodyIconState")]
|
||||
public string? OverlayIconState { get; set; } = "body-overlay";
|
||||
|
||||
/// <summary>
|
||||
/// The iconstate used for broken handcuffs
|
||||
/// </summary>
|
||||
[DataField("brokenIconState")]
|
||||
public string? BrokenState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The iconstate used for broken handcuffs
|
||||
/// </summary>
|
||||
[DataField("brokenName", readOnly: true)]
|
||||
public string BrokenName { get; private set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// The iconstate used for broken handcuffs
|
||||
/// </summary>
|
||||
[DataField("brokenDesc", readOnly: true)]
|
||||
public string BrokenDesc { get; private set; } = "";
|
||||
|
||||
[ViewVariables]
|
||||
public bool Broken
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isBroken;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_isBroken != value)
|
||||
{
|
||||
_isBroken = value;
|
||||
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataField("startCuffSound")]
|
||||
public SoundSpecifier StartCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_start.ogg");
|
||||
|
||||
@@ -112,19 +84,11 @@ namespace Content.Server.Cuffs.Components
|
||||
[DataField("color")]
|
||||
public Color Color { get; set; } = Color.White;
|
||||
|
||||
// Non-exposed data fields
|
||||
private bool _isBroken = false;
|
||||
|
||||
/// <summary>
|
||||
/// Used to prevent DoAfter getting spammed.
|
||||
/// </summary>
|
||||
public bool Cuffing;
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new HandcuffedComponentState(Broken ? BrokenState : string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the cuffed state of an entity
|
||||
/// </summary>
|
||||
|
||||
@@ -86,12 +86,6 @@ namespace Content.Server.Cuffs
|
||||
if (component.Cuffing || !EntityManager.TryGetComponent<CuffableComponent>(target, out var cuffed))
|
||||
return;
|
||||
|
||||
if (component.Broken)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("handcuff-component-cuffs-broken-error"), user, user);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityManager.TryGetComponent<HandsComponent?>(target, out var hands))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("handcuff-component-target-has-no-hands-error",("targetName", target)), user, user);
|
||||
|
||||
Reference in New Issue
Block a user