mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Adds a check to see if a faxecute animation is being played before playing another animation. The old code can thrown an exception which I've seen on live while ghosting. (cherry picked from commit b04f98513c498c9994caaa7c8412e67a19dc6c3e)
55 lines
1.8 KiB
C#
55 lines
1.8 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 class FaxVisualsSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly AnimationPlayerSystem _player = default!;
|
|
[Dependency] private readonly 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),
|
|
new AnimationTrackSpriteFlick.KeyFrame("icon", 2.4f),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"faxecute");
|
|
}
|
|
}
|
|
}
|