Fix emag sparking animation on doors (#40350)

* Fix

* Update

* Comment
This commit is contained in:
Winkarst-cpu
2025-10-15 02:13:40 +03:00
committed by GitHub
parent 111805c03b
commit 2f09b117ca
7 changed files with 95 additions and 2 deletions

View File

@@ -68,7 +68,7 @@ public sealed class DoorSystem : SharedDoorSystem
{
new AnimationTrackSpriteFlick
{
LayerKey = DoorVisualLayers.BaseUnlit,
LayerKey = DoorVisualLayers.BaseEmagging,
KeyFrames =
{
new AnimationTrackSpriteFlick.KeyFrame(comp.EmaggingSpriteState, 0f),
@@ -92,6 +92,10 @@ public sealed class DoorSystem : SharedDoorSystem
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.AnimationKey))
_animationSystem.Stop(entity.Owner, DoorComponent.AnimationKey);
// We are checking beforehand since some doors may not have an emagging visual layer, and we don't want LayerSetVisible to throw an error.
if (_sprite.TryGetLayer(entity.Owner, DoorVisualLayers.BaseEmagging, out var _, false))
_sprite.LayerSetVisible(entity.Owner, DoorVisualLayers.BaseEmagging, state == DoorState.Emagging);
UpdateAppearanceForDoorState(entity, args.Sprite, state);
}
@@ -134,7 +138,9 @@ public sealed class DoorSystem : SharedDoorSystem
return;
case DoorState.Emagging:
_animationSystem.Play(entity, (Animation)entity.Comp.EmaggingAnimation, DoorComponent.AnimationKey);
// We are checking beforehand since some doors may not have an emagging visual layer.
if (_sprite.TryGetLayer(entity.Owner, DoorVisualLayers.BaseEmagging, out var _, false))
_animationSystem.Play(entity, (Animation)entity.Comp.EmaggingAnimation, DoorComponent.AnimationKey);
return;
}