----------------------------------------------------------------------------
-- @Author: ViperGTS96--------------------www.vipergts96.com----------------
----------------------------------------------------------------------------
--------------------"The simplest design is the best design." --------------
---@v.1.0.0.0---------------------------------------------------------------
----------------------------------------------------------------------------
-- @date 24/1/2019-------------------------------------------
-------------------------------------------
-- http://www.vipergts96.com/autoLog/
-- https://gdn.giants-software.com/documentation_scripting_fs19.php

fs19vehicleSpecScript = {}
fs19vehicleSpecScript.title = "Vehicle Specialization Script";
fs19vehicleSpecScript.author = "ViperGTS96";
fs19vehicleSpecScript.modDirectory  = g_currentModDirectory;

function fs19vehicleSpecScript.prerequisitesPresent(specializations)
	return SpecializationUtil.hasSpecialization(Washable, specializations)-- Specialization requirement (optional)
		and SpecializationUtil.hasSpecialization(AnimatedVehicle, specializations);-- Specialization requirement (optional)
end;

function fs19vehicleSpecScript.registerEventListeners(vehicleType)
	for _, functionName in pairs( { "onLoad", "onPostLoad", "onUpdate", "onUpdateTick", "onDraw", "saveToXMLFile" } ) do
		SpecializationUtil.registerEventListener(vehicleType, functionName, fs19vehicleSpecScript);
	end;
end;

function fs19vehicleSpecScript:onLoad(savegame)
	--
	print("Load mod: '"..fs19vehicleSpecScript.title.."' by: '"..fs19vehicleSpecScript.author.."' loaded sucessfully.");
	--

--[[  
	if savegame ~= nil then
		local colorR = getXMLFloat(savegame.xmlFile, savegame.key .. string.format(".fs19vehicleSpecScript#currentRed"));
		local colorG = getXMLFloat(savegame.xmlFile, savegame.key .. string.format(".fs19vehicleSpecScript#currentGreen"));
		local colorB = getXMLFloat(savegame.xmlFile, savegame.key .. string.format(".fs19vehicleSpecScript#currentBlue"));
		local savedColorIndex = Utils.getNoNil(getXMLFloat(savegame.xmlFile, savegame.key .. string.format(".fs19vehicleSpecScript#currentColorIndex")), 0);
		if (colorR ~= nil and colorG ~= nil and colorB ~= nil) then
			self.colorRed, self.colorBlue, self.colorGreen, self.newColor = colorR, colorG, colorB, savedColorIndex;
		end;
]]
end;


function fs19vehicleSpecScript:onPostLoad(savegame)
--[[

	if self.spec_wheels ~= nil and self.spec_wheels.wheels ~= nil and #self.spec_wheels.wheels ~= 0 then
		for whlIndex, wheel in pairs(self.spec_wheels.wheels) do
			if wheel.isLeft and wheel.width > 0.2 then
				--
			elseif not wheel.isLeft and wheel.width > 0.2 then
				--
			end;
		end;
	end;

]]
end;

function fs19vehicleSpecScript:onUpdate(dt)
--[[
	if self.movingDirection ~= 0.0 then

	end;
]]
end;

function fs19vehicleSpecScript:onUpdateTick(dt)

end;

function fs19vehicleSpecScript:saveToXMLFile(xmlFile, key)
--[[ key includes the name of the script
	if self.colorRed ~= nil and self.colorBlue ~= nil and self.colorGreen ~= nil then
		setXMLFloat(xmlFile, key.."#currentRed",self.colorRed)
		setXMLFloat(xmlFile, key.."#currentGreen",self.colorBlue)
		setXMLFloat(xmlFile, key.."#currentBlue", self.colorGreen)
		setXMLInt(xmlFile,  key.."#currentColorIndex", self.newColor)
	end;
]]
end;

function fs19vehicleSpecScript:onDraw()
end;