Siphon and Vent Visualizers (#2062)
* scrubber sprites * vent sprites * Vent visualstate * scrubber visual state * Vent and siphon respect being disabled * Vent and Siphon Visualizer * Fix typo Co-authored-by: py01 <pyronetics01@gmail.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
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.Atmos
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SiphonVisualizer : AppearanceVisualizer
|
||||
{
|
||||
private RSI _siphonRSI;
|
||||
|
||||
public override void LoadData(YamlMappingNode node)
|
||||
{
|
||||
base.LoadData(node);
|
||||
|
||||
var rsiString = node.GetNode("siphonRSI").ToString();
|
||||
var rsiPath = SharedSpriteComponent.TextureRoot / rsiString;
|
||||
try
|
||||
{
|
||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
||||
var resource = resourceCache.GetResource<RSIResource>(rsiPath);
|
||||
_siphonRSI = resource.RSI;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorS("go.siphonvisualizer", "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(SiphonVisuals.VisualState, out SiphonVisualState siphonVisualState))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var siphonBaseState = "scrub";
|
||||
siphonBaseState += siphonVisualState.SiphonEnabled ? "On" : "Off";
|
||||
|
||||
sprite.LayerMapReserveBlank(Layer.SiphonBase);
|
||||
var baseSiphonLayer = sprite.LayerMapGet(Layer.SiphonBase);
|
||||
sprite.LayerSetRSI(baseSiphonLayer, _siphonRSI);
|
||||
sprite.LayerSetState(baseSiphonLayer, siphonBaseState);
|
||||
sprite.LayerSetVisible(baseSiphonLayer, true);
|
||||
}
|
||||
|
||||
private enum Layer
|
||||
{
|
||||
SiphonBase,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
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.Atmos
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class VentVisualizer : AppearanceVisualizer
|
||||
{
|
||||
private RSI _ventRSI;
|
||||
|
||||
public override void LoadData(YamlMappingNode node)
|
||||
{
|
||||
base.LoadData(node);
|
||||
|
||||
var rsiString = node.GetNode("ventRSI").ToString();
|
||||
var rsiPath = SharedSpriteComponent.TextureRoot / rsiString;
|
||||
try
|
||||
{
|
||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
||||
var resource = resourceCache.GetResource<RSIResource>(rsiPath);
|
||||
_ventRSI = resource.RSI;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorS("go.ventvisualizer", "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(VentVisuals.VisualState, out VentVisualState ventVisualState))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ventBaseState = "vent";
|
||||
ventBaseState += ventVisualState.VentEnabled ? "On" : "Off";
|
||||
|
||||
sprite.LayerMapReserveBlank(Layer.VentBase);
|
||||
var baseVentLayer = sprite.LayerMapGet(Layer.VentBase);
|
||||
sprite.LayerSetRSI(baseVentLayer, _ventRSI);
|
||||
sprite.LayerSetState(baseVentLayer, ventBaseState);
|
||||
sprite.LayerSetVisible(baseVentLayer, true);
|
||||
}
|
||||
|
||||
private enum Layer
|
||||
{
|
||||
VentBase,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
using Content.Server.GameObjects.Components.NodeContainer;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Atmos;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -23,6 +25,20 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
|
||||
private AtmosphereSystem _atmosSystem;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool SiphonEnabled
|
||||
{
|
||||
get => _siphonEnabled;
|
||||
set
|
||||
{
|
||||
_siphonEnabled = value;
|
||||
UpdateAppearance();
|
||||
}
|
||||
}
|
||||
private bool _siphonEnabled = true;
|
||||
|
||||
private AppearanceComponent _appearance;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -40,10 +56,15 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
Logger.Error($"{typeof(BaseSiphonComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
|
||||
return;
|
||||
}
|
||||
Owner.TryGetComponent(out _appearance);
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!SiphonEnabled)
|
||||
return;
|
||||
|
||||
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
|
||||
if (tileAtmos == null)
|
||||
return;
|
||||
@@ -52,5 +73,10 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
}
|
||||
|
||||
protected abstract void ScrubGas(GasMixture inletGas, GasMixture outletGas);
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
_appearance?.SetData(SiphonVisuals.VisualState, new SiphonVisualState(SiphonEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using Content.Server.GameObjects.Components.NodeContainer;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Atmos;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -23,6 +25,20 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
|
||||
private AtmosphereSystem _atmosSystem;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool VentEnabled
|
||||
{
|
||||
get => _ventEnabled;
|
||||
set
|
||||
{
|
||||
_ventEnabled = value;
|
||||
UpdateAppearance();
|
||||
}
|
||||
}
|
||||
private bool _ventEnabled = true;
|
||||
|
||||
private AppearanceComponent _appearance;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -40,10 +56,15 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
Logger.Error($"{typeof(BaseVentComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
|
||||
return;
|
||||
}
|
||||
Owner.TryGetComponent(out _appearance);
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!VentEnabled)
|
||||
return;
|
||||
|
||||
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
|
||||
if (tileAtmos == null)
|
||||
return;
|
||||
@@ -52,5 +73,10 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
|
||||
}
|
||||
|
||||
protected abstract void VentGas(GasMixture inletGas, GasMixture outletGas);
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
_appearance?.SetData(VentVisuals.VisualState, new VentVisualState(VentEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
Content.Shared/GameObjects/Atmos/SharedSiphonComponent.cs
Normal file
22
Content.Shared/GameObjects/Atmos/SharedSiphonComponent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.GameObjects.Atmos
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum SiphonVisuals
|
||||
{
|
||||
VisualState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class SiphonVisualState
|
||||
{
|
||||
public readonly bool SiphonEnabled;
|
||||
|
||||
public SiphonVisualState(bool siphonEnabled)
|
||||
{
|
||||
SiphonEnabled = siphonEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Content.Shared/GameObjects/Atmos/SharedVentComponent.cs
Normal file
22
Content.Shared/GameObjects/Atmos/SharedVentComponent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.GameObjects.Atmos
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum VentVisuals
|
||||
{
|
||||
VisualState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class VentVisualState
|
||||
{
|
||||
public readonly bool VentEnabled;
|
||||
|
||||
public VentVisualState(bool ventEnabled)
|
||||
{
|
||||
VentEnabled = ventEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,12 @@
|
||||
- type: Icon
|
||||
texture: Constructible/Power/eightdirwire.png
|
||||
- type: Sprite
|
||||
texture: Constructible/Power/eightdirwire.png
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PipeVisualizer
|
||||
pipeRSI: Constructible/Atmos/pipe.rsi
|
||||
- type: SiphonVisualizer
|
||||
siphonRSI: Constructible/Atmos/scrubber.rsi
|
||||
- type: Destructible
|
||||
thresholdvalue: 100
|
||||
|
||||
|
||||
@@ -12,7 +12,12 @@
|
||||
- type: Icon
|
||||
texture: Constructible/Power/eightdirwire.png
|
||||
- type: Sprite
|
||||
texture: Constructible/Power/eightdirwire.png
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: PipeVisualizer
|
||||
pipeRSI: Constructible/Atmos/pipe.rsi
|
||||
- type: VentVisualizer
|
||||
ventRSI: Constructible/Atmos/vent.rsi
|
||||
- type: Destructible
|
||||
thresholdvalue: 100
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"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":"scrubOff",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"scrubOn",
|
||||
"directions":1,
|
||||
"delays":[
|
||||
[
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/Constructible/Atmos/scrubber.rsi/scrubOff.png
Normal file
BIN
Resources/Textures/Constructible/Atmos/scrubber.rsi/scrubOff.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 767 B |
BIN
Resources/Textures/Constructible/Atmos/scrubber.rsi/scrubOn.png
Normal file
BIN
Resources/Textures/Constructible/Atmos/scrubber.rsi/scrubOn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
28
Resources/Textures/Constructible/Atmos/vent.rsi/meta.json
Normal file
28
Resources/Textures/Constructible/Atmos/vent.rsi/meta.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"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":"ventOff",
|
||||
"directions":1,
|
||||
"delays":[ [ 1.0 ] ]
|
||||
},
|
||||
{
|
||||
"name":"ventOn",
|
||||
"directions":1,
|
||||
"delays":[
|
||||
[
|
||||
0.08,
|
||||
0.08,
|
||||
0.08,
|
||||
0.08
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/Constructible/Atmos/vent.rsi/ventOff.png
Normal file
BIN
Resources/Textures/Constructible/Atmos/vent.rsi/ventOff.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 612 B |
BIN
Resources/Textures/Constructible/Atmos/vent.rsi/ventOn.png
Normal file
BIN
Resources/Textures/Constructible/Atmos/vent.rsi/ventOn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user