2020-09-13 14:23:52 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using Content.Shared.GameObjects.Components.Atmos;
|
2020-08-30 18:13:15 -06:00
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Client.GameObjects;
|
2020-09-13 14:23:52 +02:00
|
|
|
|
using Robust.Client.Interfaces.GameObjects.Components;
|
2020-10-08 09:53:56 -06:00
|
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
2020-08-30 18:13:15 -06:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.GameObjects.Components.Atmos
|
|
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
|
public class PipeVisualizer : AppearanceVisualizer
|
|
|
|
|
|
{
|
2020-10-08 09:53:56 -06:00
|
|
|
|
public override void InitializeEntity(IEntity entity)
|
2020-08-30 18:13:15 -06:00
|
|
|
|
{
|
2020-10-08 09:53:56 -06:00
|
|
|
|
base.InitializeEntity(entity);
|
|
|
|
|
|
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
|
|
|
|
|
|
sprite.LayerMapReserveBlank(Layer.PipeBase);
|
|
|
|
|
|
var pipeBaseLayer = sprite.LayerMapGet(Layer.PipeBase);
|
|
|
|
|
|
sprite.LayerSetVisible(pipeBaseLayer, true);
|
2020-08-30 18:13:15 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnChangeData(component);
|
2020-10-08 09:53:56 -06:00
|
|
|
|
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return;
|
|
|
|
|
|
if (!component.TryGetData(PipeVisuals.VisualState, out PipeVisualState pipeVisualState)) return;
|
|
|
|
|
|
var pipeBase = sprite.LayerMapGet(Layer.PipeBase);
|
|
|
|
|
|
var pipeBaseStateId = GetPipeBaseStateId(pipeVisualState);
|
|
|
|
|
|
sprite.LayerSetState(pipeBase, pipeBaseStateId);
|
|
|
|
|
|
}
|
2020-08-30 18:13:15 -06:00
|
|
|
|
|
2020-10-08 09:53:56 -06:00
|
|
|
|
private string GetPipeBaseStateId(PipeVisualState pipeVisualState)
|
|
|
|
|
|
{
|
|
|
|
|
|
var stateId = "pipe";
|
|
|
|
|
|
stateId += pipeVisualState.PipeDirection.PipeDirectionToPipeShape().ToString();
|
|
|
|
|
|
stateId += (int) pipeVisualState.ConduitLayer;
|
|
|
|
|
|
return stateId;
|
|
|
|
|
|
}
|
2020-08-30 18:13:15 -06:00
|
|
|
|
|
2020-10-08 09:53:56 -06:00
|
|
|
|
private enum Layer
|
|
|
|
|
|
{
|
|
|
|
|
|
PipeBase,
|
2020-08-30 18:13:15 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|