-- blame luacutscene's globals for this jank
_G.helpers = helpers
_G.player = player
_G.cutsceneEntity = cutsceneEntity
_G.cutsceneTrigger = cutsceneTrigger
_G.modMetaData = modMetaData
_G.arguments = arguments

local Calc = require("#Monocle.Calc")
local Coroutine = require("#Monocle.Coroutine")
local Ease = require("#Monocle.Ease")
local Engine = require("#Monocle.Engine")
local Tween = require("#Monocle.Tween")
local Celeste = require("#Celeste")
local CelesteMod = Celeste.Mod
local Audio = require("#Celeste.Audio")
local Buses = require("#Celeste.Buses")
local DynamicData = require("#MonoMod.Utils").DynamicData
local util = require("Assets/Cutscenes/RotationCollab/util")


local from

function onTalk()
  onEnter()
end

function onBegin()
  disableMovement()
  waitUntilOnGround()

  if arguments.flag then
    if getFlag(arguments.flag) then return end

    setFlag(arguments.flag, true)
  end

  from = util.get_camera()
  coroutine.yield(
    util.pan_to(getLevel().LevelOffset + vector2(arguments.x, arguments.y))
  )
  say("RotationCollab_Six_screen8_lua")
  wait(0.75)
  coroutine.yield(util.pan_to(from, 6))
  wait(0.25)
  say("RotationCollab_Six_screen8_lua")
  wait(0.1)
end

function onEnd(room, wasSkipped)
  enableMovement()
  util.routine(util.pan_to(from, 0.5))
end
