local monocle = require("#monocle")

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

function onBegin()
  disableMovement()
  disableRetry()
	if not getFlag("Ch0_cutscenePrologueFinished") then
  		disablePause()
		makeUnskippable()
	end

  player.ForceCameraUpdate = false
  setFlag("donk_NightTime", true)
  engine.Scene:NextColorGrade("Donker19/LackOfInsiration/bluenight")

  setFlag("maddy_Prologue_sleep", true)
  wait(2.5)
  setFlag("maddy_Prologue_sleep", false)

  setFlag("maddy_Prologue_BedRot", true)
  wait(2)
  setFlag("maddy_Prologue_BedRot", false)

  setFlag("maddy_Prologue_Sit", true)
  wait(1.5)
  setFlag("maddy_Prologue_Sit", false)

  setFlag("maddy_Prologue_Game", true)
  playSound("event:/Donk_MoreOrionsBelt/sfx_TextingSounds", player.Position)
  wait(3)
  setFlag("maddy_Prologue_Game", false)

  setFlag("donk_NightTime", false)

  setFlag("donk_DayTime", true)
  engine.Scene:NextColorGrade("none")

  setFlag("maddy_Prologue_layFloor", true)
  wait(2)
  setFlag("maddy_Prologue_layFloor", false)

  setFlag("maddy_Prologue_BedRot", true)
  wait(3)
  setFlag("maddy_Prologue_BedRot", false)

  setFlag("maddy_Prologue_sleep", true)
  wait(3)
  setFlag("maddy_Prologue_sleep", false)

  setFlag("donk_DayTime", False)

  engine.Scene:NextColorGrade("Donker19/LackOfInsiration/bluenight")
  setFlag("donk_NightTime", true)

  setFlag("maddy_Prologue_BedRot", true)
  wait(2)
  setFlag("maddy_Prologue_BedRot", false)

  setFlag("maddy_Prologue_Game", true)
  playSound("event:/Donk_MoreOrionsBelt/sfx_TextingSounds", player.Position)
  wait(3)
  setFlag("maddy_Prologue_Game", false)

  setFlag("maddy_Prologue_Sit", true)
  wait(1.5)
  setFlag("maddy_Prologue_Sit", false)

  setFlag("donk_NightTime", false)

  setFlag("donk_DayTime", true)
  engine.Scene:NextColorGrade("none")

  setFlag("maddy_Prologue_SitPhone", true)
  wait(3)
  engine.Scene:NextColorGrade("Donker19/LackOfInsiration/0_BlackFade")
  wait(1)

  setFlag("maddy_Prologue_SitPhone", false)
  setFlag("maddy_Prologue_PhoneAlert", true)
  engine.Scene:NextColorGrade("none") 

  wait(8)
  engine.Scene:NextColorGrade("Donker19/LackOfInsiration/0_BlackFade")
  wait(4)
  setFlag("donk_TeleportToLab", true)
  enableMovement()
end

function onEnd(room, wasSkipped)
  enableMovement()
  engine.Scene:NextColorGrade("none") 
  setFlag("donk_TeleportToLab", true)
  player.DummyAutoAnimate = true
  player.ForceCameraUpdate = true
  getLevel():ResetZoom()
  enableMovement()
end