* Pipe prototypes * PipeDirection setter * IRotatableNode * NodeContainer passes rotation events to its nodes * Removes duplicate pipe prototypes that are rotations of each other * PipeDirectionHelpers * PipeNode rotation * icon removal * Pipe icons * Icon fix * Fixes pipe sprites and icons Co-authored-by: py01 <pyronetics01@gmail.com>
46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using System;
|
|
using Content.Shared.GameObjects.Components.Atmos;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.Interfaces.GameObjects.Components;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
|
|
namespace Content.Client.GameObjects.Components.Atmos
|
|
{
|
|
[UsedImplicitly]
|
|
public class PipeVisualizer : AppearanceVisualizer
|
|
{
|
|
public override void InitializeEntity(IEntity entity)
|
|
{
|
|
base.InitializeEntity(entity);
|
|
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
|
|
sprite.LayerMapReserveBlank(Layer.PipeBase);
|
|
var pipeBaseLayer = sprite.LayerMapGet(Layer.PipeBase);
|
|
sprite.LayerSetVisible(pipeBaseLayer, true);
|
|
}
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
{
|
|
base.OnChangeData(component);
|
|
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);
|
|
}
|
|
|
|
private string GetPipeBaseStateId(PipeVisualState pipeVisualState)
|
|
{
|
|
var stateId = "pipe";
|
|
stateId += pipeVisualState.PipeDirection.PipeDirectionToPipeShape().ToString();
|
|
stateId += (int) pipeVisualState.ConduitLayer;
|
|
return stateId;
|
|
}
|
|
|
|
private enum Layer
|
|
{
|
|
PipeBase,
|
|
}
|
|
}
|
|
}
|