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 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.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Utility;
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.ventvisualizer", "Unable to load RSI '{0}'. Trace:\n{1}", rsiPath, e);
}
}
public override void InitializeEntity(IEntity entity)
{
base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
sprite.LayerMapReserveBlank(Layer.PipeBase);
var pipeBaseLayer = sprite.LayerMapGet(Layer.PipeBase);
sprite.LayerSetRSI(pipeBaseLayer, _pipeRSI);
sprite.LayerSetVisible(pipeBaseLayer, true);
}