Pipe Sprites & Visualizer (#1954)
* Pipe sprites * pipe copyright * SharedPipeComponent * Pipe Visualizer draft * missing longitudinal pipe sprites * expanded rsi states * pipe prototype fixes * Fixed pipe visualizer * ConduitLayer enum * PipeVisualizer update * halfpipe sprites * yaml unneeded proto removal * PipeVisualizer uses its own RSI * Removes unused field from PipeVisualizer Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -23,6 +24,12 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
public PipeDirection PipeDirection => _pipeDirection;
|
||||
private PipeDirection _pipeDirection;
|
||||
|
||||
/// <summary>
|
||||
/// Controls what visuals are applied in <see cref="PipeVisualizer"/>.
|
||||
/// </summary>
|
||||
public ConduitLayer ConduitLayer => _conduitLayer;
|
||||
private ConduitLayer _conduitLayer;
|
||||
|
||||
[ViewVariables]
|
||||
private IPipeNet _pipeNet = PipeNet.NullNet;
|
||||
|
||||
@@ -55,17 +62,24 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
[ViewVariables]
|
||||
public float Volume { get; private set; }
|
||||
|
||||
private AppearanceComponent _appearance;
|
||||
|
||||
private PipeVisualState PipeVisualState => new PipeVisualState(PipeDirection, ConduitLayer);
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _pipeDirection, "pipeDirection", PipeDirection.None);
|
||||
serializer.DataField(this, x => Volume, "volume", 10);
|
||||
serializer.DataField(ref _conduitLayer, "conduitLayer", ConduitLayer.Two);
|
||||
}
|
||||
|
||||
public override void Initialize(IEntity owner)
|
||||
{
|
||||
base.Initialize(owner);
|
||||
LocalAir = new GasMixture(Volume);
|
||||
Owner.TryGetComponent(out _appearance);
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
public void JoinPipeNet(IPipeNet pipeNet)
|
||||
@@ -128,6 +142,16 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
var pipeVisualStates = Owner.GetComponent<NodeContainerComponent>()
|
||||
.Nodes
|
||||
.OfType<PipeNode>()
|
||||
.Select(pipeNode => pipeNode.PipeVisualState)
|
||||
.ToArray();
|
||||
_appearance?.SetData(PipeVisuals.VisualState, new PipeVisualStateSet(pipeVisualStates));
|
||||
}
|
||||
|
||||
private enum CardinalDirection
|
||||
{
|
||||
North = Direction.North,
|
||||
@@ -136,36 +160,4 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
West = Direction.West,
|
||||
}
|
||||
}
|
||||
|
||||
public enum PipeDirection
|
||||
{
|
||||
None = 0,
|
||||
|
||||
//Half of a pipe in a direction
|
||||
North = 1 << 0,
|
||||
South = 1 << 1,
|
||||
West = 1 << 2,
|
||||
East = 1 << 3,
|
||||
|
||||
//Straight pipes
|
||||
Longitudinal = North | South,
|
||||
Lateral = West | East,
|
||||
|
||||
//Bends
|
||||
NWBend = North | West,
|
||||
NEBend = North | East,
|
||||
SWBend = South | West,
|
||||
SEBend = South | East,
|
||||
|
||||
//T-Junctions
|
||||
TNorth = North | Lateral,
|
||||
TSouth = South | Lateral,
|
||||
TWest = West | Longitudinal,
|
||||
TEast = East | Longitudinal,
|
||||
|
||||
//Four way
|
||||
FourWay = North | South | East | West,
|
||||
|
||||
All = -1,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user