require "DAMN_Parts";
require "DAMN_Spawns";

--***********************************************************
--**                   KI5 / bikinihorst                   **
--***********************************************************

DAMN.Parts:processConfigV2("LTD91", {
	["BumperFront"] = {
		partId = "LTD91BumperFront",
		itemToModel = {
			["Base.91fordLTDBumperFront0"] = "FrontBumper0",
			["Base.91fordLTDBumperFront1"] = "FrontBumper1",
		},
		default = "first",
	},
    ["BumperFrontPD"] = {
		partId = "LTD91BumperFront",
		itemToModel = {
			["Base.91fordLTDBumperFront1"] = "FrontBumper1",
			["Base.91fordLTDBumperFront0"] = "FrontBumper0",
		},
		default = "first",
	},
	["BumperRear"] = {
		partId = "LTD91BumperRear",
		itemToModel = {
			["Base.91fordLTDBumperRear0"] = "BumperRear0",
		},
		default = "first",
	},
    ["BumperRearW"] = {
		partId = "LTD91BumperRear",
		itemToModel = {
			["Base.91fordLTDWagonBumperRear1"] = "BumperRear1",
		},
		default = "first",
	},
	["WindshieldArmor"] = {
		partId = "LTD91WindshieldArmor",
		itemToModel = {
			["Base.fordCVPIWindshieldArmor"] = "LTD91winda0",
		},
	},
	["WindshieldRearArmor"] = {
		partId = "LTD91WindshieldRearArmor",
		itemToModel = {
			["Base.fordCVPIWindshieldRearArmor"] = "LTD91windra",
		},
	},
    ["WindshieldRearArmorW"] = {
		partId = "LTD91WindshieldRearArmor",
		itemToModel = {
			["Base.91fordLTDWagonWindshieldRearArmor"] = "LTD91windrab",
		},
	},
	["WindowFrontLeftArmor"] = {
		partId = "LTD91WindowFrontLeftArmor",
		itemToModel = {
			["Base.fordCVPIFrontWindowArmor"] = "LTD91leftdoora",
		},
	},
	["WindowFrontRightArmor"] = {
		partId = "LTD91WindowFrontRightArmor",
		itemToModel = {
			["Base.fordCVPIFrontWindowArmor"] = "LTD91rightdoora",
		},
	},
	["WindowRearLeftArmor"] = {
		partId = "LTD91WindowRearLeftArmor",
		itemToModel = {
			["Base.fordCVPIRearWindowArmor"] = "LTD91leftdoorra",
		},
	},
	["WindowRearRightArmor"] = {
		partId = "LTD91WindowRearRightArmor",
		itemToModel = {
			["Base.fordCVPIRearWindowArmor"] = "LTD91rightdoorra",
		},
	},
    ["WindowBackLeftArmor"] = {
		partId = "LTD91WindowBackLeftArmor",
		itemToModel = {
			["Base.91fordLTDWagonBackWindowArmor"] = "LTD91leftwinba",
		},
	},
	["WindowBackRightArmor"] = {
		partId = "LTD91WindowBackRightArmor",
		itemToModel = {
			["Base.91fordLTDWagonBackWindowArmor"] = "LTD91rightwinba",
		},
	},
	["SpareTire"] = {
		partId = "LTD91SpareTire",
		itemToModel = {
			["Base.fordCVPITire1"] = "LTD91SpareTire0",
            ["Base.91fordLTDTire1"] = "LTD91SpareTire1",
		},
		default = "trve_random",
		noPartChance = 33,
	},
    ["RoofrackSedan"] = {
		partId = "LTD91Roofrack",
		itemToModel = {
			["Base.91fordLTDRoofrack1"] = {"LTD91Roofrack0", "LTD91Roofrack0b"},
		},
		default = "trve_random",
			noPartChance = 90,
	},
	["RoofrackWagon"] = {
		partId = "LTD91Roofrack",
		itemToModel = {
			["Base.91fordLTDRoofrack1"] = "LTD91Roofrack0",
		},
		default = "trve_random",
			noPartChance = 50,
	},
    ["TireFrontLeft"] = {
		partId = "TireFrontLeft",
		itemToModel = {
			["Base.fordCVPITire1"] = "fordCVPITire",
			["Base.91fordLTDTire1"] = "fordLTDTire",
		},
	},
	["TireFrontRight"] = {
		partId = "TireFrontRight",
		itemToModel = {
			["Base.fordCVPITire1"] = "fordCVPITire",
			["Base.91fordLTDTire1"] = "fordLTDTire",
		},
	},
	["TireRearLeft"] = {
		partId = "TireRearLeft",
		itemToModel = {
			["Base.fordCVPITire1"] = "fordCVPITire",
			["Base.91fordLTDTire1"] = "fordLTDTire",
		},
	},
	["TireRearRight"] = {
		partId = "TireRearRight",
		itemToModel = {
			["Base.fordCVPITire1"] = "fordCVPITire",
			["Base.91fordLTDTire1"] = "fordLTDTire",
		},
	},
});


function LTD91.ContainerAccess.Gunrack(vehicle, part, chr)
	if chr:getVehicle() == vehicle then
		local seat = vehicle:getSeat(chr)
		return seat == 1 or seat == 0;
	elseif chr:getVehicle() then
		return false
	else
		if not vehicle:isInArea(part:getArea(), chr) then return false end
		local doorPart = vehicle:getPartById("DoorFrontRight")
		if doorPart and doorPart:getDoor() and not doorPart:getDoor():isOpen() then
			return false
		end
		return true
	end
end

function LTD91.ContainerAccess.Roofrack(vehicle, part, chr)
	if chr:getVehicle() then return false end
	if not vehicle:isInArea(part:getArea(), chr) then return false end
	return true
end