This commit is contained in:
2021-04-07 00:03:10 +02:00
parent ddc71b7d8e
commit 50355cf817
2 changed files with 17 additions and 8 deletions

View File

@@ -9,6 +9,8 @@ namespace ReallifeGamemode.Server.Util
{
public static class AnimationSync
{
public static Dictionary<Player, List<string>> animationPair = new Dictionary<Player, List<string>>();
public static void SyncAnimation(this Player player, dynamic animationName)
{
if (!player.HasData("Animation"))
@@ -28,10 +30,15 @@ namespace ReallifeGamemode.Server.Util
{
string animationName = animations.ElementAt(0);
List<string> nextAnimations = animations.Skip(1).ToList();
player.SendChatMessage(nextAnimations.ToString());
player.SyncAnimation(animationName);
if (nextAnimations.Count != 0)
player.TriggerEvent("SERVER:QueueAnimations", nextAnimations.ToArray(), animationName);
{
player.TriggerEvent("SERVER:QueueAnimation", animationName);
animationPair.Add(player, nextAnimations);
}
}
/// <summary>Check if Player has any Animation playing.
@@ -63,11 +70,14 @@ namespace ReallifeGamemode.Server.Util
public class AnimationSyncEvents : Script
{
[RemoteEvent("CLIENT:AnimPairTransition")]
public void AnimPairTransition(Player player, string JSON_transitionTo)
public void AnimPairTransition(Player player)
{
string[] transitionTo = (string[])JsonConvert.DeserializeObject(JSON_transitionTo);
player.SendChatMessage(transitionTo.ToString());
player.SyncAnimation(transitionTo.ToList<string>());
if (!AnimationSync.animationPair.ContainsKey(player))
return;
List<string> animationPairs = AnimationSync.animationPair[player];
player.SyncAnimation(animationPairs);
}
[RemoteEvent("CLIENT:ClearAnimationData")]