Resolve ClustergrenadeVisualizer is Obsolete (#13890)
This commit is contained in:
@@ -1,34 +0,0 @@
|
|||||||
using Content.Shared.Explosion;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Client.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
|
|
||||||
namespace Content.Client.Explosion
|
|
||||||
{
|
|
||||||
[UsedImplicitly]
|
|
||||||
// ReSharper disable once InconsistentNaming
|
|
||||||
public sealed class ClusterGrenadeVisualizer : AppearanceVisualizer
|
|
||||||
{
|
|
||||||
[DataField("state")]
|
|
||||||
private string? _state;
|
|
||||||
|
|
||||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
|
||||||
{
|
|
||||||
base.OnChangeData(component);
|
|
||||||
|
|
||||||
var entities = IoCManager.Resolve<IEntityManager>();
|
|
||||||
if (!entities.TryGetComponent<SpriteComponent>(component.Owner, out var sprite))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component.TryGetData(ClusterGrenadeVisuals.GrenadesCounter, out int grenadesCounter))
|
|
||||||
{
|
|
||||||
sprite.LayerSetState(0, $"{_state}-{grenadesCounter}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
16
Content.Client/Explosion/ClusterGrenadeVisualizerSystem.cs
Normal file
16
Content.Client/Explosion/ClusterGrenadeVisualizerSystem.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Content.Shared.Explosion;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.Explosion;
|
||||||
|
|
||||||
|
public sealed class ClusterGrenadeVisualizerSystem : VisualizerSystem<ClusterGrenadeVisualsComponent>
|
||||||
|
{
|
||||||
|
protected override void OnAppearanceChange(EntityUid uid, ClusterGrenadeVisualsComponent comp, ref AppearanceChangeEvent args)
|
||||||
|
{
|
||||||
|
if (args.Sprite == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (AppearanceSystem.TryGetData<int>(uid, ClusterGrenadeVisuals.GrenadesCounter, out var grenadesCounter, args.Component))
|
||||||
|
args.Sprite.LayerSetState(0, $"{comp.State}-{grenadesCounter}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Content.Client.Explosion;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
[Access(typeof(ClusterGrenadeVisualizerSystem))]
|
||||||
|
public sealed class ClusterGrenadeVisualsComponent : Component
|
||||||
|
{
|
||||||
|
[DataField("state")]
|
||||||
|
public string? State;
|
||||||
|
}
|
||||||
@@ -9,9 +9,8 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
state: base-0
|
state: base-0
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: ClusterGrenadeVisuals
|
||||||
- type: ClusterGrenadeVisualizer
|
state: base
|
||||||
state: base
|
|
||||||
- type: ClusterGrenade
|
- type: ClusterGrenade
|
||||||
- type: ContainerContainer
|
- type: ContainerContainer
|
||||||
containers:
|
containers:
|
||||||
|
|||||||
Reference in New Issue
Block a user