local save = require("#Celeste.Mod.CrossoverCollab.Code.PointsStuff.PointsModule")

-- Returns if a flag exists, if it does, returns true, if it doesn't returns false
function isflagtrue(flag)
    return save.SaveData:IsFlagTrue(flag)
end

function onBegin()
	wait()
	-- Time of the day
	for i=0,23 do
		if i == os.date("*t").hour then
			setFlag("currentHour"..i,true)
		else
			setFlag("currentHour"..i,false)
		end
	end
	setFlag("isNight",true)
	setFlag("isDay",false)
	setDarkness(0.1)
	setBloomStrength(0.6)
	local theme = 1
	for i=1,4,1 do -- shopTheme
		if isflagtrue("furniture_wallpapers_theme"..tostring(theme)) then
			setFlag("shopTheme"..tostring(theme),true)
		else
			setFlag("shopTheme"..tostring(theme),false)
		end
		theme = theme + 1
	end
	theme = 1
	for i=1,3,1 do -- furniture_bed_theme
		if isflagtrue("furniture_bedsheets_theme"..tostring(theme)) then
			setFlag("furniture_bed_theme"..tostring(theme),true)
		else
			setFlag("furniture_bed_theme"..tostring(theme),false)
		end
		theme = theme + 1
	end
	theme = 1
	for i=1,3,1 do -- furniture_courtains_theme
		if isflagtrue("furniture_courtains_theme"..tostring(theme)) then
			setFlag("furniture_courtains_theme"..tostring(theme),true)
		else
			setFlag("furniture_courtains_theme"..tostring(theme),false)
		end
		theme = theme + 1
	end
	if isflagtrue("furniture_nail") then
		setFlag("furniture_nail",true)
	end
	if isflagtrue("furniture_mysteryegg") then
		setFlag("furniture_mysteryegg",true)
	end
	if isflagtrue("furniture_bulletkin") then
		setFlag("furniture_bulletkin",true)
	end
	if isflagtrue("furniture_slugcat") then
		setFlag("furniture_slugcat",true)
	end
	if isflagtrue("furniture_medamaude") then
		setFlag("furniture_medamaude",true)
	end
	if isflagtrue("furniture_manipulator") then
		setFlag("furniture_manipulator",true)
	end
	if isflagtrue("furniture_lute") then
		setFlag("furniture_lute",true)
	end
	setFlag("blackFade",false)
	if not getFlag("VoidRoom_IntroCutsceneSeen") then
		disableMovement()
		disableRetry()
		disablePause()
		getLevel().InCutscene = false
		player.DummyAutoAnimate = false
		player.Sprite:Play("lobbyAsleep")
		wait(2.4)
		enablePause()
		getLevel().InCutscene = true
		wait(0.2)
		say("CC_XELK_CUTS_AB_B")
	end
end

function onEnd()
	enableMovement()
	enableRetry()
	setFlag("VoidRoom_IntroCutsceneSeen",true)
end