CatStation/Content.Client/Fax/System/FaxVisualsSystem.cs
AsnDen 5bef97b9ff
Faxes are colored (again) (#38387)
* Faxes are colored (again)

* copyright
2026-07-14 05:03:34 +00:00

53 lines
1.7 KiB
C#

using Robust.Client.GameObjects;
using Content.Shared.Fax.Components;
using Content.Shared.Fax;
using Robust.Client.Animations;
namespace Content.Client.Fax.System;
/// <summary>
/// Visualizer for the fax machine which displays the correct sprite based on the inserted entity.
/// </summary>
public sealed partial class FaxVisualsSystem : EntitySystem
{
[Dependency] private AnimationPlayerSystem _player = default!;
[Dependency] private SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FaxMachineComponent, AppearanceChangeEvent>(OnAppearanceChanged);
}
private void OnAppearanceChanged(EntityUid uid, FaxMachineComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (_player.HasRunningAnimation(uid, "faxecute"))
return;
if (_appearance.TryGetData(uid, FaxMachineVisuals.VisualState, out FaxMachineVisualState visuals) &&
visuals == FaxMachineVisualState.Inserting)
{
_player.Play(uid,
new Animation()
{
Length = TimeSpan.FromSeconds(2.4),
AnimationTracks =
{
new AnimationTrackSpriteFlick()
{
LayerKey = FaxMachineVisuals.VisualState,
KeyFrames =
{
new AnimationTrackSpriteFlick.KeyFrame(component.InsertingState, 0f)
},
},
},
},
"faxecute");
}
}
}