Pump visuals (#1960)

* Pipe sprites

* pipe copyright

* SharedPipeComponent

* Pipe Visualizer draft

* missing longitudinal pipe sprites

* expanded rsi states

* pipe prototype fixes

* Fixed pipe visualizer

* PressurePump and VolumePump

* VolumePump fix

* PressurePump fix

* Shared pump

# Conflicts:
#	Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs
#	Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs

* PumpVisualizer Draft

* ConduitLayer enum

* PipeVisualizer update

* halfpipe sprites

* pumpvisualizer simplification

* yaml unneeded proto removal

* pump visualizer draft 2

* Pump overlays

* pump rsi name

* merge fix

* PumpVisuals ConduitLayer

* merge fix

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-08-31 04:33:05 -06:00
committed by GitHub
parent 9d5278ab0d
commit 178931e54b
10 changed files with 148 additions and 5 deletions

View File

@@ -1,8 +1,8 @@
using Content.Shared.GameObjects.Components.Atmos; using Content.Shared.GameObjects.Components.Atmos;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.GameObjects.Components; using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.ResourceManagement; using Robust.Client.ResourceManagement;
using Robust.Shared.GameObjects.Components.Renderable; using Robust.Shared.GameObjects.Components.Renderable;
@@ -10,7 +10,6 @@ using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using System; using System;
using System.Collections.Generic;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos

View File

@@ -0,0 +1,70 @@
using Content.Shared.GameObjects.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 YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Disposal
{
[UsedImplicitly]
public class PumpVisualizer : AppearanceVisualizer
{
private RSI _pumpRSI;
public override void LoadData(YamlMappingNode node)
{
base.LoadData(node);
var rsiString = node.GetNode("pumpRSI").ToString();
var rsiPath = SharedSpriteComponent.TextureRoot / rsiString;
try
{
var resourceCache = IoCManager.Resolve<IResourceCache>();
var resource = resourceCache.GetResource<RSIResource>(rsiPath);
_pumpRSI = resource.RSI;
}
catch (Exception e)
{
Logger.ErrorS("go.pumpvisualizer", "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(PumpVisuals.VisualState, out PumpVisualState pumpVisualState))
{
return;
}
var pumpBaseState = "pump";
pumpBaseState += pumpVisualState.InletDirection.ToString();
pumpBaseState += ((int) pumpVisualState.InletConduitLayer).ToString();
pumpBaseState += pumpVisualState.OutletDirection.ToString();
pumpBaseState += ((int) pumpVisualState.OutletConduitLayer).ToString();
sprite.LayerMapReserveBlank(Layer.PumpBase);
var basePumpLayer = sprite.LayerMapGet(Layer.PumpBase);
sprite.LayerSetRSI(basePumpLayer, _pumpRSI);
sprite.LayerSetState(basePumpLayer, pumpBaseState);
sprite.LayerSetVisible(basePumpLayer, true);
}
private enum Layer
{
PumpBase
}
}
}

View File

@@ -2,6 +2,8 @@
using Content.Server.GameObjects.Components.NodeContainer; using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.Nodes; using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Content.Shared.GameObjects.Components.Atmos; using Content.Shared.GameObjects.Components.Atmos;
using Content.Shared.GameObjects.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -32,6 +34,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
[ViewVariables] [ViewVariables]
private PipeNode _outletPipe; private PipeNode _outletPipe;
private AppearanceComponent _appearance;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
@@ -57,6 +61,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
Logger.Error($"{typeof(BasePumpComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); Logger.Error($"{typeof(BasePumpComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
return; return;
} }
Owner.TryGetComponent(out _appearance);
UpdateAppearance();
} }
public override void Update() public override void Update()
@@ -65,5 +71,10 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
} }
protected abstract void PumpGas(GasMixture inletGas, GasMixture outletGas); protected abstract void PumpGas(GasMixture inletGas, GasMixture outletGas);
private void UpdateAppearance()
{
_appearance?.SetData(PumpVisuals.VisualState, new PumpVisualState(_inletDirection, _outletDirection, _inletPipe.ConduitLayer, _outletPipe.ConduitLayer));
}
} }
} }

View File

@@ -0,0 +1,29 @@
using Content.Shared.GameObjects.Components.Atmos;
using Robust.Shared.Serialization;
using System;
namespace Content.Shared.GameObjects.Atmos
{
[Serializable, NetSerializable]
public enum PumpVisuals
{
VisualState
}
[Serializable, NetSerializable]
public class PumpVisualState
{
public readonly PipeDirection InletDirection;
public readonly PipeDirection OutletDirection;
public readonly ConduitLayer InletConduitLayer;
public readonly ConduitLayer OutletConduitLayer;
public PumpVisualState(PipeDirection inletDirection, PipeDirection outletDirection, ConduitLayer inletConduitLayer, ConduitLayer outletConduitLayer)
{
InletDirection = inletDirection;
OutletDirection = outletDirection;
InletConduitLayer = inletConduitLayer;
OutletConduitLayer = outletConduitLayer;
}
}
}

View File

@@ -12,7 +12,12 @@
- type: Icon - type: Icon
texture: Constructible/Power/eightdirwire.png texture: Constructible/Power/eightdirwire.png
- type: Sprite - type: Sprite
sprite: Constructible/Power/mv_cable.rsi - type: Appearance
visuals:
- type: PipeVisualizer
pipeRSI: Constructible/Atmos/pipe.rsi
- type: PumpVisualizer
pumpRSI: Constructible/Atmos/pressurepump.rsi
- type: Destructible - type: Destructible
thresholdvalue: 100 thresholdvalue: 100
@@ -21,8 +26,6 @@
parent: PumpBase parent: PumpBase
id: NorthwardLongitudinalPump id: NorthwardLongitudinalPump
components: components:
- type: Sprite
state: mvcable_3
- type: NodeContainer - type: NodeContainer
nodes: nodes:
- !type:PipeNode - !type:PipeNode

View File

@@ -0,0 +1,31 @@
{
"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":"pumpEast2West2",
"directions":1,
"delays":[ [ 1.0 ] ]
},
{
"name":"pumpNorth2South2",
"directions":1,
"delays":[ [ 1.0 ] ]
},
{
"name":"pumpSouth2North2",
"directions":1,
"delays":[ [ 1.0 ] ]
},
{
"name":"pumpWest2East2",
"directions":1,
"delays":[ [ 1.0 ] ]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B