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>
@@ -0,0 +1,69 @@
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.GameObjects.Components.Renderable;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PipeVisualizer : AppearanceVisualizer
|
||||
{
|
||||
private RSI _pipeRSI;
|
||||
|
||||
public override void LoadData(YamlMappingNode node)
|
||||
{
|
||||
base.LoadData(node);
|
||||
|
||||
var rsiString = node.GetNode("pipeRSI").ToString();
|
||||
var rsiPath = SharedSpriteComponent.TextureRoot / rsiString;
|
||||
try
|
||||
{
|
||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
||||
var resource = resourceCache.GetResource<RSIResource>(rsiPath);
|
||||
_pipeRSI = resource.RSI;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorS("go.pipevisualizer", "Unable to load RSI '{0}'. Trace:\n{1}", rsiPath, e);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!component.TryGetData(PipeVisuals.VisualState, out PipeVisualStateSet pipeVisualStateSet))
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < pipeVisualStateSet.PipeVisualStates.Length; i++)
|
||||
{
|
||||
var pipeVisualState = pipeVisualStateSet.PipeVisualStates[i];
|
||||
var rsiState = "pipe";
|
||||
rsiState += pipeVisualState.PipeDirection.ToString();
|
||||
rsiState += ((int) pipeVisualState.ConduitLayer).ToString();
|
||||
|
||||
var pipeLayerKey = "pipeLayer" + i.ToString();
|
||||
sprite.LayerMapReserveBlank(pipeLayerKey);
|
||||
var currentPipeLayer = sprite.LayerMapGet(pipeLayerKey);
|
||||
sprite.LayerSetRSI(currentPipeLayer, _pipeRSI);
|
||||
sprite.LayerSetState(currentPipeLayer, rsiState);
|
||||
sprite.LayerSetVisible(currentPipeLayer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.GameObjects.Components.NodeContainer;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Atmos
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum PipeVisuals
|
||||
{
|
||||
VisualState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class PipeVisualStateSet
|
||||
{
|
||||
public readonly PipeVisualState[] PipeVisualStates;
|
||||
|
||||
public PipeVisualStateSet(PipeVisualState[] pipeVisualStates)
|
||||
{
|
||||
PipeVisualStates = pipeVisualStates;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class PipeVisualState
|
||||
{
|
||||
public readonly PipeDirection PipeDirection;
|
||||
public readonly ConduitLayer ConduitLayer;
|
||||
|
||||
public PipeVisualState(PipeDirection pipeDirection, ConduitLayer conduitLayer)
|
||||
{
|
||||
PipeDirection = pipeDirection;
|
||||
ConduitLayer = conduitLayer;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
|
||||
public enum ConduitLayer
|
||||
{
|
||||
One = 1,
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
}
|
||||
}
|
||||
@@ -12,32 +12,31 @@
|
||||
- type: Icon
|
||||
texture: Constructible/Power/eightdirwire.png
|
||||
- type: Sprite
|
||||
sprite: Constructible/Power/hv_cable.rsi
|
||||
- type: Destructible
|
||||
thresholdvalue: 100
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PipeVisualizer
|
||||
pipeRSI: Constructible/Atmos/pipe.rsi
|
||||
|
||||
- type: entity
|
||||
parent: PipeBase
|
||||
id: FourwayPipe
|
||||
name: Fourway Pipe
|
||||
components:
|
||||
- type: Sprite
|
||||
state: hvcable_15
|
||||
- type: NodeContainer
|
||||
nodes:
|
||||
- !type:PipeNode
|
||||
nodeGroupID: Pipe
|
||||
pipeDirection: FourWay
|
||||
pipeDirection: Fourway
|
||||
|
||||
- type: entity
|
||||
parent: PipeBase
|
||||
id: LongitudinalPipe
|
||||
name: Longitudinal Pipe
|
||||
components:
|
||||
- type: Sprite
|
||||
state: hvcable_3
|
||||
- type: NodeContainer
|
||||
nodes:
|
||||
- !type:PipeNode
|
||||
nodeGroupID: Pipe
|
||||
pipeDirection: Longitudinal
|
||||
pipeDirection: Longitudinal
|
||||
196
Resources/Textures/Constructible/Atmos/pipe.rsi/meta.json
Normal file
@@ -0,0 +1,196 @@
|
||||
{
|
||||
"version":1,
|
||||
"size":{
|
||||
"x":32,
|
||||
"y":32
|
||||
},
|
||||
"license":"CC-BY-SA-3.0",
|
||||
"copyright":"Taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da",
|
||||
"states":[
|
||||
{
|
||||
"name":"pipeEast2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeNorth2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeSouth2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeWest2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeFourway1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeFourway2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeFourway3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeLateral1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeLateral2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeLateral3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeLongitudinal1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeLongitudinal2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeLongitudinal3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeNEBend1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeNEBend2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeNEBend3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeNWBend1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeNWBend2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeNWBend3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeSEBend1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeSEBend2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeSEBend3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeSWBend1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeSWBend2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeSWBend3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTEast1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTEast2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTEast3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTNorth1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTNorth2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTNorth3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTSouth1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTSouth2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTSouth3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTWest1",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTWest2",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"pipeTWest3",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeEast2.png
Normal file
|
After Width: | Height: | Size: 217 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeFourway1.png
Normal file
|
After Width: | Height: | Size: 556 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeFourway2.png
Normal file
|
After Width: | Height: | Size: 538 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeFourway3.png
Normal file
|
After Width: | Height: | Size: 545 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeLateral1.png
Normal file
|
After Width: | Height: | Size: 273 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeLateral2.png
Normal file
|
After Width: | Height: | Size: 278 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeLateral3.png
Normal file
|
After Width: | Height: | Size: 278 B |
|
After Width: | Height: | Size: 329 B |
|
After Width: | Height: | Size: 326 B |
|
After Width: | Height: | Size: 321 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeNEBend1.png
Normal file
|
After Width: | Height: | Size: 265 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeNEBend2.png
Normal file
|
After Width: | Height: | Size: 255 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeNEBend3.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeNWBend1.png
Normal file
|
After Width: | Height: | Size: 317 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeNWBend2.png
Normal file
|
After Width: | Height: | Size: 347 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeNWBend3.png
Normal file
|
After Width: | Height: | Size: 324 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeNorth2.png
Normal file
|
After Width: | Height: | Size: 229 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeSEBend1.png
Normal file
|
After Width: | Height: | Size: 233 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeSEBend2.png
Normal file
|
After Width: | Height: | Size: 264 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeSEBend3.png
Normal file
|
After Width: | Height: | Size: 276 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeSWBend1.png
Normal file
|
After Width: | Height: | Size: 267 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeSWBend2.png
Normal file
|
After Width: | Height: | Size: 292 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeSWBend3.png
Normal file
|
After Width: | Height: | Size: 309 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeSouth2.png
Normal file
|
After Width: | Height: | Size: 278 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTEast1.png
Normal file
|
After Width: | Height: | Size: 450 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTEast2.png
Normal file
|
After Width: | Height: | Size: 450 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTEast3.png
Normal file
|
After Width: | Height: | Size: 433 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTNorth1.png
Normal file
|
After Width: | Height: | Size: 474 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTNorth2.png
Normal file
|
After Width: | Height: | Size: 447 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTNorth3.png
Normal file
|
After Width: | Height: | Size: 427 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTSouth1.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTSouth2.png
Normal file
|
After Width: | Height: | Size: 416 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTSouth3.png
Normal file
|
After Width: | Height: | Size: 426 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTWest1.png
Normal file
|
After Width: | Height: | Size: 449 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTWest2.png
Normal file
|
After Width: | Height: | Size: 471 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeTWest3.png
Normal file
|
After Width: | Height: | Size: 479 B |
BIN
Resources/Textures/Constructible/Atmos/pipe.rsi/pipeWest2.png
Normal file
|
After Width: | Height: | Size: 236 B |