Add events on animation starts (#6382)

* added AnimationStartedEvent

* added AnimationStarted event to Control

* reordered Control.AnimationStarted above Control.AnimationCompleted

* fixed comment

* switched to internal constructor and proxy method
This commit is contained in:
Ataman
2026-01-19 23:29:22 +01:00
committed by GitHub
parent 65ed19fa4e
commit 14b17aff6d
2 changed files with 33 additions and 0 deletions

View File

@@ -154,6 +154,9 @@ namespace Robust.Client.GameObjects
}
ent.Comp.PlayingAnimations.Add(key, playback);
var startedEvent = new AnimationStartedEvent(ent.Owner, ent.Comp, key);
RaiseLocalEvent(ent.Owner, startedEvent, true);
}
public bool HasRunningAnimation(EntityUid uid, string key)
@@ -199,6 +202,34 @@ namespace Robust.Client.GameObjects
}
}
/// <summary>
/// Raised whenever an animation started playing.
/// </summary>
public sealed class AnimationStartedEvent : EntityEventArgs
{
/// <summary>
/// The entity associated with the event.
/// </summary>
public EntityUid Uid { get; init; }
/// <summary>
/// The animation player component associated with the entity this event was raised on.
/// </summary>
public AnimationPlayerComponent AnimationPlayer { get; init; }
/// <summary>
/// The key associated with the animation that was started.
/// </summary>
public string Key { get; init; } = string.Empty;
internal AnimationStartedEvent(EntityUid uid, AnimationPlayerComponent animationPlayer, string key)
{
Uid = uid;
AnimationPlayer = animationPlayer;
Key = key;
}
}
/// <summary>
/// Raised whenever an animation stops, either due to running its course or being stopped manually.
/// </summary>

View File

@@ -12,6 +12,7 @@ namespace Robust.Client.UserInterface
{
private Dictionary<string, AnimationPlayback>? _playingAnimations;
public Action<string>? AnimationStarted;
public Action<string>? AnimationCompleted;
/// <summary>
@@ -27,6 +28,7 @@ namespace Robust.Client.UserInterface
_playingAnimations ??= new Dictionary<string, AnimationPlayback>();
_playingAnimations.Add(key, playback);
AnimationStarted?.Invoke(key);
}
public bool HasRunningAnimation(string key)