local Engine = require("#monocle.engine")
local Calc = require("#monocle.calc")
local Ease = require("#monocle.ease")
local minput = require("#Monocle.MInput")
local wasDashAssistOn = false
-- TY MICROLITH
function onBegin()
  
  disableRetry()
  disableMovement()
  -- movement/retry
  npc = getEntity("MoreCustomNPC", "Celeste.Mod.MaxHelpingHand.Entities.")
  local npc_from = npc.Position
  local npc_to = vector2(npc.Position.X - 0, npc.Position.Y - 120)
  
  local plat = getEntity("JumpThru")
  -- this get entity also gets the jungle helper invis jumpthrotgh
  local plat_from = plat.Position.Y
  local plat_to = plat.Position.Y - 120
  player.ForceCameraUpdate = true
  --event:/CommunalHelperEvents/game/strawberryJam/game/solar_elevator/elevate
  
  --playSound("event:/CommunalHelperEvents/game/strawberryJam/game/solar_elevator/elevate")
  
  local particlesA = getEntities("ParticleEmitter", "Celeste.Mod.FemtoHelper.")
  --get the badeline shp particles entity
  local particle
  for i, e in ipairs(particlesA) do
    if not particle or particle.Y < e.Y then
      particle = e
    end
  end
  
  local particlesB = getFirstEntity("ParticleEmitter", "Celeste.Mod.FemtoHelper.")
  
  
  
  local particleA_from = particle.Position
  --do this one once
  local particleA_to = vector2(particle.Position.X, particle.Position.Y - 120)
  
  local particleB_from = particlesB.Position
  --do this one once
  local particleB_to = vector2(particlesB.Position.X, particlesB.Position.Y - 120)
  
  
  
  
  
  
  
  num_seconds = 3
  --reveal ladder (real)
  for t = 0, num_seconds, Engine.DeltaTime do
    npc.Position = npc_from + (npc_to - npc_from) * Ease.Linear(t/num_seconds)
	--plat.Position = plat_from + (plat_to - plat_from) * Ease.Linear(t/num_seconds)
	
	particlesB.Position = particleB_from + (particleB_to - particleB_from) * Ease.Linear(t/num_seconds)
	
	particle.Position = particleA_from + (particleA_to - particleA_from) * Ease.Linear(t/num_seconds)
	
	plat:MoveV(-0.665)
    wait()
  end
  playSound("event:/CommunalHelperEvents/game/strawberryJam/game/solar_elevator/halt")
  endCutscene()
end

function onStay(player)
  --Engine.Scene:DirectionalShake({ x = 100, y = 100 }, 0.02)
end

--- Callback for when the cutscene ends.
-- Function, no yielding actions allowed.
-- That means no walking, waiting etc.
-- Only "clean up" actions.
-- @tparam #Celeste.Level room Current room.
-- @bool wasSkipped If the cutscene was skipped.
function onEnd(room, wasSkipped)
  enableMovement()
  enableRetry()
end
