local celeste = require("#celeste")
local csharpVector2 = require("#microsoft.xna.framework.vector2")

function onBegin()
	waitUntilOnGround()
	playMusic("event:/none")
	disableMovement()
	wait(0.35)
	player.Facing = getEnum("Celeste.Facings", "Left")
	wait(0.15)
	playSound("event:/CCDeltarune/Ohhohoho")
	playMusic("event:/none")
	runTo(7656)
	wait(1)
	walk(32)
	wait(0.5)
	walk(-32)
	wait(1)
	player.Facing = getEnum("Celeste.Facings", "Right")
	wait(1.75)
	setFlag("Deltarune_CursorChase",false)
	player.Facing = getEnum("Celeste.Facings", "Left")
	wait(0.25)
	setFlag("Deltarune_TheQueenAppears",true)
	wait(0.5)
	setFlag("Deltarune_TrappedByQueen",true)
	player.ForceCameraUpdate = true
	wait(0.2)
	player.Facing = getEnum("Celeste.Facings", "Right")
	wait(1)
	playMusic("event:/CCDeltarune/queen")
	wait(0.25)
	say("CC_Pointside_Deltarune_QueenTrapped")
	wait(0.55)
	miniTextbox("CC_Pointside_Deltarune_QueenTrappedWaiting")
	wait(2)
	setFlag("Deltarune_CageFallsDown",true)
	wait(0.1)
	playSound("event:/CommunalHelperEvents/game/chainedFallingBlock/chain_tighten_block")
	wait(0.4)
	miniTextbox("CC_Pointside_Deltarune_QueenTrappedWaitingB")
	wait(2)
	player.DummyAutoAnimate = false
	player.Sprite:Play("lookUp")
	wait(3)
	player.DummyAutoAnimate = true
	wait(0.8)
	miniTextbox("CC_Pointside_Deltarune_QueenTrappedWaitingC")
	wait(1.5)
	miniTextbox("CC_Pointside_Deltarune_QueenTrappedWaitingD")
	wait(3.5)
	celeste.SpotlightWipe.FocusPoint = csharpVector2(232, 84)
	getRoom().Wipe = celeste.SpotlightWipe(getRoom(), false, nil)
	wait(1.75)
end

function onEnd(room, wasSkipped)
	enableMovement()
	playMusic("event:/CC/CC_Lobby/CC_Lobby2",0)
	teleportTo(7878,-3778,"e02 - Portal")
end