Vent and Siphon visualizer and icon fixes (#2288)

* Half pipes

* PipeVisualizer pipeRSI field

* Vent and Siphon visualizer fixes

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-10-18 04:13:06 -06:00
committed by GitHub
parent 32138958ce
commit f01a50012e
7 changed files with 93 additions and 20 deletions

View File

@@ -2,20 +2,49 @@
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.Interfaces.ResourceManagement;
using Robust.Client.ResourceManagement;
using Robust.Shared.GameObjects.Components.Renderable;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos
{ {
[UsedImplicitly] [UsedImplicitly]
public class PipeVisualizer : AppearanceVisualizer 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.ventvisualizer", "Unable to load RSI '{0}'. Trace:\n{1}", rsiPath, e);
}
}
public override void InitializeEntity(IEntity entity) public override void InitializeEntity(IEntity entity)
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return; if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
sprite.LayerMapReserveBlank(Layer.PipeBase); sprite.LayerMapReserveBlank(Layer.PipeBase);
var pipeBaseLayer = sprite.LayerMapGet(Layer.PipeBase); var pipeBaseLayer = sprite.LayerMapGet(Layer.PipeBase);
sprite.LayerSetRSI(pipeBaseLayer, _pipeRSI);
sprite.LayerSetVisible(pipeBaseLayer, true); sprite.LayerSetVisible(pipeBaseLayer, true);
} }

View File

@@ -11,6 +11,7 @@ using Robust.Shared.Utility;
using System; using System;
using Content.Shared.GameObjects.Components.Atmos; using Content.Shared.GameObjects.Components.Atmos;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos
{ {
@@ -37,23 +38,26 @@ namespace Content.Client.GameObjects.Components.Atmos
} }
} }
public override void InitializeEntity(IEntity entity)
{
base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
sprite.LayerMapReserveBlank(Layer.SiphonBase);
var pipeBaseLayer = sprite.LayerMapGet(Layer.SiphonBase);
sprite.LayerSetRSI(pipeBaseLayer, _siphonRSI);
sprite.LayerSetVisible(pipeBaseLayer, true);
}
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {
base.OnChangeData(component); base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return;
{ if (!component.TryGetData(SiphonVisuals.VisualState, out SiphonVisualState siphonVisualState)) return;
return;
}
if (!component.TryGetData(SiphonVisuals.VisualState, out SiphonVisualState siphonVisualState))
{
return;
}
var siphonBaseState = "scrub"; var siphonBaseState = "scrub";
siphonBaseState += siphonVisualState.SiphonEnabled ? "On" : "Off"; siphonBaseState += siphonVisualState.SiphonEnabled ? "On" : "Off";
sprite.LayerMapReserveBlank(Layer.SiphonBase);
var baseSiphonLayer = sprite.LayerMapGet(Layer.SiphonBase); var baseSiphonLayer = sprite.LayerMapGet(Layer.SiphonBase);
sprite.LayerSetRSI(baseSiphonLayer, _siphonRSI); sprite.LayerSetRSI(baseSiphonLayer, _siphonRSI);
sprite.LayerSetState(baseSiphonLayer, siphonBaseState); sprite.LayerSetState(baseSiphonLayer, siphonBaseState);

View File

@@ -11,6 +11,7 @@ using Robust.Shared.Utility;
using System; using System;
using Content.Shared.GameObjects.Components.Atmos; using Content.Shared.GameObjects.Components.Atmos;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos
{ {
@@ -37,23 +38,26 @@ namespace Content.Client.GameObjects.Components.Atmos
} }
} }
public override void InitializeEntity(IEntity entity)
{
base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
sprite.LayerMapReserveBlank(Layer.VentBase);
var pipeBaseLayer = sprite.LayerMapGet(Layer.VentBase);
sprite.LayerSetRSI(pipeBaseLayer, _ventRSI);
sprite.LayerSetVisible(pipeBaseLayer, true);
}
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {
base.OnChangeData(component); base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return;
{ if (!component.TryGetData(VentVisuals.VisualState, out VentVisualState ventVisualState)) return;
return;
}
if (!component.TryGetData(VentVisuals.VisualState, out VentVisualState ventVisualState))
{
return;
}
var ventBaseState = "vent"; var ventBaseState = "vent";
ventBaseState += ventVisualState.VentEnabled ? "On" : "Off"; ventBaseState += ventVisualState.VentEnabled ? "On" : "Off";
sprite.LayerMapReserveBlank(Layer.VentBase);
var baseVentLayer = sprite.LayerMapGet(Layer.VentBase); var baseVentLayer = sprite.LayerMapGet(Layer.VentBase);
sprite.LayerSetRSI(baseVentLayer, _ventRSI); sprite.LayerSetRSI(baseVentLayer, _ventRSI);
sprite.LayerSetState(baseVentLayer, ventBaseState); sprite.LayerSetState(baseVentLayer, ventBaseState);

View File

@@ -57,6 +57,7 @@ namespace Content.Shared.GameObjects.Components.Atmos
public enum PipeShape public enum PipeShape
{ {
Half,
Straight, Straight,
Bend, Bend,
TJunction, TJunction,
@@ -126,6 +127,11 @@ namespace Content.Shared.GameObjects.Components.Atmos
{ {
return pipeDirection switch return pipeDirection switch
{ {
PipeDirection.North => PipeShape.Half,
PipeDirection.South => PipeShape.Half,
PipeDirection.East => PipeShape.Half,
PipeDirection.West => PipeShape.Half,
PipeDirection.Lateral => PipeShape.Straight, PipeDirection.Lateral => PipeShape.Straight,
PipeDirection.Longitudinal => PipeShape.Straight, PipeDirection.Longitudinal => PipeShape.Straight,

View File

@@ -13,14 +13,26 @@
offset: Center offset: Center
- type: Destructible - type: Destructible
thresholdvalue: 100 thresholdvalue: 100
- type: Sprite
sprite: Constructible/Atmos/pipe.rsi
- type: Appearance - type: Appearance
visuals: visuals:
- type: PipeVisualizer - type: PipeVisualizer
pipeRSI: Constructible/Atmos/pipe.rsi
- type: Icon - type: Icon
sprite: Constructible/Atmos/pipe.rsi sprite: Constructible/Atmos/pipe.rsi
- type: entity
parent: PipeBase
id: PipeHalf
suffix: Half
components:
- type: NodeContainer
nodes:
- !type:PipeNode
nodeGroupID: Pipe
pipeDirection: North
- type: Icon
state: pipeHalf2
- type: entity - type: entity
parent: PipeBase parent: PipeBase
id: PipeStraight id: PipeStraight

View File

@@ -25,6 +25,24 @@
] ]
] ]
}, },
{
"name":"pipeHalf2",
"directions":4,
"delays":[
[
1.0
],
[
1.0
],
[
1.0
],
[
1.0
]
]
},
{ {
"name":"pipeBend2", "name":"pipeBend2",
"directions":4, "directions":4,

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B