2021-08-01 04:50:36 +02:00
|
|
|
using Content.Shared.SubFloor;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.GameObjects;
|
2021-11-22 23:22:59 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-05 18:09:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2021-08-01 04:50:36 +02:00
|
|
|
|
|
|
|
|
namespace Content.Client.SubFloor
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
public class SubFloorShowLayerVisualizer : AppearanceVisualizer
|
|
|
|
|
{
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
{
|
|
|
|
|
base.OnChangeData(component);
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
var entities = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
if (!entities.TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
2021-08-01 04:50:36 +02:00
|
|
|
return;
|
|
|
|
|
|
2021-12-15 19:46:42 +13:00
|
|
|
if (!component.TryGetData(SubFloorVisuals.SubFloor, out bool subfloor))
|
|
|
|
|
return;
|
2021-08-01 04:50:36 +02:00
|
|
|
|
2021-12-15 19:46:42 +13:00
|
|
|
foreach (var layer in sprite.AllLayers)
|
|
|
|
|
{
|
|
|
|
|
layer.Visible = subfloor;
|
|
|
|
|
}
|
2021-08-01 04:50:36 +02:00
|
|
|
|
2021-12-15 19:46:42 +13:00
|
|
|
if (!sprite.LayerMapTryGet(Layers.FirstLayer, out var firstLayer))
|
|
|
|
|
{
|
|
|
|
|
sprite.Visible = subfloor;
|
|
|
|
|
return;
|
2021-08-01 04:50:36 +02:00
|
|
|
}
|
2021-12-15 19:46:42 +13:00
|
|
|
|
|
|
|
|
// show the top part of the sprite. E.g. the grille-part of a vent, but not the connecting pipes.
|
|
|
|
|
sprite.LayerSetVisible(firstLayer, true);
|
|
|
|
|
sprite.Visible = true;
|
2021-08-01 04:50:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum Layers : byte
|
|
|
|
|
{
|
|
|
|
|
FirstLayer,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|