D:\ValheimDev\Dumps\Old\assembly_valheim\RandomAnimation.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\RandomAnimation.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
.  using System.Text;
using UnityEngine; using UnityEngine;
   
public class RandomAnimation : MonoBehaviour public class RandomAnimation : MonoBehaviour
{ {
    private void Start()     private void Start()
    {     {
        this.m_anim = base.GetComponentInChildren<Animator>();         this.m_anim = base.GetComponentInChildren<Animator>();
        this.m_nview = base.GetComponent<ZNetView>();         this.m_nview = base.GetComponent<ZNetView>();
    }     }
   
    private void FixedUpdate()     private void FixedUpdate()
    {     {
        if (this.m_nview != null && !this.m_nview.IsValid())         if (this.m_nview != null && !this.m_nview.IsValid())
        {         {
            return;             return;
        }         }
        float fixedDeltaTime = Time.fixedDeltaTime;         float fixedDeltaTime = Time.fixedDeltaTime;
        foreach (RandomAnimation.RandomValue randomValue in this.m_values)         foreach (RandomAnimation.RandomValue randomValue in this.m_values)
        {         {
.              this.m_sb.Clear();
              this.m_sb.Append("RA_");
              this.m_sb.Append(randomValue.m_name);
            if (this.m_nview == null || this.m_nview.IsOwner())             if (this.m_nview == null || this.m_nview.IsOwner())
            {             {
                randomValue.m_timer += fixedDeltaTime;                 randomValue.m_timer += fixedDeltaTime;
                if (randomValue.m_timer > randomValue.m_interval)                 if (randomValue.m_timer > randomValue.m_interval)
                {                 {
                    randomValue.m_timer = 0f;                     randomValue.m_timer = 0f;
                    randomValue.m_value = UnityEngine.Random.Range(0, randomValue.m_values);                     randomValue.m_value = UnityEngine.Random.Range(0, randomValue.m_values);
                    if (this.m_nview)                     if (this.m_nview)
                    {                     {
.                        this.m_nview.GetZDO().Set("RA_" + randomValue.m_name, randomValue.m_value);                         this.m_nview.GetZDO().Set(this.m_sb.ToString(), randomValue.m_value);
                    }                     }
                    if (!randomValue.m_floatValue)                     if (!randomValue.m_floatValue)
                    {                     {
                        this.m_anim.SetInteger(randomValue.m_name, randomValue.m_value);                         this.m_anim.SetInteger(randomValue.m_name, randomValue.m_value);
                    }                     }
                }                 }
            }             }
            if (this.m_nview && !this.m_nview.IsOwner())             if (this.m_nview && !this.m_nview.IsOwner())
            {             {
.                int @int = this.m_nview.GetZDO().GetInt("RA_" + randomValue.m_name, 0);                 int @int = this.m_nview.GetZDO().GetInt(this.m_sb.ToString(), 0);
                if (@int != randomValue.m_value)                 if (@int != randomValue.m_value)
                {                 {
                    randomValue.m_value = @int;                     randomValue.m_value = @int;
                    if (!randomValue.m_floatValue)                     if (!randomValue.m_floatValue)
                    {                     {
                        this.m_anim.SetInteger(randomValue.m_name, randomValue.m_value);                         this.m_anim.SetInteger(randomValue.m_name, randomValue.m_value);
                    }                     }
                }                 }
            }             }
            if (randomValue.m_floatValue)             if (randomValue.m_floatValue)
            {             {
.                if (randomValue.m_hashValues == null || randomValue.m_hashValues.Length != randomValue.m_values)                 if (randomValue.m_hashValues.Count != randomValue.m_values)
                {                 {
.                    randomValue.m_hashValues = new int[randomValue.m_values];                     randomValue.m_hashValues.Resize(randomValue.m_values);
                    for (int i = 0; i < randomValue.m_values; i++)                     for (int i = 0; i < randomValue.m_values; i++)
                    {                     {
.                        randomValue.m_hashValues[i] = ZSyncAnimation.GetHash(randomValue.m_name + i.ToString());                         this.m_sb.Clear(); 
                          this.m_sb.Append(randomValue.m_name); 
                          this.m_sb.Append(i.ToString()); 
                          randomValue.m_hashValues[i] = ZSyncAnimation.GetHash(this.m_sb.ToString());
                    }                     }
                }                 }
                for (int j = 0; j < randomValue.m_values; j++)                 for (int j = 0; j < randomValue.m_values; j++)
                {                 {
                    float num = this.m_anim.GetFloat(randomValue.m_hashValues[j]);                     float num = this.m_anim.GetFloat(randomValue.m_hashValues[j]);
                    if (j == randomValue.m_value)                     if (j == randomValue.m_value)
                    {                     {
                        num = Mathf.MoveTowards(num, 1f, fixedDeltaTime / randomValue.m_floatTransition);                         num = Mathf.MoveTowards(num, 1f, fixedDeltaTime / randomValue.m_floatTransition);
                    }                     }
                    else                     else
                    {                     {
                        num = Mathf.MoveTowards(num, 0f, fixedDeltaTime / randomValue.m_floatTransition);                         num = Mathf.MoveTowards(num, 0f, fixedDeltaTime / randomValue.m_floatTransition);
                    }                     }
                    this.m_anim.SetFloat(randomValue.m_hashValues[j], num);                     this.m_anim.SetFloat(randomValue.m_hashValues[j], num);
                }                 }
            }             }
        }         }
    }     }
   
    public List<RandomAnimation.RandomValue> m_values = new List<RandomAnimation.RandomValue>();     public List<RandomAnimation.RandomValue> m_values = new List<RandomAnimation.RandomValue>();
   
    private Animator m_anim;     private Animator m_anim;
   
    private ZNetView m_nview;     private ZNetView m_nview;
   
.      private readonly StringBuilder m_sb = new StringBuilder();
   
    [Serializable]     [Serializable]
    public class RandomValue     public class RandomValue
    {     {
        public string m_name;         public string m_name;
   
        public int m_values;         public int m_values;
   
        public float m_interval;         public float m_interval;
   
        public bool m_floatValue;         public bool m_floatValue;
   
        public float m_floatTransition = 1f;         public float m_floatTransition = 1f;
   
        [NonSerialized]         [NonSerialized]
        public float m_timer;         public float m_timer;
   
        [NonSerialized]         [NonSerialized]
        public int m_value;         public int m_value;
   
        [NonSerialized]         [NonSerialized]
.        public int[] m_hashValues;         public List<int> m_hashValues = new List<int>();
    }     }
} }