-- FILE: 	mapEditorScriptingExtension_c.lua
-- PURPOSE:	Prevent the map editor feature set being limited by what MTA can load from a map file by adding a script file to maps
-- VERSION:	RemoveWorldObjects (v1) AutoLOD (v1) BreakableObjects (v1)

function requestLODsClient()
	triggerServerEvent("requestLODsClient", resourceRoot)
end
addEventHandler("onClientResourceStart", resourceRoot, requestLODsClient)

function setLODsClient(lodTbl)
	for model in pairs(lodTbl) do
		engineSetModelLODDistance(model, 300)
	end
end
addEvent("setLODsClient", true)
addEventHandler("setLODsClient", resourceRoot, setLODsClient)

function applyBreakableState()
	for k, obj in pairs(getElementsByType("object", resourceRoot)) do
		local breakable = getElementData(obj, "breakable")
		if breakable then
			setObjectBreakable(obj, breakable == "true")
		end
	end
end
addEventHandler("onClientResourceStart", resourceRoot, applyBreakableState)


removeWorldModel(1283, 100000, 0, 0, 0)

trafficLight = {	
	{2080.0969238281,-1757.9871826172,13.052373886108-0.5, 270},
	{2105.1103515625,-1746.5256347656,13.066941261292-0.5, 90},
	{2095.9497070312,-1762.7818603516,13.068688392639-0.5, 350},
	{2089.0095214844,-1743.1584472656,13.054549217224-0.5, 170},

	{1996.3833007812,-1739.9636230469,13.546875-1, 170},
	
	{2075.4582519531,-1740.4384765625,12.546875, 170},
	
	{1966.9439697266,-1762.9841308594,12.546875, 0},
	{1935.9752197266,-1740.9639892578,12.546875, 170},


	{1834.2712402344,-1746.7581787109,12.545937538147, 90},
	{1827.4929199219,-1763.7893066406,12.546875, 0},
	{1810.5816650391,-1737.8718261719,12.535672187805, 270},
	{1816.0114746094,-1720.8828125,12.546875, 170},


	{1699.171875,-1726.62109375,12.546875, 90},
	{1695.4620361328,-1742.9855957031,12.546875, 0},
	{1680.2788085938,-1738.1468505859,12.557538032532, 270},
	{1683.6462402344,-1721.6831054688,12.546875, 170},


	{1575.3874511719,-1743.3553466797,12.546875, 0},
	{1523.7955322266,-1719.6499023438,12.546875, 170},
	{1423.2971191406,-1722.0498046875,12.546875, 170},
	{1394.994140625,-1742.4431152344,12.546875, 0},
	{1322.5078125,-1726.2591552734,12.546875, 90},


	{1322.3225097656,-1566.1892089844,12.546875, 90},
	{1368.1687011719,-1389.6616210938,12.69873046875, 90},
	{1363.5135498047,-1420.5855712891,12.546875, 0},
	{1332.4111328125,-1411.8298339844,12.547068595886, 270},
	{1336.9774169922,-1382.0162353516,12.674090385437, 180},

	{1369.5415039062,-1234.8361816406,12.546875, 90},
	{1369.9064941406,-1135.2263183594,22.828125, 90},
	{1332.7613525391,-1155.0748291016,22.828125, 270},


	{1374.8546142578,-1053.455078125,25.836002349854, 0},
	{1379.1540527344,-1029.9576416016,25.578769683838, 90},
	{1347.6973876953,-1025.3885498047,25.688007354736, 180},
	{1341.2164306641,-1042.5120849609,25.967203140259, 270},


	{1382.8778076172,-957.84210205078,33.331729888916, 0},
	{1391.9877929688,-931.10815429688,33.438430786133, 90},
	{1361.1990966797,-922.16052246094,33.364608764648, 180},
	{1347.0510253906,-946.52178955078,33.947174072266, 270},


	{1267.5798339844,-945.31567382812,41.427757263184, 0},
	{1225.0874023438,-922.55834960938,41.893508911133, 180},
	{1168.6411132812,-960.71478271484,41.768177032471, 0},
	{1153.1915283203,-932.10168457031,42.203125, 180},
	{1092.1899414062,-967.17755126953,41.47306060791, 0},
	{1016.6983032227,-947.42419433594,41.130668640137, 180},
	{974.22137451172,-954.95007324219,39.355422973633, 270},
	{968.51812744141,-982.94268798828,37.965309143066, 0},
	{800.72479248047,-1063.2156982422,23.8671875, 0},
	{789.41693115234,-1033.0755615234,23.941844940186, 180},


	{150.23057556152,-1543.4307861328,9.2694683074951, 140},
	{165.93682861328,-1565.3385009766,11.284332275391, 45},
	{138.14874267578,-1583.4661865234,10.575651168823, 330},


	{464.35046386719,-1730.8974609375,9.5814065933228, 0},


	{1383.9846191406,-1862.7686767578,12.539073944092, 180},
	{1431.9770507812,-1881.5479736328,12.546875, 0},
	{1563.8974609375,-1862.2666015625,12.546875, 180},
	{1535.8787841797,-1882.0064697266,12.546875, 0},
	{1696.2608642578,-1824.88671875,12.542388916016, 0},
	{1698.6491699219,-1806.5418701172,12.546875, 90},


	{1812.6208496094,-1837.7690429688,12.578125, 270},
	{1811.9613037109,-1860.4259033203,12.570352554321, 270},
	{1922.9161376953,-1762.4508056641,12.47705078125, 0},
	{1955.7683105469,-2157.5637207031,12.546875, 180},
}

for k,v in pairs(trafficLight) do 
	lights = createObject(1352, v[1], v[2], v[3])
	setElementRotation(lights, 0, 0, v[4])
	setObjectBreakable(lights, false)
end