local result
local Audio = require("#Celeste.Audio")
local vector2 = require("#microsoft.xna.framework.vector2")
local lua_helper = celeste.Mod.LuaCutscenes.LuaHelper
local monocle = require("#Monocle")
local minput = require("#Monocle.MInput")
local coroutineEntity = monocle.Entity()
local targetY = 3080
local targetB = 2320
local ascendSpeed = 40

local function doFadeWipe(state)
	disableMovement()
    fadeWipe = celeste.FadeWipe(engine.Scene, state, nil) -- (state = "false" escurece ,"true" clareia)
    engine.Scene:Add(fadeWipe)
    fadeWipe.duration = 3.5
    fadeWipe.EndTimer = 3.5
	enableMovement()
end

local function antestp()
	player.ForceCameraUpdate = false
	wait(0.5)
	doFadeWipe(false)
  	wait(3.5)
end

local function depoistp()
	wait(0.5)
	doFadeWipe(true)
end

function onBegin()
	makeUnskippable()
	disableRetry()
	disableMovement()
	walkTo(3840)
    wait(1)
    --player.ForceCameraUpdate = true
    --player.Sprite:Play("fall", true, false)
	setPlayerState("StDummy")
	setFlag("abducao")
	wait(1)
	say("Angleversario_abducao_3")
	--alien = Audio.Loop("event:/game/04_cliffside/arrowblock_move", player.position)
	player.DummyGravity = false
	while player.Position.Y > targetY do
 		player:MoveV(-ascendSpeed * monocle.Engine.DeltaTime, nil, nil)
		coroutine.yield()
	end
	--Audio.Loop(alien, player.position, "arrow_stop", 1)
	setPlayerState("StNormal")
	disableMovement()
	antestp()
	--Audio.Stop(Audio.Play("event:/game/04_cliffside/arrowblock_move_child", player.position), false)
	--teleportTo(3393, 2320, "Intro-Retention")
	teleportTo(3393, 2512, "LV00-IntroRetention")
	depoistp()
end

function onEnd()
	depoistp()
end