Files
tbd-station-14/Content.Client/GameObjects/Components/Recycling/RecyclerVisualizer.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

68 lines
1.9 KiB
C#

using Content.Shared.GameObjects.Components.Recycling;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Recycling
{
[UsedImplicitly]
public class RecyclerVisualizer : AppearanceVisualizer
{
private string _stateClean;
private string _stateBloody;
public override void LoadData(YamlMappingNode node)
{
base.LoadData(node);
if (node.TryGetNode("state_clean", out var child))
{
_stateClean = child.AsString();
}
if (node.TryGetNode("state_bloody", out child))
{
_stateBloody = child.AsString();
}
}
public override void InitializeEntity(IEntity entity)
{
base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite) ||
!entity.TryGetComponent(out AppearanceComponent appearance))
{
return;
}
appearance.TryGetData(RecyclerVisuals.Bloody, out bool bloody);
sprite.LayerSetState(RecyclerVisualLayers.Bloody, bloody
? _stateBloody
: _stateClean);
}
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite))
{
return;
}
component.TryGetData(RecyclerVisuals.Bloody, out bool bloody);
sprite.LayerSetState(RecyclerVisualLayers.Bloody, bloody
? _stateBloody
: _stateClean);
}
}
public enum RecyclerVisualLayers : byte
{
Bloody
}
}