local STR = MG_CarDealer.TunerElement_CreateStruct("underneon")
STR.PrintName = "Neonlicht"
STR.Icon = "ruby"
STR.Max = 1

local Scale = STR:AddVars("Skala", "number")
Scale.Min = 50
Scale.Max = 100
Scale.StartValue = 75

STR:AddVars("Farbe", "color")

local local_ply, ply_pos, pos
local dist = MG_CarDealerConfig.TuneRenderDist * MG_CarDealerConfig.TuneRenderDist
function STR:CL_Think(tunesys, vars)
	local_ply = local_ply or LocalPlayer()
	ply_pos = local_ply:EyePos()
	pos = tunesys:GetPos()
	if tunesys:IsDormant() or pos:DistToSqr(ply_pos) > dist then return end
	local dlight = DynamicLight(tunesys:EntIndex())
	if dlight then
		dlight.Pos = pos
		local col = vars["Farbe"]
		dlight.r = col.r
		dlight.g = col.g
		dlight.b = col.b
		dlight.Brightness = 9
		local scale = vars["Skala"]
		dlight.Size = scale
		dlight.Decay = scale * 3
		dlight.DieTime = CurTime() + 0.3
		dlight.dir = Vector(0, 0, -1)
		dlight.outerangle = 1
		dlight.innerangle = 1
	end
end

TunerElement.Register(STR)