local monocle = require("#monocle")
local coroutineEntity = monocle.Entity()
local celeste = require("#celeste")

local oshiro
local tabletele
local tableteleB

function onBegin()
		local level = getLevel()
                level:add(coroutineEntity)

        oshiro = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("oshiro")
        tabletele = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("tabletele")
        tableteleB = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("tableteleB")
        disableRetry()
	disableMovement()
        walk(-60)
        getLevel():add(coroutineEntity)
        wait(0.5)
	helpers.say("CHAMBRE_INTRO")	
        level.Displacement:AddBurst(oshiro.Position, 0.5, 8, 32, 0.5)
        oshiro.Position = vector2(oshiro.X, oshiro.Y -500)
        playSound("event:/char/badeline/disappear")
        helpers.say("CHAMBRE_B")
        walk(-60)
        run(5)
        player.DummyAutoAnimate = false
		player.Sprite:Play("lookUp")
        helpers.say("CHAMBRE_C")
	player.DummyAutoAnimate = true
        run(-5)
        helpers.say("CHAMBRE_D")
        run(-85,false,1,false)
        walk(5)
        coroutine.yield(getLevel():ZoomTo(vector2(160, 100), 1.7, 0.75))
        wait(0.2)
        tableteleB.Position = vector2(tabletele.Position.X, tabletele.Position.Y)
        tabletele.Position = vector2(tabletele.X, tabletele.Y -500)
        playSound("event:/new_content/game/10_farewell/endscene_attachment_click")
        helpers.say("CHAMBRE_E")
        playSound("event:/new_content/game/10_farewell/ppt_mouseclick")
        setFlag("noir", true)
        teleportTo (0,0,"THERESORTSHOW")

  enableMovement()
	
end

function onEnd(room, wasSkipped)
    if wasSkipped then
        setFlag("noir", true)
	  teleportTo (0,0,"THERESORTSHOW")
 	 enableMovement()
   end
end


