Add subfloor appearance data, pipes correctly render subfloor. (#4393)
This commit is contained in:
committed by
GitHub
parent
eee3c940fb
commit
f2a3987343
40
Content.Client/SubFloor/SubFloorShowLayerVisualizer.cs
Normal file
40
Content.Client/SubFloor/SubFloorShowLayerVisualizer.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Shared.SubFloor;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.SubFloor
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SubFloorShowLayerVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if (component.TryGetData(SubFloorVisuals.SubFloor, out bool subfloor))
|
||||
{
|
||||
sprite.Visible = true;
|
||||
|
||||
// Due to the way this visualizer works, you might want to specify it before any other
|
||||
// visualizer that hides/shows layers depending on certain conditions, such as PipeConnectorVisualizer.
|
||||
foreach (var layer in sprite.AllLayers)
|
||||
{
|
||||
layer.Visible = subfloor;
|
||||
}
|
||||
|
||||
if (sprite.LayerMapTryGet(Layers.FirstLayer, out var firstLayer))
|
||||
{
|
||||
sprite.LayerSetVisible(firstLayer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Layers : byte
|
||||
{
|
||||
FirstLayer,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user