local N=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\118\101\114\109\111\114\101"))local C=N("\079\098\106\101\099\116\084\119\101\101\110\077\097\110\097\103\101\114")local F=game:GetService("\076\105\103\104\116\105\110\103")local h=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local d={}d.__index=d d.ClassName="\076\105\103\104\116\105\110\103\077\097\110\097\103\101\114"function d.new()local N=setmetatable({},d)N._objectTweenManager=C.new()return N end function d._getObject(C,N)if not N:sub(1,9)=="\076\105\103\104\116\105\110\103\046"then error("\066\097\100 \112\097\116\104")end local h=N:sub(10)if h==""then return F end local d=F for C in h:gmatch("\037\119\043")do local F=d:FindFirstChild(C)if not F then warn("\085\110\097\098\108\101 \116\111 \102\105\110\100 "..N)return nil end d=F end return d end function d.TweenProperties(C,N)assert(N)assert(N.Id)assert(N.Objects)assert(N.Priority)local F=N.Id..h:GenerateGUID()local d=N.Priority local K={}for N,h in pairs(N.Objects)do assert(type(N)=="\115\116\114\105\110\103")assert(type(h)=="\116\097\098\108\101","\078\111\116 \097 \116\097\098\108\101")local a=C:_getObject(N)if a then assert(not K[a])K[a]=true C._objectTweenManager:TweenProperties(d,F,a,h)end end return function()for N,h in pairs(K)do C._objectTweenManager:RemoveTween(F,N)end end end function d.Destroy(N)N._objectTweenManager:Destroy()setmetatable(N,nil)end return d.new()
--- General LightingManager which can tween items in lighting
-- @classmod LightingManager

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))

local ObjectTweenManager = require("ObjectTweenManager")
local Lighting = game:GetService("Lighting")
local HttpService = game:GetService("HttpService")

local LightingManager = {}
LightingManager.__index = LightingManager
LightingManager.ClassName = "LightingManager"

function LightingManager.new()
	local self = setmetatable({}, LightingManager)

	self._objectTweenManager = ObjectTweenManager.new()

	return self
end

--- Ain't sexy, but it'll do
function LightingManager:_getObject(path)
	if not path:sub(1, #("Lighting.")) == "Lighting." then
		error("Bad path")
	end

	local base_path = path:sub(#("Lighting.") + 1)
	if base_path == "" then
		return Lighting
	end

	local current = Lighting
	for word in base_path:gmatch("%w+") do
		local new_obj = current:FindFirstChild(word)
		if not new_obj then
			warn("Unable to find " .. path)
			return nil
		end
		current = new_obj
	end

	return current
end

--- Tweens properties based upon a table with the following information
-- @param propertyTable Set of properties to tween
--[[
	{
		Priority = 0;
		Id = "BASELINE";
		Objects = {
			["Lighting"] = {
				Brightness = `Number`;
				OutdoorAmbient = `Color3`;
				FogColor = `Color3`;
				FogStart = `Number;
				FogEnd = `Number;
			};
			["Lighting.ColorCorrection"] = {
				Saturation = `Number;
				Contrast = `Number;
			};
			["Lighting.SunRays"] = {
				Intensity = `Number;
			};
		};
--]]
function LightingManager:TweenProperties(propertyTable)
	assert(propertyTable)
	assert(propertyTable.Id)
	assert(propertyTable.Objects)
	assert(propertyTable.Priority)

	local key = propertyTable.Id .. HttpService:GenerateGUID()
	local priority = propertyTable.Priority

	local objects = {}
	for path, properties in pairs(propertyTable.Objects) do
		assert(type(path) == "string")
		assert(type(properties) == "table", "Not a table")

		local object = self:_getObject(path)
		if object then
			assert(not objects[object])
			objects[object] = true
			self._objectTweenManager:TweenProperties(priority, key, object, properties)
		end
	end

	return function()
		for object, _ in pairs(objects) do
			self._objectTweenManager:RemoveTween(key, object)
		end
	end
end

function LightingManager:Destroy()
	self._objectTweenManager:Destroy()
	setmetatable(self, nil)
end

return LightingManager.new()