local vector2 = require("#microsoft.xna.framework.vector2")
local exCameraHelper = require("#Celeste.Mod.ExCameraDynamics.Code.Module.ExCameraInterop")

function onBegin()
    
    disableMovement()
    makeUnskippable ()

    setBloomStrength(0)

    --local level = getLevel()
    --coroutine.yield(level:ZoomSnap(vector2(160, 90), 2))
    local level = getLevel()
    coroutine.yield(exCameraHelper.Level_ZoomToFocus(level, vector2(656, 2060), 2, 0.01))

    player.Facing = getEnum("Celeste.Facings", "Right")
    setDarkness (1)
    local darkness = 1
    while (true) do
        wait(0.01)
        darkness = darkness - 0.1
        setDarkness (darkness)
        if darkness < 0.1 then
            break
        end
    end

    walkTo (676, walkBackwards==false, speedMultiplier==1, keepWalkingIntoWalls==false)
    player.Facing = getEnum("Celeste.Facings", "Left")
    wait(0.3)
    
    player.DummyAutoAnimate = false
    player.Sprite:Play("sleep")
    wait(2)


    local darkness = getDarkness ()
    while (true) do
        wait(0.01)
        darkness = darkness + 0.1
        setDarkness (darkness)
        if darkness > 0.9 then
            break
        end
    end
    wait(1)
    
    player.DummyAutoAnimate = true

    teleportTo(688, 2487, "morning_01")
    
    
    enableMovement()
    endCutscene ()

end