This commit is contained in:
2021-04-06 23:35:02 +02:00
parent 441a483c8e
commit fcccaa8c51

View File

@@ -8,24 +8,11 @@ namespace ReallifeGamemode.Server.Util
{ {
public static class AnimationSync public static class AnimationSync
{ {
public static void SyncAnimation(this Player player, dynamic animations) public static void SyncAnimation(this Player player, dynamic animationName)
{ {
if (!player.HasData("Animation")) if (!player.HasData("Animation"))
player.SetData("Animation", String.Empty); player.SetData("Animation", String.Empty);
string animationName;
if (animations is List<string>)
{
animationName = animations.get(0);
List<string> nextAnimations = animations.Skip(1);
player.TriggerEvent("SERVER:QueueAnimations", nextAnimations.ToArray(), animationName);
}
else
{
animationName = animations;
}
string currentAnimation = player.GetData<string>("Animation"); string currentAnimation = player.GetData<string>("Animation");
string newAnimation = animationName; string newAnimation = animationName;
@@ -36,6 +23,14 @@ namespace ReallifeGamemode.Server.Util
player.SetData<string>("Animation", newAnimation); player.SetData<string>("Animation", newAnimation);
} }
public static void SyncAnimation(this Player player, List<string> animations)
{
string animationName = animations.ElementAt(0);
List<string> nextAnimations = animations.Skip(1).ToList();
player.SyncAnimation(animationName);
player.TriggerEvent("SERVER:QueueAnimations", nextAnimations.ToArray(), animationName);
}
/// <summary>Check if Player has any Animation playing. /// <summary>Check if Player has any Animation playing.
/// </summary> /// </summary>
/// <param name="player"></param> /// <param name="player"></param>