require "DAMN_Parts";
require "DAMN_Spawns";

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

DAMN.Parts:processConfigV2("GNX87", {
	["BumperFront"] = {
		partId = "GNX87BumperFront",
		itemToModel = {
			["Base.87buickRegalBumperFront"] = "BumperFront0",
			["Base.87buickRegalBumperFrontA"] = "BumperFrontA",
			["Base.87buickRegalBullbar"] = "BullbarFrontA",
		},
		default = "first",
	},
	["BumperRear"] = {
		partId = "GNX87BumperRear",
		itemToModel = {
			["Base.87buickRegalBumperRear"] = "BumperRear0",
		},
		default = "first",
	},
	["WindshieldArmor"] = {
		partId = "GNX87WindshieldArmor",
		itemToModel = {
			["Base.87buickRegalWindshieldArmor"] = "GNX87winda0",
		},
	},
	["WindshieldRearArmor"] = {
		partId = "GNX87WindshieldRearArmor",
		itemToModel = {
			["Base.87buickRegalWindshieldRearArmor"] = "GNX87windra",
		},
	},
	["FrontLeftArmor"] = {
		partId = "GNX87FrontLeftArmor",
		itemToModel = {
			["Base.87buickRegalFrontWindowArmor"] = "GNX87leftdoora",
		},
	},
	["FrontRightArmor"] = {
		partId = "GNX87FrontRightArmor",
		itemToModel = {
			["Base.87buickRegalFrontWindowArmor"] = "GNX87rightdoora",
		},
	},
	["RearLeftArmor"] = {
		partId = "GNX87RearLeftArmor",
		itemToModel = {
			["Base.87buickRegalRearWindowArmor"] = "GNX87leftdoorra",
		},
	},
	["RearRightArmor"] = {
		partId = "GNX87RearRightArmor",
		itemToModel = {
			["Base.87buickRegalRearWindowArmor"] = "GNX87rightdoorra",
		},
	},
	["SpareTire"] = {
		partId = "GNX87SpareTire",
		itemToModel = {
			["Base.87buickRegalTire1"] = "GNX87Spare1",
			["Base.87buickRegalGNXTire3"] = "GNX87Spare2",
		},
		default = "trve_random",
		noPartChance = 33,
	},
	["Roofrack"] = {
		partId = "GNX87Roofrack",
		itemToModel = {
			["Base.87buickRegalRoofrack3"] = "GNX87Roofrack0",
		},
		default = "trve_random",
		noPartChance = 95,
	},
	["Spoiler"] = {
		partId = "GNX87Spoiler",
		itemToModel = {
			["Base.87buickRegalGNXSpoiler3"] = "GNX87Spoiler0",
		},
		default = "first",
	},
	["SpoilerO"] = {
		partId = "GNX87Spoiler",
		itemToModel = {
			["Base.87buickRegalGNXSpoiler3"] = "GNX87Spoiler0",
		},
	},
	["FrontLip"] = {
		partId = "GNX87FrontLip",
		itemToModel = {
			["Base.87buickRegalFrontLip3"] = "GNX87Lip0",
			["Base.87buickRegalFrontSplitLip3"] = "GNX87Lip1",
		},
		default = "trve_random",
		noPartChance = 33,
	},
	["TireFrontLeft"] = {
		partId = "TireFrontLeft",
		itemToModel = {
			["Base.87buickRegalTire1"] = "GNX87Tire",
			["Base.87buickRegalGNXTire3"] = "GNX87TireS",
		},
	},
	["TireFrontRight"] = {
		partId = "TireFrontRight",
		itemToModel = {
			["Base.87buickRegalTire1"] = "GNX87Tire",
			["Base.87buickRegalGNXTire3"] = "GNX87TireS",
		},
	},
	["TireRearLeft"] = {
		partId = "TireRearLeft",
		itemToModel = {
			["Base.87buickRegalTire1"] = "GNX87Tire",
			["Base.87buickRegalGNXTire3"] = "GNX87TireS",
		},
	},
	["TireRearRight"] = {
		partId = "TireRearRight",
		itemToModel = {
			["Base.87buickRegalTire1"] = "GNX87Tire",
			["Base.87buickRegalGNXTire3"] = "GNX87TireS",
		},
	},
});


function GNX87.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

function GNX87.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