Files
crystall-punk-14/Content.Client/Wall/ReinforcedWallVisualizer.cs

45 lines
1.3 KiB
C#
Raw Normal View History

2021-06-09 22:19:39 +02:00
using Content.Shared.Wall;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
2021-12-05 18:09:01 +01:00
using Robust.Shared.IoC;
2021-06-09 22:19:39 +02:00
namespace Content.Client.Wall
{
[UsedImplicitly]
public sealed class ReinforcedWallVisualizer : AppearanceVisualizer
{
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;
2021-12-05 18:09:01 +01:00
var entities = IoCManager.Resolve<IEntityManager>();
if (!entities.TryGetComponent(entity, out ISpriteComponent? sprite)) return;
if (stage < 0)
{
sprite.LayerSetVisible(ReinforcedWallVisualLayers.Deconstruction, false);
return;
}
sprite.LayerSetVisible(ReinforcedWallVisualLayers.Deconstruction, true);
sprite.LayerSetState(ReinforcedWallVisualLayers.Deconstruction, $"reinf_construct-{stage}");
}
}
2020-12-04 11:57:33 +01:00
public enum ReinforcedWallVisualLayers : byte
{
Deconstruction,
}
}