/// <summary>
 /// Sets the Linker to listen to the passed stat's value change
 /// event and set's the value of LinkedStat.
 /// </summary>
 private void SetLinkedStat(RPGStat stat)
 {
     if (stat == null)
     {
         UnityEngine.Debug.LogWarning("Stat Linker was created with null reference to a stat.");
     }
     LinkedStat = stat;
 }
        public void LoadFromDefine(RPGStatCollectionDefine define, bool replaceIfExist)
        {
            if (define == null)
            {
                Debug.LogError($"LoadFromDefine: null");
                return;
            }

            foreach (var data in define.getDefinedCollection())
            {
                RPGStat stat = null;

                switch (data.type)
                {
                case RPGStatCollectionDefine.RPGStatType.RPGStat:
                    stat = new RPGStat()
                    {
                        StatBaseValue = data.defaultValue
                    }; break;

                case RPGStatCollectionDefine.RPGStatType.RPGStatModifiable:
                    stat = new RPGStatModifiable()
                    {
                        StatBaseValue = data.defaultValue
                    }; break;

                case RPGStatCollectionDefine.RPGStatType.RPGAttribute:
                    stat = new RPGAttribute()
                    {
                        StatBaseValue = data.defaultValue
                    }; break;

                case RPGStatCollectionDefine.RPGStatType.RPGVital:
                    stat = new RPGVital()
                    {
                        StatBaseValue = data.defaultValue
                    }; break;
                }

                AddStat(data.key, stat, replaceIfExist);

//                Debug.Log ( $"RPGStatCollection::LoadFromDefine() AddStat => {data.key.Colored(Colors.yellow)} {define}" );
            }
        }
 public RPGStatLinkerBasic(float ratio, RPGStat linkedStat) : base(linkedStat)
 {
     this._ratio = ratio;
 }
 /// <summary>
 /// Trys to get the RPGStat with the given RPGStatTypeId.
 /// If stat exists, returns true.
 /// </summary>
 public bool TryGetStat(string statTypeId, out RPGStat stat)
 {
     return(_core.TryGetStat(statTypeId, out stat));
 }
 /// <summary>
 /// Basic constructor that only takes a stat linker asset and
 /// a linked stat. Listens to the Stat's OnValueChange
 /// event if the stat implements IStatValueChange.
 /// </summary>
 public RPGStatLinker(RPGStat linkedStat)
 {
     SetLinkedStat(linkedStat);
 }
 /// <summary>
 /// Trys to get the RPGStat with the given RPGStatTypeId.
 /// If stat exists, returns true.
 /// </summary>
 public bool TryGetStat(string statTypeId, out RPGStat stat)
 {
     stat = GetStat(statTypeId);
     return(stat != null);
 }