Piping sprites cleanup (#3022)

* Moves piping visualizers to own folder

* Pump visualizer update

* Siphon and vent visualiser only set enabled visibility

* PipeVisualizer cleanup

* Replaces off vent/scrubber sprites

* Gas filter sprite update

* Revert "Gas filter sprite update"

This reverts commit 676e5d55e1157a229b1445eeea53a5c8032dbbb5.

* Rotates gas filter sprites to match T-junction pipe directions

* Removes pipes from scruber and vent state

* Makes sprite components use layers

* disabled sprite netsync on piping entities

* piping meta.json cleanup

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2021-01-19 07:26:16 -06:00
committed by GitHub
parent 6a41194bc9
commit f9f724b4af
27 changed files with 251 additions and 358 deletions

View File

@@ -0,0 +1,78 @@
using System;
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.Serialization;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Atmos
{
[UsedImplicitly]
public class PipeVisualizer : AppearanceVisualizer
{
private string _rsiString;
private RSI _pipeRSI;
public override void LoadData(YamlMappingNode node)
{
base.LoadData(node);
var serializer = YamlObjectSerializer.NewReader(node);
serializer.DataField(ref _rsiString, "rsiString", "Constructible/Atmos/pipe.rsi");
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);
}
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return;
if (!component.TryGetData(PipeVisuals.VisualState, out PipeVisualState pipeVisualState)) return;
var pipeBase = sprite.LayerMapGet(Layer.PipeBase);
var pipeBaseStateId = GetPipeBaseStateId(pipeVisualState);
sprite.LayerSetState(pipeBase, pipeBaseStateId);
}
private string GetPipeBaseStateId(PipeVisualState pipeVisualState)
{
var stateId = "pipe";
stateId += pipeVisualState.PipeDirection.PipeDirectionToPipeShape().ToString();
return stateId;
}
private enum Layer : byte
{
PipeBase,
}
}
}