mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
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:
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user