Files
Delta-v/Content.Client/_DV/Pager/PagerButtonSystem.cs
pathetic meowmeowandpre-commit-ci[bot] 3267b4c2a8 Doorbells (#5799)
* doored bell

* doored bell

* rezept

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-05-16 10:08:49 -05:00

42 lines
1.3 KiB
C#

using Content.Shared._DV.Pager;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
namespace Content.Client._DV.Pager;
public sealed class PagerButtonSystem : SharedPagerButtonSystem
{
[Dependency] private readonly AnimationPlayerSystem _animationPlayer = default!;
private const string AnimateKey = "pager-press";
protected override void AfterActivated(Entity<PagerButtonComponent> ent)
{
if (!_animationPlayer.HasRunningAnimation(ent.Owner, AnimateKey))
_animationPlayer.Play(ent.Owner, GetAnimation(ent), AnimateKey);
}
private Animation GetAnimation(Entity<PagerButtonComponent> ent)
{
const float flickDuration = 20f / 60f;
return new Animation()
{
Length = TimeSpan.FromSeconds(flickDuration),
AnimationTracks =
{
new AnimationTrackSpriteFlick()
{
LayerKey = PagerButtonVisualLayers.Base,
KeyFrames =
{
new AnimationTrackSpriteFlick.KeyFrame(ent.Comp.PressState, 0f),
new AnimationTrackSpriteFlick.KeyFrame(ent.Comp.UnpressedState, flickDuration),
},
},
},
};
}
}