Make pulled and cuffed players unable to move (#3227)

This commit is contained in:
DrSmugleaf
2021-02-16 02:51:52 +01:00
committed by GitHub
parent 17a224ad2c
commit 9f408945de
2 changed files with 15 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ namespace Content.Client.GameObjects.Components.ActionBlocking
public class CuffableComponent : SharedCuffableComponent public class CuffableComponent : SharedCuffableComponent
{ {
[ViewVariables] [ViewVariables]
private string _currentRSI = default!; private string? _currentRSI;
[ViewVariables] [ComponentDependency] private readonly SpriteComponent? _spriteComponent = null; [ViewVariables] [ComponentDependency] private readonly SpriteComponent? _spriteComponent = null;
@@ -36,7 +36,11 @@ namespace Content.Client.GameObjects.Components.ActionBlocking
if (_currentRSI != cuffState.RSI) // we don't want to keep loading the same RSI if (_currentRSI != cuffState.RSI) // we don't want to keep loading the same RSI
{ {
_currentRSI = cuffState.RSI; _currentRSI = cuffState.RSI;
_spriteComponent.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState), new ResourcePath(cuffState.RSI));
if (_currentRSI != null)
{
_spriteComponent.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState), new ResourcePath(_currentRSI));
}
} }
else else
{ {

View File

@@ -1,4 +1,6 @@
using System; #nullable enable
using System;
using Content.Shared.GameObjects.Components.Pulling;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker; using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Maths; using Robust.Shared.Maths;
@@ -12,8 +14,10 @@ namespace Content.Shared.GameObjects.Components.ActionBlocking
public override string Name => "Cuffable"; public override string Name => "Cuffable";
public override uint? NetID => ContentNetIDs.CUFFED; public override uint? NetID => ContentNetIDs.CUFFED;
[ComponentDependency] private readonly SharedPullableComponent? _pullable = default!;
[ViewVariables] [ViewVariables]
public bool CanStillInteract = true; public bool CanStillInteract { get; set; } = true;
#region ActionBlockers #region ActionBlockers
@@ -24,6 +28,7 @@ namespace Content.Shared.GameObjects.Components.ActionBlocking
bool IActionBlocker.CanAttack() => CanStillInteract; bool IActionBlocker.CanAttack() => CanStillInteract;
bool IActionBlocker.CanEquip() => CanStillInteract; bool IActionBlocker.CanEquip() => CanStillInteract;
bool IActionBlocker.CanUnequip() => CanStillInteract; bool IActionBlocker.CanUnequip() => CanStillInteract;
bool IActionBlocker.CanMove() => _pullable == null || !_pullable.BeingPulled || CanStillInteract;
#endregion #endregion
@@ -32,11 +37,11 @@ namespace Content.Shared.GameObjects.Components.ActionBlocking
{ {
public bool CanStillInteract { get; } public bool CanStillInteract { get; }
public int NumHandsCuffed { get; } public int NumHandsCuffed { get; }
public string RSI { get; } public string? RSI { get; }
public string IconState { get; } public string IconState { get; }
public Color Color { get; } public Color Color { get; }
public CuffableComponentState(int numHandsCuffed, bool canStillInteract, string rsiPath, string iconState, Color color) : base(ContentNetIDs.CUFFED) public CuffableComponentState(int numHandsCuffed, bool canStillInteract, string? rsiPath, string iconState, Color color) : base(ContentNetIDs.CUFFED)
{ {
NumHandsCuffed = numHandsCuffed; NumHandsCuffed = numHandsCuffed;
CanStillInteract = canStillInteract; CanStillInteract = canStillInteract;