Files
tbd-station-14/Content.Client/Lathe/LatheSystem.cs
Leon Friedrich 25b9e048e5 Visualizer systems update (#8203)
* optimize appearance updating for subfloor entities

* sprite event args

* a

* stop double appearance update.
2022-05-16 14:41:23 +10:00

57 lines
2.2 KiB
C#

using Robust.Client.GameObjects;
using Content.Shared.Lathe;
using Content.Shared.Power;
using Content.Client.Power;
using Content.Client.Wires.Visualizers;
using Content.Shared.Wires;
namespace Content.Client.Lathe
{
public sealed class LatheSystem : VisualizerSystem<LatheVisualsComponent>
{
protected override void OnAppearanceChange(EntityUid uid, LatheVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (args.Component.TryGetData(PowerDeviceVisuals.Powered, out bool powered) &&
args.Sprite.LayerMapTryGet(PowerDeviceVisualLayers.Powered, out _))
{
args.Sprite.LayerSetVisible(PowerDeviceVisualLayers.Powered, powered);
}
if (args.Component.TryGetData(WiresVisuals.MaintenancePanelState, out bool panel)
&& args.Sprite.LayerMapTryGet(WiresVisualizer.WiresVisualLayers.MaintenancePanel, out _))
{
args.Sprite.LayerSetVisible(WiresVisualizer.WiresVisualLayers.MaintenancePanel, panel);
}
// Lathe specific stuff
if (args.Component.TryGetData(LatheVisuals.IsRunning, out bool isRunning))
{
var state = isRunning ? component.RunningState : component.IdleState;
args.Sprite.LayerSetAnimationTime(LatheVisualLayers.IsRunning, 0f);
args.Sprite.LayerSetState(LatheVisualLayers.IsRunning, state);
}
if (args.Component.TryGetData(LatheVisuals.IsInserting, out bool isInserting)
&& args.Sprite.LayerMapTryGet(LatheVisualLayers.IsInserting, out var isInsertingLayer))
{
if (args.Component.TryGetData(LatheVisuals.InsertingColor, out Color color)
&& !component.IgnoreColor)
{
args.Sprite.LayerSetColor(isInsertingLayer, color);
}
args.Sprite.LayerSetAnimationTime(isInsertingLayer, 0f);
args.Sprite.LayerSetVisible(isInsertingLayer, isInserting);
}
}
}
}
public enum LatheVisualLayers : byte
{
IsRunning,
IsInserting
}