local luaCutscenesUtils = require("#Celeste.Mod.MaxHelpingHand.Module.LuaCutscenesUtils")
local luaCutscenesUtils2 = require("#ExtendedVariants.Module.LuaCutscenesUtils")
local cat = getEntity("DialogNPC", "Celeste.Mod.DoonvHelper.Entities.")

function onBegin()
	disableMovement()
	makeUnskippable()
	disableRetry()
	cat.CutsceneModeEnabled = true
	playSound("event:/CC/CC_KoseiDiamond/ui_pause")
	if getFlag("cryoGoldenRun") and not getFlag("PartyCenter") then
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquest_golden"))
	end
	if getFlag("PartyCenter") then
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquest_party"))
			endCutscene()
	else
		if (getFlag("catTalkedG")) then
			luaCutscenesUtils2.TriggerFloatVariant("RoomLighting", 0.95, false)
			setFlag("catTalkedE",true)
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestH"))
			setFlag("catTalkedA",true)
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		elseif not (getFlag("catTalkedA",true)) then -- first greeting
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestA"))
			setFlag("catTalkedA",true)
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		elseif (getFlag("sunkenplant00",true) and getFlag("sunkenplant01",true) and getFlag("sunkenplant02",true) and getFlag("sunkenplant03",true) and getFlag("sunkenplant04",true) and getFlag("sunkenplant05",true) and not getFlag("catTalkedG",true)) then
			-- if got all corals, gives you a life heart
			luaCutscenesUtils2.TriggerFloatVariant("RoomLighting", 0.95, false)
			setFlag("catTalkedE",true)
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestG"))
			setFlag("catTalkedG",true)
			playSound("event:/game/general/seed_complete_berry")
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		elseif (getFlag("catTalkedE",true)) then
			luaCutscenesUtils2.TriggerFloatVariant("RoomLighting", 0.95, false)
			setFlag("catTalkedE",true)
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestF"))
			setFlag("catTalkedF",true)
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		elseif (getFlag("catTalkedD",true) and (getFlag("sunkenplant00",true) or getFlag("sunkenplant01",true) or getFlag("sunkenplant02",true) or getFlag("sunkenplant03",true) or getFlag("sunkenplant04",true) or getFlag("sunkenplant05",true))) then
		-- if got one coral, gives blessing
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestE"))
			luaCutscenesUtils2.TriggerFloatVariant("RoomLighting", 0.95, false)
			setFlag("catTalkedE",true)
			playSound("event:/game/general/seed_complete_berry")
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		elseif (getFlag("catTalkedC",true)) then
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestD"))
			setFlag("catTalkedD",true)
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		elseif (getFlag("catTalkedB",true) and getFlag("CatHasBeenPet")) then
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestC"))
			setFlag("catTalkedC",true)
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		elseif getFlag("catTalkedA",true) then
			coroutine.yield(luaCutscenesUtils.SayWithDifferentFont("ANDYB", "CC_KoseiDiamond_catquestB"))
			setFlag("catTalkedB",true)
			enableMovement()
			enableRetry()
			cat.CutsceneModeEnabled = false
			endCutscene()
		end
	end
	enableMovement()
	enableRetry()
	cat.CutsceneModeEnabled = false
end