Minor door animation tweak (#43708)

is this bad
This commit is contained in:
Jessica M
2026-04-23 20:29:17 -07:00
committed by GitHub
parent 91f8e9490d
commit ebe5d47cc6
2 changed files with 26 additions and 11 deletions
+22 -7
View File
@@ -81,7 +81,10 @@ public sealed class DoorSystem : SharedDoorSystem
private void OnAnimationCompleted(Entity<DoorComponent> ent, ref AnimationCompletedEvent args)
{
if (args.Key != DoorComponent.OpenCloseKey || !TryComp<SpriteComponent>(ent, out var sprite))
if (args.Key != DoorComponent.OpenKey && args.Key != DoorComponent.CloseKey)
return;
if (!TryComp<SpriteComponent>(ent, out var sprite))
return;
switch (ent.Comp.State)
@@ -130,9 +133,15 @@ public sealed class DoorSystem : SharedDoorSystem
switch (state)
{
case DoorState.Open:
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.OpenCloseKey))
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.OpenKey))
return;
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.CloseKey))
{
_animationSystem.Stop(entity, null, DoorComponent.CloseKey);
_animationSystem.Play(entity, (Animation)entity.Comp.OpeningAnimation, DoorComponent.OpenKey);
}
foreach (var (layer, layerState) in entity.Comp.OpenSpriteStates)
{
// Allow animations to play while it's open (e.g., pinion);
@@ -143,9 +152,15 @@ public sealed class DoorSystem : SharedDoorSystem
return;
case DoorState.Closed:
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.OpenCloseKey))
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.CloseKey))
return;
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.OpenKey))
{
_animationSystem.Stop(entity, null, DoorComponent.OpenKey);
_animationSystem.Play(entity, (Animation)entity.Comp.OpeningAnimation, DoorComponent.CloseKey);
}
foreach (var (layer, layerState) in entity.Comp.ClosedSpriteStates)
{
_sprite.LayerSetAutoAnimated((entity.Owner, sprite), layer, true);
@@ -157,20 +172,20 @@ public sealed class DoorSystem : SharedDoorSystem
if (entity.Comp.OpeningAnimationTime == TimeSpan.Zero)
return;
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.OpenCloseKey))
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.OpenKey))
return;
_animationSystem.Play(entity, (Animation)entity.Comp.OpeningAnimation, DoorComponent.OpenCloseKey);
_animationSystem.Play(entity, (Animation)entity.Comp.OpeningAnimation, DoorComponent.OpenKey);
return;
case DoorState.Closing:
if (entity.Comp.ClosingAnimationTime == TimeSpan.Zero)
return;
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.OpenCloseKey))
if (_animationSystem.HasRunningAnimation(entity, DoorComponent.CloseKey))
return;
_animationSystem.Play(entity, (Animation)entity.Comp.ClosingAnimation, DoorComponent.OpenCloseKey);
_animationSystem.Play(entity, (Animation)entity.Comp.ClosingAnimation, DoorComponent.CloseKey);
return;
case DoorState.Denying:
@@ -137,10 +137,10 @@ public sealed partial class DoorComponent : Component
#region Graphics
/// <summary>
/// The key used when playing door opening/closing/emagging/deny animations.
/// </summary>
public const string OpenCloseKey = "door_animation_openclose";
public const string OpenKey = "door_animation_open";
public const string CloseKey = "door_animation_close";
/// <summary>
/// The key used when playing door deny animations.