public static int GetPerkAdjustedAccruedCurrency(BuildingTypeVO buildingVO, uint startTime, uint endTime, List <ActivatedPerkData> allPerks) { int num = 0; int num2 = (int)(endTime - startTime); float num3 = ResourceGenerationPerkUtils.BaseCurrencyRate(buildingVO); if (allPerks != null && allPerks.Count > 0) { List <CurrencyPerkEffectDataTO> allCurrencyPerksEffectsActiveDuringTimeWindow = ResourceGenerationPerkUtils.GetAllCurrencyPerksEffectsActiveDuringTimeWindow(buildingVO.Currency, startTime, endTime, allPerks); allCurrencyPerksEffectsActiveDuringTimeWindow.Sort(new Comparison <CurrencyPerkEffectDataTO>(ResourceGenerationPerkUtils.StartTimeCompare)); List <CurrencyPerkEffectDataTO> list = ResourceGenerationPerkUtils.CombineOverlappingPerkEffectsIntoFinalList(allCurrencyPerksEffectsActiveDuringTimeWindow, startTime, endTime); int count = list.Count; int num4 = 0; while (num4 < count && num2 > 0) { CurrencyPerkEffectDataTO currencyPerkEffectDataTO = list[num4]; int num5 = currencyPerkEffectDataTO.Duration; if (num5 > num2) { num5 = num2; } float num6 = (1f + currencyPerkEffectDataTO.RateBonus) * num3; num += Mathf.FloorToInt(num6 * (float)num5); num2 -= num5; num4++; } } if (num2 > 0) { num += Mathf.FloorToInt(num3 * (float)num2); } return(num); }
public static int GetPerkAdjustSecondsTillFull(BuildingTypeVO buildingVO, float remainingAmountTillFull, uint currentTime, List <ActivatedPerkData> allPerks) { int num = 0; float num2 = ResourceGenerationPerkUtils.BaseCurrencyRate(buildingVO); if (allPerks != null && allPerks.Count > 0) { List <CurrencyPerkEffectDataTO> allCurrencyPerksEffectsActiveDuringTimeWindow = ResourceGenerationPerkUtils.GetAllCurrencyPerksEffectsActiveDuringTimeWindow(buildingVO.Currency, currentTime, currentTime, allPerks); allCurrencyPerksEffectsActiveDuringTimeWindow.Sort(new Comparison <CurrencyPerkEffectDataTO>(ResourceGenerationPerkUtils.EndTimeCompare)); List <CurrencyPerkEffectDataTO> list = ResourceGenerationPerkUtils.CombineOverlappingPerkEffectsIntoFinalList(allCurrencyPerksEffectsActiveDuringTimeWindow, currentTime, 4294967295u); int count = list.Count; int num3 = 0; while (num3 < count && remainingAmountTillFull > 0f) { CurrencyPerkEffectDataTO currencyPerkEffectDataTO = list[num3]; int num4 = currencyPerkEffectDataTO.Duration; float num5 = (1f + currencyPerkEffectDataTO.RateBonus) * num2; float num6 = num5 * (float)num4; if (num6 > remainingAmountTillFull) { num6 = remainingAmountTillFull; num4 = Mathf.FloorToInt(num6 / num5); } remainingAmountTillFull -= num6; num += num4; num3++; } } if (remainingAmountTillFull > 0f) { num += Mathf.FloorToInt(remainingAmountTillFull / num2); } return(num); }