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,
|
||||
}
|
||||
Reference in New Issue
Block a user