using Cryville.Crtr.Skin.Components;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace Cryville.Crtr {
	public static class BuiltinResources {
		public static Dictionary<string, Type> Components
			= new Dictionary<string, Type>();
		public static Dictionary<string, Shader> Shaders
			= new Dictionary<string, Shader>();
		public static Dictionary<string, Mesh> Meshes
			= new Dictionary<string, Mesh>();
		public static Dictionary<string, Material> Materials
			= new Dictionary<string, Material>();

		static bool loaded;

		public static void LoadDefault() {
			if (loaded) return;
			Components.Add("anim", typeof(SkinAnimation));
			Components.Add("image", typeof(SpritePlane));
			Components.Add("linesec", typeof(TrackLine));
			Components.Add("mesh", typeof(MeshBase));
			Components.Add("polysec", typeof(PolygonSGO));
			Components.Add("rect", typeof(SpriteRect));
			Components.Add("scale3", typeof(SpriteScale3));
			Components.Add("sec", typeof(SectionalGameObject));
			Components.Add("sprite", typeof(SpriteBase));
			Components.Add("text", typeof(SpriteText));

			Meshes.Add("quad", Resources.Load<Mesh>("Meshes/quad"));
			Meshes.Add("quad_scale3h", Resources.Load<Mesh>("Meshes/quad_scale3h"));

			Materials.Add("-SpriteMat", Resources.Load<Material>("Materials/SpriteMat"));

			Shaders.Add("default", Shader.Find("Sprites/Default"));
			Shaders.Add("additive", Shader.Find("Sprites/Additive"));

			loaded = true;
		}
	}
}
