mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 08:07:28 +00:00
* 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>
42 lines
1.3 KiB
C#
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),
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|
|
}
|