require "DAMN_Parts";
require "DAMN_Spawns";

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

DAMN.Parts:processConfigV2("BAN65", {
	["BumperFront"] = {
		partId = "DAMNBumperFront",
		itemToModel = {
			["Base.65bansheeBumperFront0"] = "BumperFront0",
			["Base.65bansheeBumperFrontA"] = "BumperFrontA",
		},
		default = "first",
	},
	["BumperRear"] = {
		partId = "DAMNBumperRear",
		itemToModel = {
			["Base.65bansheeBumperRear0"] = "BumperRear0",
            ["Base.65bansheeBumperRearA"] = "BumperRearA",
		},
		default = "first",
	},
	["WindshieldArmor"] = {
		partId = "DAMNWindshieldArmor",
		itemToModel = {
			["Base.65bansheeWindshieldArmor"] = "winda0",
		},
	},
	["WindshieldRearArmor"] = {
		partId = "DAMNWindshieldRearArmor",
		itemToModel = {
			["Base.65bansheeWindshieldRearArmor"] = "windra",
		},
	},
	["FrontLeftArmor"] = {
		partId = "DAMNFrontLeftArmor",
		itemToModel = {
			["Base.65bansheeFrontWindowArmor"] = "leftdoora",
		},
	},
	["FrontRightArmor"] = {
		partId = "DAMNFrontRightArmor",
		itemToModel = {
			["Base.65bansheeFrontWindowArmor"] = "rightdoora",
		},
	},
	["TireFrontLeft"] = {
		partId = "TireFrontLeft",
		itemToModel = {
			["Base.75grandPrixR215Tire1"] = "Tire1",
			["Base.75grandPrixR217Tire3"] = "Tire2",
            ["Base.pontiacR115Tire1"] = "Tire3",
            ["Base.pontiacR117Tire3"] = "Tire4",
            ["Base.pontiac8L15Tire1"] = "Tire5",
            ["Base.pontiac8L17Tire3"] = "Tire6",
            ["damnCraft.SmallTire1"] = "Tire7",
		},
	},
	["TireFrontRight"] = {
		partId = "TireFrontRight",
		itemToModel = {
			["Base.75grandPrixR215Tire1"] = "Tire1",
			["Base.75grandPrixR217Tire3"] = "Tire2",
            ["Base.pontiacR115Tire1"] = "Tire3",
            ["Base.pontiacR117Tire3"] = "Tire4",
            ["Base.pontiac8L15Tire1"] = "Tire5",
            ["Base.pontiac8L17Tire3"] = "Tire6",
            ["damnCraft.SmallTire1"] = "Tire7",
		},
	},
	["TireRearLeft"] = {
		partId = "TireRearLeft",
		itemToModel = {
			["Base.75grandPrixR215Tire1"] = "Tire1",
			["Base.75grandPrixR217Tire3"] = "Tire2",
            ["Base.pontiacR115Tire1"] = "Tire3",
            ["Base.pontiacR117Tire3"] = "Tire4",
            ["Base.pontiac8L15Tire1"] = "Tire5",
            ["Base.pontiac8L17Tire3"] = "Tire6",
            ["damnCraft.SmallTire1"] = "Tire7",
		},
	},
	["TireRearRight"] = {
		partId = "TireRearRight",
		itemToModel = {
			["Base.75grandPrixR215Tire1"] = "Tire1",
			["Base.75grandPrixR217Tire3"] = "Tire2",
            ["Base.pontiacR115Tire1"] = "Tire3",
            ["Base.pontiacR117Tire3"] = "Tire4",
            ["Base.pontiac8L15Tire1"] = "Tire5",
            ["Base.pontiac8L17Tire3"] = "Tire6",
            ["damnCraft.SmallTire1"] = "Tire7",
		},
	},
    ["SpareTire"] = {
		partId = "DAMNSpareTireRoof",
		itemToModel = {
			["Base.75grandPrixR215Tire1"] = "Spare1",
			["Base.75grandPrixR217Tire3"] = "Spare2",
            ["Base.pontiacR115Tire1"] = "Spare3",
            ["Base.pontiacR117Tire3"] = "Spare4",
            ["Base.pontiac8L15Tire1"] = "Spare5",
            ["Base.pontiac8L17Tire3"] = "Spare6",
            ["damnCraft.SmallTire1"] = "Spare7",
		},
	},
    ["Roof"] = {
		partId = "BAN65Roof",
		itemToModel = {
			["Base.65bansheeMetalRoof3"] = "roof0",
			["Base.65bansheeVinylRoof3"] = "roof1",
		},
        default = "random",
	},
    ["RoofXP"] = {
		partId = "BAN65Roof",
		itemToModel = {
			["Base.65bansheeMetalRoof3"] = "roof0",
			["Base.65bansheeVinylRoof3"] = "roof1",
		},
        default = "first",
	},
});

function BAN65.PopupLights(player)
    local vehicle = player.getVehicle and player:getVehicle() or nil
    if vehicle and string.find(vehicle:getScriptName(), "65banshee") then

        local part = vehicle:getPartById("BAN65PopupLights")
        local opened = part:getDoor():isOpen()
        local active = vehicle:getHeadlightsOn()

        if active and opened then return
            elseif not active and opened then
                vehicle:playPartAnim(part, "Close")
                vehicle:playPartSound(part, player, "Close")
                part:getDoor():setOpen(false)
                vehicle:transmitPartDoor(part)
            elseif active and not opened then
                vehicle:playPartAnim(part, "Open")
                vehicle:playPartSound(part, player, "Open")
                part:getDoor():setOpen(true)
                vehicle:transmitPartDoor(part)
        end
    end
end

Events.OnPlayerUpdate.Add(BAN65.PopupLights);