Files
tbd-station-14/Content.Client/Disease/DiseaseMachineSystem.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

32 lines
1.1 KiB
C#

using Robust.Client.GameObjects;
using Content.Shared.Disease;
namespace Content.Client.Disease
{
/// <summary>
/// Controls client-side visuals for the
/// disease machines.
/// </summary>
public sealed class DiseaseMachineSystem : VisualizerSystem<DiseaseMachineVisualsComponent>
{
protected override void OnAppearanceChange(EntityUid uid, DiseaseMachineVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (args.Component.TryGetData(DiseaseMachineVisuals.IsOn, out bool isOn)
&& args.Component.TryGetData(DiseaseMachineVisuals.IsRunning, out bool isRunning))
{
var state = isRunning ? component.RunningState : component.IdleState;
args.Sprite.LayerSetVisible(DiseaseMachineVisualLayers.IsOn, isOn);
args.Sprite.LayerSetState(DiseaseMachineVisualLayers.IsRunning, state);
}
}
}
}
public enum DiseaseMachineVisualLayers : byte
{
IsOn,
IsRunning
}