local Vector2 = require("#microsoft.xna.framework.vector2")

local lua_helper = celeste.Mod.LuaCutscenes.LuaHelper

local function makeCoroutine(func)
  return monocle.Coroutine(lua_helper.LuaCoroutineToIEnumerator(coroutine.create(func)))
end

local function sobehand1()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand1.Position = Vector2.Lerp(redhand1.Position, redhand1.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand2()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand2.Position = Vector2.Lerp(redhand2.Position, redhand2.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand3()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand3.Position = Vector2.Lerp(redhand3.Position, redhand3.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand4()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand4.Position = Vector2.Lerp(redhand4.Position, redhand4.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand5()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand5.Position = Vector2.Lerp(redhand5.Position, redhand5.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand6()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand6.Position = Vector2.Lerp(redhand6.Position, redhand6.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand7()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand7.Position = Vector2.Lerp(redhand7.Position, redhand7.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand8()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand8.Position = Vector2.Lerp(redhand8.Position, redhand8.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand9()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand9.Position = Vector2.Lerp(redhand9.Position, redhand9.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand10()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand10.Position = Vector2.Lerp(redhand10.Position, redhand10.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand11()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand11.Position = Vector2.Lerp(redhand11.Position, redhand11.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand12()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand12.Position = Vector2.Lerp(redhand12.Position, redhand12.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand13()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand13.Position = Vector2.Lerp(redhand13.Position, redhand13.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end

local function sobehand14()
  for i = 0, 5, monocle.Engine.DeltaTime do
    redhand14.Position = Vector2.Lerp(redhand14.Position, redhand14.Position + vector2(0, -1), monocle.Ease.Linear(0.75))
    wait()
  end
end


function onBegin()

  redhand1 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand1")
  redhand2 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand2")
  redhand3 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand3")
  redhand4 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand4")
  redhand5 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand5")
  redhand6 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand6")
  redhand7 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand7")
  redhand8 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand8")
  redhand9 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand9")
  redhand10 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand10")
  redhand11 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand11")
  redhand12 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand12")
  redhand13 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand13")
  redhand14 = celeste.Mod.MaxHelpingHand.Entities.MoreCustomNPC.GetNPC("redhand14")

  waitingCoroutine = makeCoroutine(sobehand1)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand2)
  cutsceneEntity:Add(waitingCoroutine)
  wait(3)


  waitingCoroutine = makeCoroutine(sobehand3)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand4)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand5)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand6)
  cutsceneEntity:Add(waitingCoroutine)
  wait(2)


  waitingCoroutine = makeCoroutine(sobehand7)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand8)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand9)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand10)
  cutsceneEntity:Add(waitingCoroutine)
  wait(2)


  waitingCoroutine = makeCoroutine(sobehand11)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand12)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand13)
  cutsceneEntity:Add(waitingCoroutine)
  wait(0.5)

  waitingCoroutine = makeCoroutine(sobehand14)
  cutsceneEntity:Add(waitingCoroutine)
  wait(12)

end