local celeste = require("#Celeste")
local theo = getEntity("DialogNPC", "Celeste.Mod.DoonvHelper.Entities.")
local teleportBack = false
function onBegin()
	disableMovement()
	disableRetry()
	
	
	walkTo(theo.Position.X - 6 - 24)
	-- to rotate player to the right
	walk(6)
	
	
	
	local answer = choice("CC_EVIDENCE02_CELESTRIS_C03_THEO_CHOISE01", "CC_EVIDENCE02_CELESTRIS_C03_THEO_CHOISE02", "CC_EVIDENCE02_CELESTRIS_C03_THEO_CHOISE03", "CC_EVIDENCE02_CELESTRIS_C03_THEO_CHOISE05A")
	
	
	if answer == 1 then
		say("CC_EVIDENCE02_CELESTRIS_C03_THEO_DIALOGUE01")
	elseif answer == 2 then
		say("CC_EVIDENCE02_CELESTRIS_C03_THEO_DIALOGUE02")
	elseif answer == 3 then
		say("CC_EVIDENCE02_CELESTRIS_C03_THEO_DIALOGUE03")
	--elseif answer == 4 then
	--	say("CC_EVIDENCE02_CELESTRIS_C03_THEO_DIALOGUE04")
	elseif answer == 4 then
		if getFlag("CS_Celestris_C03_TheoBerry") then
			teleportBack = true
			say("CC_EVIDENCE02_CELESTRIS_C03_THEO_DIALOGUE05A")
			teleport(0, 0, "b-00", "wakeup");
		else
			say("CC_EVIDENCE02_CELESTRIS_C03_THEO_DIALOGUE05A_GETBERRYPLEASE")
		end
	end
end

function onEnd(room, wasSkipped)
	enableMovement()
	enableRetry()
	if (wasSkipped) then
		if (teleportBack) then
			teleport(0, 0, "b-00", "wakeup");
		end
	end
end