// ------------------------------------------------------------------------------- // SetCache_AutoGenerateCurrency_Production // ------------------------------------------------------------------------------- public void SetCache_AutoGenerateCurrency_Production(CurrencyTemplate _template, long _value) { if (cacheEntries.TryGetValue(_template.hash, out DataCacheEntry entry)) { entry.autoGenerateCurrencyProduction = _value; } }
// ------------------------------------------------------------------------------- // GetDuration_AutoGenerateCurrency // ------------------------------------------------------------------------------- public virtual float GetDuration_AutoGenerateCurrency <T>(List <T> syncData, CurrencyTemplate _template, float _baseValue, int _level = 0) { // -- check cache if (cacheData.CheckCache_AutoGenerateCurrency(_template)) { return(cacheData.GetCache_AutoGenerateCurrency_Duration(_template)); } // -- recalculate everything if cache is out of date float value = 0; foreach (ISyncableStruct <T> data in syncData.OfType <ISyncableStruct <T> >()) { if (!data.Valid) { continue; } IterateableTemplate template = data as IterateableTemplate; foreach (GenerateCurrencyModifier modifier in template.autoGenerateCurrencyModifier) { value += modifier.GetDurationModifier(_template, (_level == 0) ? data.level : _level, _baseValue); } } return(value); }
// ================== AUTO CURRENCY PRODUCTION - DURATION ======================== // ------------------------------------------------------------------------------- // GetCache_AutoGenerateCurrency_Duration // ------------------------------------------------------------------------------- public float GetCache_AutoGenerateCurrency_Duration(CurrencyTemplate _template) { if (cacheEntries.TryGetValue(_template.hash, out DataCacheEntry entry)) { return(entry.autoGenerateCurrencyDuration); } return(0); }
// ==================== AUTO GENERATE CURRENCY - CAPACITY ======================== // ------------------------------------------------------------------------------- // GetCache_AutoGenerateCurrency_Capacity // ------------------------------------------------------------------------------- public long GetCache_AutoGenerateCurrency_Capacity(CurrencyTemplate _template) { if (cacheEntries.TryGetValue(_template.hash, out DataCacheEntry entry)) { return(entry.autoGenerateCurrencyCapacity); } return(0); }
// ==================== AUTO GENERATE CURRENCY - CACHE =========================== // ------------------------------------------------------------------------------- // CheckCache_AutoGenerateCurrency // ------------------------------------------------------------------------------- public bool CheckCache_AutoGenerateCurrency(CurrencyTemplate _template) { if (cacheEntries.TryGetValue(_template.hash, out DataCacheEntry entry)) { return(entry.CheckUpdateInterval(cacheUpdateInterval)); } else { cacheEntries.Add(_template.hash, new DataCacheEntry()); } return(false); }
// ------------------------------------------------------------------------------- public float GetDurationModifier(CurrencyTemplate _template, int _level, float _baseValue) { float value = 0; if (template != _template) { return(value); } value += durationFlat.Get(_level); value += _baseValue * durationPercent.Get(_level); return(value); }
// ------------------------------------------------------------------------------- public long GetProductionModifier(CurrencyTemplate _template, int _level, long _baseValue) { long value = 0; if (template != _template) { return(value); } value += productionFlat.Get(_level); value += Convert.ToInt64(_baseValue * productionPercent.Get(_level)); return(value); }
// ------------------------------------------------------------------------------- public long GetCapacityModifier(CurrencyTemplate _template, int _level, long _baseValue) { long value = 0; if (template != _template) { return(value); } value += capacityFlat.Get(_level); value += Convert.ToInt64(_baseValue * capacityPercent.Get(_level)); return(value); }
public void AddEntry(CurrencyTemplate _template, int _slot, long _amount, long _timeStamp) { CurrencySyncStruct syncStruct = new CurrencySyncStruct(_template, _slot, _amount, _timeStamp); syncData.Add(syncStruct); }