local excam = require("#Celeste.Mod.ExCameraDynamics.Code.Module.ExCameraInterop")

function onBegin()
  makeUnskippable()
  disableMovement()
  setFlag("Ending_ShowChair",false)
  setFlag("doorClosed",true)
  local level = getLevel()
  setFlag("ending_bluescreen",true)
  wait()
  playSound("event:/CC/CC_Lobby/CC_error")
  setFlag("ending_blueScreenAppeared",true)
  coroutine.yield(excam.Level_ZoomBack(getLevel(), 0.1)) 
  player.DummyAutoAnimate = false
  setFlag("BLUESCREENOFDEATH", true)
  setFlag("ending_bluescreen",false)
  wait(4)
  setFlag("ending_blackscreen",true)
  setFlag("BLUESCREENOFDEATH", false)
  wait(0.05)
  teleportTo(115,160)
  player.Sprite:Play("PointsideEnding_start")
  coroutine.yield(excam.Level_ZoomToFocus(getLevel(), vector2 (121,154), 80, 0.1))
  wait(0.9)
  setFlag("ending_blackscreen",false)
  coroutine.yield(excam.Level_ZoomToFocus(getLevel(), vector2 (121,150), 3, 2.5))
  say("CC_Pointside_Ending_A_A")
  wait(0.05)
  player.Sprite:Play("PointsideEnding_keyboard")
  wait(0.125)
  say("CC_Pointside_Ending_A_B")
  wait(0.5)
  player.Sprite:Play("PointsideEnding_stretch")
  wait(1.25)
  say("CC_Pointside_Ending_A_C")
  coroutine.yield(excam.Level_ZoomBack(getLevel(), 4.5)) 
  wait(1)
  say("CC_Pointside_Ending_A_D")
  player.Sprite:Play("PointsideEnding_getUp")--Replace this with the getting up animation--
  wait(1.2)
  setFlag("Ending_ShowChair",true)
  wait(0.3)
  player.DummyAutoAnimate = true
  walkTo(184)
  player.DummyAutoAnimate = false
  setFlag("doorOpening",true)
  setFlag("doorClosed",false)
  player.Sprite:Play("Ending_OpenDoor")--Replace this with the door opening and closing animation--
  wait(0.5)
  player.Sprite:Play("Ending_Turn")
  wait(0.5)
  player.DummyAutoAnimate = true
  setFlag("y00teleport",true)
end