public void PayCost(LevelCurrencyCost[] _cost, int _level)
 {
     foreach (LevelCurrencyCost cost in _cost)
     {
         for (int i = 0; i < syncData.Count; i++)
         {
             if (syncData[i].template == cost.template)
             {
                 CurrencySyncStruct entry = syncData[i];
                 entry.value -= cost.value.Get(_level);
                 syncData[i]  = entry;
             }
         }
     }
 }
 public void PayCost(FixedCurrencyCost[] _cost, long _value)
 {
     foreach (FixedCurrencyCost cost in _cost)
     {
         for (int i = 0; i < syncData.Count; i++)
         {
             if (syncData[i].template == cost.template)
             {
                 CurrencySyncStruct entry = syncData[i];
                 entry.value -= cost.value * _value;
                 syncData[i]  = entry;
             }
         }
     }
 }
        protected override void UpdateServer()
        {
            for (int i = 0; i < syncData.Count; i++)
            {
                if (!syncData[i].Valid)
                {
                    continue;
                }
                CurrencySyncStruct entry = syncData[i];

                entry.modifierCapacity   = GetCapacity_AutoGenerateCurrency <CurrencySyncStruct>(GetEntries(), entry.template, entry.GetBaseCapacity(this.gameObject), level);
                entry.modifierProduction = GetProduction_AutoGenerateCurrency <CurrencySyncStruct>(GetEntries(), entry.template, entry.GetBaseProduction(this.gameObject), level);
                entry.modifierDuration   = GetDuration_AutoGenerateCurrency <CurrencySyncStruct>(GetEntries(), entry.template, entry.GetBaseDuration(this.gameObject), level);

                entry.Update(this.gameObject);
                syncData[i] = entry;
            }
        }
        public void AddCurrency(FixedCurrencyCost[] _cost, long _value)
        {
            foreach (FixedCurrencyCost cost in _cost)
            {
                int index = syncData.FindIndex(x => x.template == cost.template);

                if (index != -1)
                {
                    CurrencySyncStruct entry = syncData[index];
                    entry.value    += cost.value * _value;
                    syncData[index] = entry;
                }
                else
                {
                    index = GetFreeSlot();
                    if (index != -1)
                    {
                        AddEntry(cost.template, index, cost.value * _value, 0);
                    }
                }
            }
        }
        public void AddEntry(CurrencyTemplate _template, int _slot, long _amount, long _timeStamp)
        {
            CurrencySyncStruct syncStruct = new CurrencySyncStruct(_template, _slot, _amount, _timeStamp);

            syncData.Add(syncStruct);
        }