local Y=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 w=game:GetService("\087\111\114\107\115\112\097\099\101")local T=Y("\065\099\099\101\108\084\119\101\101\110")local t=Y("\070\097\107\101\083\107\121\098\111\120\083\105\100\101")local M=Y("\077\097\105\100")local p=Y("\083\105\103\110\097\108")local f={}do local Y={Top="\085\112",Bottom="\068\110";Right="\076\102";Left="\082\116";Front="\070\116",Back="\066\107"}for Y,w in pairs(Y)do f[Enum.NormalId[Y]]="\083\107\121\098\111\120"..w end end local y={}y.__index=y y.ClassName="\070\097\107\101\083\107\121\098\111\120"y._partSize=1024 function y.new(Y)local f=setmetatable({},y)f._maid=M.new()f._parentFolder=Instance.new("\070\111\108\100\101\114")f._parentFolder.Name="\083\107\121\098\111\120"f._maid:GiveTask(f._parentFolder)f._sides={}for Y,w in pairs(Enum.NormalId:GetEnumItems())do f._sides[w]=t.new(f._partSize,w,f._parentFolder)end f._visible=false f.VisibleChanged=p.new()f._percentVisible=T.new(.25)f._percentVisible.t=0 f._percentVisible.p=0 if Y then f:SetSkybox(Y)end f._parentFolder.Parent=w.CurrentCamera return f end function y.SetPartSize(w,Y)w._partSize=Y or error("\078\111 \112\097\114\116\083\105\122\101")for Y,T in pairs(w._sides)do T:SetPartSize(w._partSize)end return w end function y.Show(w,Y)if w._visible then return end w._visible=true w._percentVisible.t=1 if Y then w._percentVisible.p=1 end w.VisibleChanged:Fire(w._visible,Y)end function y.Hide(w,Y)if not w._visible then return end w._visible=false w._percentVisible.t=0 if Y then w._percentVisible.p=0 end w.VisibleChanged:Fire(w._visible,Y)end function y.SetSkybox(w,Y)w._skybox=Y or error("\078\111 \115\107\121\098\111\120")for w,T in pairs(w._sides)do local t=f[w]T:SetImage(Y[t])end return w end function y.IsVisible(Y)return Y._visible end function y.UpdateRender(w,Y)local T=1-w._percentVisible.p for w,t in pairs(w._sides)do t:UpdateRender(Y)t:SetTransparency(T)end end function y.Destroy(Y)Y._maid:DoCleaning()Y._maid=nil end return y
--- Allow transitions between skyboxes
-- @classmod FakeSkybox

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

local Workspace = game:GetService("Workspace")

local AccelTween = require("AccelTween")
local FakeSkyboxSide = require("FakeSkyboxSide")
local Maid = require("Maid")
local Signal = require("Signal")

local SKYBOX_PROPERTY_IMAGE_MAP = {} do
	local properties = {
		Top = "Up";
		Bottom = "Dn";

		 -- Bind backwards
		Right = "Lf";
		Left = "Rt";

		Front = "Ft";
		Back = "Bk";
	}
	for Surface, Direction in pairs(properties) do
		SKYBOX_PROPERTY_IMAGE_MAP[Enum.NormalId[Surface]] = "Skybox" .. Direction
	end
end

local FakeSkybox = {}
FakeSkybox.__index = FakeSkybox
FakeSkybox.ClassName = "FakeSkybox"
FakeSkybox._partSize = 1024

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

	self._maid = Maid.new()

	self._parentFolder = Instance.new("Folder")
	self._parentFolder.Name = "Skybox"
	self._maid:GiveTask(self._parentFolder)

	self._sides = {}
	for _, NormalId in pairs(Enum.NormalId:GetEnumItems()) do
		self._sides[NormalId] = FakeSkyboxSide.new(self._partSize, NormalId, self._parentFolder)
		--self._maid[NormalId] = self._sides[NormalId]
	end

	self._visible = false
	self.VisibleChanged = Signal.new()

	self._percentVisible = AccelTween.new(0.25)
	self._percentVisible.t = 0
	self._percentVisible.p = 0

	if skybox then
		self:SetSkybox(skybox)
	end

	self._parentFolder.Parent = Workspace.CurrentCamera

	return self
end


function FakeSkybox:SetPartSize(partSize)
	self._partSize = partSize or error("No partSize")

	for _, side in pairs(self._sides) do
		side:SetPartSize(self._partSize)
	end

	return self
end

function FakeSkybox:Show(doNotAnimate)
	if self._visible then
		return
	end

	self._visible = true
	self._percentVisible.t = 1

	if doNotAnimate then
		self._percentVisible.p = 1
	end
	self.VisibleChanged:Fire(self._visible, doNotAnimate)
end

function FakeSkybox:Hide(doNotAnimate)
	if not self._visible then
		return
	end

	self._visible = false
	self._percentVisible.t = 0

	if doNotAnimate then
		self._percentVisible.p = 0
	end
	self.VisibleChanged:Fire(self._visible, doNotAnimate)
end

function FakeSkybox:SetSkybox(skybox)
	self._skybox = skybox or error("No skybox")

	for normal, side in pairs(self._sides) do
		local propertyName = SKYBOX_PROPERTY_IMAGE_MAP[normal]
		side:SetImage(skybox[propertyName])
	end

	return self
end

function FakeSkybox:IsVisible()
	return self._visible
end

function FakeSkybox:UpdateRender(baseCFrame)
	local transparency = 1-self._percentVisible.p

	for _, side in pairs(self._sides) do
		side:UpdateRender(baseCFrame)
		side:SetTransparency(transparency)
	end
end

function FakeSkybox:Destroy()
	self._maid:DoCleaning()
	self._maid = nil
end

return FakeSkybox