Port wires/maintenance panel visualizer (#10543)
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Wires.Visualizers
|
||||
{
|
||||
public sealed class WiresVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
if (component.TryGetData<bool>(WiresVisuals.MaintenancePanelState, out var state))
|
||||
{
|
||||
sprite.LayerSetVisible(WiresVisualLayers.MaintenancePanel, state);
|
||||
}
|
||||
// Mainly for spawn window
|
||||
else
|
||||
{
|
||||
sprite.LayerSetVisible(WiresVisualLayers.MaintenancePanel, false);
|
||||
}
|
||||
}
|
||||
|
||||
public enum WiresVisualLayers : byte
|
||||
{
|
||||
MaintenancePanel,
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Content.Client/Wires/Visualizers/WiresVisualizerSystem.cs
Normal file
32
Content.Client/Wires/Visualizers/WiresVisualizerSystem.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Wires.Visualizers
|
||||
{
|
||||
public sealed class WiresVisualizerSystem : VisualizerSystem<WiresVisualsComponent>
|
||||
{
|
||||
protected override void OnAppearanceChange(EntityUid uid, WiresVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
var layer = args.Sprite.LayerMapReserveBlank(WiresVisualLayers.MaintenancePanel);
|
||||
|
||||
if(args.AppearanceData.TryGetValue(WiresVisuals.MaintenancePanelState, out var panelStateObject) &&
|
||||
panelStateObject is bool panelState)
|
||||
{
|
||||
args.Sprite.LayerSetVisible(layer, panelState);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Mainly for spawn window
|
||||
args.Sprite.LayerSetVisible(layer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum WiresVisualLayers : byte
|
||||
{
|
||||
MaintenancePanel
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user