--Output Cache	

local NCache = {}
local ECache = {}
local TCache = {}
local SCache = {}

for gear,ratio in pairs(_Tune.Ratios) do
	local nhpPlot = {}
	local ehpPlot = {}
	local thpPlot = {}
	local shpPlot = {}
	for rpm = 0, math.ceil((_Tune.Redline+100)/100) do
		local ntqPlot = {}
		local etqPlot = {}
		local ttqPlot = {}
		local stqPlot = {}
		if rpm~=0 then
			if _Tune.Engine then
				ntqPlot.Horsepower,ntqPlot.Torque = GetNCurve(rpm*100,gear-2)
				if _TCount~=0 then
					ttqPlot.Horsepower,ttqPlot.Torque = GetTCurve(rpm*100,gear-2)
				else
					ttqPlot.Horsepower,ttqPlot.Torque = 0,0
				end
				if _SCount~=0 then
					stqPlot.Horsepower,stqPlot.Torque = GetSCurve(rpm*100,gear-2)
				else
					stqPlot.Horsepower,stqPlot.Torque = 0,0
				end
			else
				ntqPlot.Horsepower,ntqPlot.Torque = 0,0
				ttqPlot.Horsepower,ttqPlot.Torque = 0,0
				stqPlot.Horsepower,stqPlot.Torque = 0,0
			end
			if _Tune.Electric then
				etqPlot.Horsepower,etqPlot.Torque = GetECurve(rpm*100,gear-2)
			else
				etqPlot.Horsepower,etqPlot.Torque = 0,0
			end
		else
			ntqPlot.Horsepower,ntqPlot.Torque = 0,0
			etqPlot.Horsepower,etqPlot.Torque = 0,0
			ttqPlot.Horsepower,ttqPlot.Torque = 0,0
			stqPlot.Horsepower,stqPlot.Torque = 0,0
		end
		if _Tune.Engine then
			nhp,ntq = GetNCurve((rpm+1)*100,gear-2)
			if _TCount~=0 then
				thp,ttq = GetTCurve((rpm+1)*100,gear-2)
			else
				thp,ttq = 0,0
			end
			if _SCount~=0 then
				shp,stq = GetSCurve((rpm+1)*100,gear-2)
			else
				shp,stq = 0,0
			end
		else
			nhp,ntq = 0,0
			thp,ttq = 0,0
			shp,stq = 0,0
		end
		if _Tune.Electric then
			ehp,etq = GetECurve((rpm+1)*100,gear-2)
		else
			ehp,etq = 0,0
		end
		ntqPlot.HpSlope,ntqPlot.TqSlope = (nhp-ntqPlot.Horsepower),(ntq-ntqPlot.Torque)
		etqPlot.HpSlope,etqPlot.TqSlope = (ehp-etqPlot.Horsepower),(etq-etqPlot.Torque)
		ttqPlot.HpSlope,ttqPlot.TqSlope = (thp-ttqPlot.Horsepower),(ttq-ttqPlot.Torque)
		stqPlot.HpSlope,stqPlot.TqSlope = (shp-stqPlot.Horsepower),(stq-stqPlot.Torque)
		nhpPlot[rpm] = ntqPlot
		ehpPlot[rpm] = etqPlot
		thpPlot[rpm] = ttqPlot
		shpPlot[rpm] = stqPlot
	end
	table.insert(NCache,nhpPlot)
	table.insert(ECache,ehpPlot)
	table.insert(TCache,thpPlot)
	table.insert(SCache,shpPlot)
end
