private int HandleSpeedDown(int baseValue, int totalValue, int orignalSpeed) { if (this.bUseStepAdjustWhenSpeedDown) { int num = 0; bool flag = false; for (int i = 0; i < this.SpeedDownConfigs.get_Count(); i++) { RangeConfig rangeConfig = this.SpeedDownConfigs.get_Item(i); int num2 = 0; int num3 = 0; if (rangeConfig.Intersect(this.bReferenceBaseSpeedWhenSpeedDown ? baseValue : 0, totalValue, orignalSpeed, out num2, out num3)) { flag = true; int num4 = num3 - num2; num4 *= 100 - rangeConfig.Attenuation; num4 /= 100; num += num4; } else if (flag) { break; } } return(orignalSpeed - num); } for (int j = 0; j < this.SpeedDownConfigs.get_Count(); j++) { if (this.SpeedDownConfigs.get_Item(j).Intersect(this.bReferenceBaseSpeedWhenSpeedUp ? baseValue : 0, totalValue)) { return(this.SpeedDownConfigs.get_Item(j).MaxValue - (this.SpeedDownConfigs.get_Item(j).MaxValue - totalValue) * (100 - this.SpeedDownConfigs.get_Item(j).Attenuation) / 100); } } return(totalValue); }
private static int HandleSpeedUp(int baseValue, int totalValue, int orignalSpeed) { int num = 0; bool flag = false; for (int i = 0; i < s_SpeedUpRanges.Length; i++) { RangeConfig config = s_SpeedUpRanges[i]; int outMin = 0; int outMax = 0; if (config.Intersect(baseValue, orignalSpeed, totalValue, out outMin, out outMax)) { flag = true; int num5 = outMax - outMin; num5 *= 100 - config.Attenuation; num5 /= 100; num += num5; } else if (flag) { break; } } return(orignalSpeed + num); }
public bool Intersect(int InBase, int InMin, int InMax, out int OutMin, out int OutMax) { OutMin = (OutMax = 0); int num = this.MinValue + InBase; int num2 = this.MaxValue + InBase; if (InMax < num) { return(false); } if (InMin > num2) { return(false); } OutMin = RangeConfig.Clamp(InMin, num, num2); OutMax = RangeConfig.Clamp(InMax, num, num2); return(true); }
public override void Init() { base.Init(); ResSpeedAdjustConfig dataByKey = GameDataMgr.speedAdjusterDatabin.GetDataByKey(0u); ResSpeedAdjustConfig dataByKey2 = GameDataMgr.speedAdjusterDatabin.GetDataByKey(1u); this.bActiveSys = (dataByKey != null && dataByKey2 != null); if (!this.bActiveSys) { return; } this.SpeedUpConfigs.Clear(); this.bActiveWhenSpeedUp = (dataByKey.bValid == 1); this.bReferenceBaseSpeedWhenSpeedUp = (dataByKey.bReferenceBaseSpeed == 1); this.bUseStepAdjustWhenSpeedUp = (dataByKey.bStepAdjust == 1); for (int i = 0; i < dataByKey.astRangeConfigs.Length; i++) { if (dataByKey.astRangeConfigs[i].bValid != 1) { break; } RangeConfig rangeConfig = default(RangeConfig); rangeConfig.MinValue = dataByKey.astRangeConfigs[i].iMinValue; rangeConfig.MaxValue = dataByKey.astRangeConfigs[i].iMaxValue; rangeConfig.Attenuation = (int)dataByKey.astRangeConfigs[i].bAttenuation; this.SpeedUpConfigs.Add(rangeConfig); } this.SpeedDownConfigs.Clear(); this.bActiveWhenSpeedDown = (dataByKey2.bValid == 1); this.bReferenceBaseSpeedWhenSpeedDown = (dataByKey2.bReferenceBaseSpeed == 1); this.bUseStepAdjustWhenSpeedDown = (dataByKey2.bStepAdjust == 1); for (int j = 0; j < dataByKey2.astRangeConfigs.Length; j++) { if (dataByKey2.astRangeConfigs[j].bValid != 1) { break; } RangeConfig rangeConfig2 = default(RangeConfig); rangeConfig2.MinValue = dataByKey2.astRangeConfigs[j].iMinValue; rangeConfig2.MaxValue = dataByKey2.astRangeConfigs[j].iMaxValue; rangeConfig2.Attenuation = (int)dataByKey2.astRangeConfigs[j].bAttenuation; this.SpeedDownConfigs.Add(rangeConfig2); } }