Convert ReinforcedWallVisualizer to ECS (#15735)
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
using Content.Shared.Wall;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Wall
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class ReinforcedWallVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (component.TryGetData(ReinforcedWallVisuals.DeconstructionStage, out int stage))
|
||||
{
|
||||
SetDeconstructionStage(component, stage);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDeconstructionStage(AppearanceComponent component, int stage)
|
||||
{
|
||||
var entity = component.Owner;
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(entity, out SpriteComponent? sprite)) return;
|
||||
|
||||
var index = sprite.LayerMapReserveBlank(ReinforcedWallVisualLayers.Deconstruction);
|
||||
|
||||
if (stage < 0)
|
||||
{
|
||||
sprite.LayerSetVisible(index, false);
|
||||
return;
|
||||
}
|
||||
|
||||
sprite.LayerSetVisible(index, true);
|
||||
sprite.LayerSetState(index, $"reinf_construct-{stage}");
|
||||
}
|
||||
}
|
||||
|
||||
public enum ReinforcedWallVisualLayers : byte
|
||||
{
|
||||
Deconstruction,
|
||||
}
|
||||
}
|
||||
6
Content.Client/Wall/ReinforcedWallVisuals.cs
Normal file
6
Content.Client/Wall/ReinforcedWallVisuals.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Content.Client.Wall;
|
||||
|
||||
public enum ReinforcedWallVisualLayers : byte
|
||||
{
|
||||
Deconstruction,
|
||||
}
|
||||
@@ -464,8 +464,17 @@
|
||||
key: walls
|
||||
base: reinf_over
|
||||
- type: Appearance
|
||||
- type: GenericVisualizer
|
||||
visuals:
|
||||
- type: ReinforcedWallVisualizer
|
||||
enum.ReinforcedWallVisuals.DeconstructionStage:
|
||||
ReinforcedWallVisualLayers.Deconstruction:
|
||||
-1: { visible: false }
|
||||
0: { state: reinf_construct-0, visible: true}
|
||||
1: { state: reinf_construct-1, visible: true}
|
||||
2: { state: reinf_construct-2, visible: true}
|
||||
3: { state: reinf_construct-3, visible: true}
|
||||
4: { state: reinf_construct-4, visible: true}
|
||||
5: { state: reinf_construct-5, visible: true}
|
||||
- type: StaticPrice
|
||||
price: 150
|
||||
- type: RadiationBlocker
|
||||
|
||||
Reference in New Issue
Block a user