using System.Linq;
using Godot;

public partial class Level2 : Node3D
{
  [Export]
  private Marker3D _spawnPoint;

  public override void _Ready()
  {
    var player = GetTree().Root.GetChildren().OfType<CharacterBody3D>().Single();
    player.Transform = _spawnPoint.Transform;
    var bgmPlayer = GetNode<BGMPlayer>("/root/BgmPlayer");
    GD.Print(bgmPlayer);
    bgmPlayer.SetBGMFromFilepath("res://Audio/BGM/SeasidePalace.mp3");
    bgmPlayer.PlayBGM();
  }

  public void OnCollisionWithLevelLoader(Node3D node)
  {
    GD.Print("Entered level loader");
    var sceneHandler = (SceneHandler)GetNode("/root/SceneHandler");
    sceneHandler.OnLoadScene("res://Scenes/Level.tscn");
  }
}
