using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class ResourceLoader
{

	public static PackedScene LoadLayerPrefab()
	{
		return GD.Load<PackedScene>($"res://Prefabs/Layer.tscn");
	}

	public static PackedScene LoadRobotPrefab()
	{
		return GD.Load<PackedScene>($"res://Prefabs/Robot.tscn");
	}

	public static PackedScene LoadProgramNodePrefab()
	{
		return GD.Load<PackedScene>($"res://Prefabs/ProgramNode.tscn");
	}

	public static PackedScene LoadMoveNodePrefab()
	{
		return GD.Load<PackedScene>($"res://Prefabs/DSL/MoveNode.tscn");
	}

	public static PackedScene LoadHarvestNodePrefab()
	{
		return GD.Load<PackedScene>($"res://Prefabs/DSL/HarvestNode.tscn");
	}

	public static PackedScene LoadCraftNodePrefab()
	{
		return GD.Load<PackedScene>($"res://Prefabs/DSL/CraftNode.tscn");
	}
	
	public static Dictionary<string, MeshInstance3D> LoadTiles()
	{
		Dictionary<string, MeshInstance3D> tileMeshes = new Dictionary<string, MeshInstance3D>();
		PackedScene tileCollection = GD.Load<PackedScene>($"res://Assets/Objects/Tiles.glb");
		Node root = tileCollection.Instantiate();
		foreach (MeshInstance3D child in root.GetChildren())
		{
			tileMeshes.Add(child.Name.ToString().ToLower(), child);
		}

		return tileMeshes;
	}

	public static Dictionary<string, MeshInstance3D> LoadDecorations()
	{
		Dictionary<string, MeshInstance3D> decorationMeshes = new Dictionary<string, MeshInstance3D>();
		PackedScene decorationCollection = GD.Load<PackedScene>($"res://Assets/Objects/Decorations.glb");
		Node root = decorationCollection.Instantiate();
		foreach (MeshInstance3D child in root.GetChildren())
		{
			decorationMeshes.Add(child.Name.ToString().ToLower(), child);
		}

		return decorationMeshes;
	}
}
