]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix(FaxVisualsSystem): Fax can Play() when a anim key has been added. (#30013)
authorCaasGit <87243814+CaasGit@users.noreply.github.com>
Sat, 20 Jul 2024 03:36:22 +0000 (20:36 -0700)
committerGitHub <noreply@github.com>
Sat, 20 Jul 2024 03:36:22 +0000 (13:36 +1000)
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.

Content.Client/Fax/System/FaxVisualsSystem.cs

index 892aec1d95490ccecf5fb8a2cbc7e2106435e912..e752fbf48e69542e80ca14bbe0baf4524f0e59c9 100644 (file)
@@ -25,24 +25,30 @@ public sealed class FaxVisualsSystem : EntitySystem
         if (args.Sprite == null)
             return;
 
-        if (_appearance.TryGetData(uid, FaxMachineVisuals.VisualState, out FaxMachineVisualState visuals) && visuals == FaxMachineVisualState.Inserting)
+        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 =
+            _player.Play(uid,
+                new Animation()
                 {
-                    new AnimationTrackSpriteFlick()
+                    Length = TimeSpan.FromSeconds(2.4),
+                    AnimationTracks =
                     {
-                        LayerKey = FaxMachineVisuals.VisualState,
-                        KeyFrames =
+                        new AnimationTrackSpriteFlick()
                         {
-                            new AnimationTrackSpriteFlick.KeyFrame(component.InsertingState, 0f),
-                            new AnimationTrackSpriteFlick.KeyFrame("icon", 2.4f),
-                        }
-                    }
-                }
-            }, "faxecute");
+                            LayerKey = FaxMachineVisuals.VisualState,
+                            KeyFrames =
+                            {
+                                new AnimationTrackSpriteFlick.KeyFrame(component.InsertingState, 0f),
+                                new AnimationTrackSpriteFlick.KeyFrame("icon", 2.4f),
+                            },
+                        },
+                    },
+                },
+                "faxecute");
         }
     }
 }