Ensnaring Component and Bola Update (#9968)
This commit is contained in:
13
Content.Client/Ensnaring/Components/EnsnareableComponent.cs
Normal file
13
Content.Client/Ensnaring/Components/EnsnareableComponent.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Content.Shared.Ensnaring.Components;
|
||||
|
||||
namespace Content.Client.Ensnaring.Components;
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedEnsnareableComponent))]
|
||||
public sealed class EnsnareableComponent : SharedEnsnareableComponent
|
||||
{
|
||||
[DataField("sprite")]
|
||||
public string? Sprite;
|
||||
|
||||
[DataField("state")]
|
||||
public string? State;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Content.Shared.Ensnaring.Components;
|
||||
|
||||
namespace Content.Client.Ensnaring.Components;
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedEnsnaringComponent))]
|
||||
public sealed class EnsnaringComponent : SharedEnsnaringComponent
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Ensnaring.Visualizers;
|
||||
[RegisterComponent]
|
||||
[Access(typeof(EnsnareableVisualizerSystem))]
|
||||
public sealed class EnsnareableVisualizerComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Content.Client.Ensnaring.Components;
|
||||
using Content.Shared.Ensnaring;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Ensnaring.Visualizers;
|
||||
|
||||
public sealed class EnsnareableVisualizerSystem : VisualizerSystem<EnsnareableComponent>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<EnsnareableVisualizerComponent, ComponentInit>(OnComponentInit);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, EnsnareableVisualizerComponent component, ComponentInit args)
|
||||
{
|
||||
if(!TryComp<SpriteComponent>(uid, out var sprite))
|
||||
return;
|
||||
|
||||
sprite.LayerMapReserveBlank(EnsnaredVisualLayers.Ensnared);
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, EnsnareableComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Component.TryGetData(EnsnareableVisuals.IsEnsnared, out bool isEnsnared))
|
||||
{
|
||||
if (args.Sprite != null && component.Sprite != null)
|
||||
{
|
||||
args.Sprite.LayerSetRSI(EnsnaredVisualLayers.Ensnared, component.Sprite);
|
||||
args.Sprite.LayerSetState(EnsnaredVisualLayers.Ensnared, component.State);
|
||||
args.Sprite.LayerSetVisible(EnsnaredVisualLayers.Ensnared, isEnsnared);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EnsnaredVisualLayers : byte
|
||||
{
|
||||
Ensnared,
|
||||
}
|
||||
@@ -12,6 +12,7 @@ namespace Content.Client.Inventory
|
||||
public Dictionary<(string ID, string Name), string>? Inventory { get; private set; }
|
||||
public Dictionary<string, string>? Hands { get; private set; }
|
||||
public Dictionary<EntityUid, string>? Handcuffs { get; private set; }
|
||||
public Dictionary<EntityUid, string>? Ensnare { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
private StrippingMenu? _strippingMenu;
|
||||
@@ -79,6 +80,17 @@ namespace Content.Client.Inventory
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Ensnare != null)
|
||||
{
|
||||
foreach (var (id, name) in Ensnare)
|
||||
{
|
||||
_strippingMenu.AddButton(Loc.GetString("strippable-bound-user-interface-stripping-menu-ensnare-button"), name, (ev) =>
|
||||
{
|
||||
SendMessage(new StrippingEnsnareButtonPressed(id));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
@@ -90,6 +102,7 @@ namespace Content.Client.Inventory
|
||||
Inventory = stripState.Inventory;
|
||||
Hands = stripState.Hands;
|
||||
Handcuffs = stripState.Handcuffs;
|
||||
Ensnare = stripState.Ensnare;
|
||||
|
||||
UpdateMenu();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user