package common.init;

import java.util.List;
import java.util.Map;
import java.util.Set;

import common.collect.Lists;
import common.collect.Maps;
import common.collect.Sets;
import common.entity.npc.EntityArachnoid;
import common.entity.npc.EntityBloodElf;
import common.entity.npc.EntityChaosMarine;
import common.entity.npc.EntityCpu;
import common.entity.npc.EntityCultivator;
import common.entity.npc.EntityDarkMage;
import common.entity.npc.EntityDwarf;
import common.entity.npc.EntityElf;
import common.entity.npc.EntityFireDemon;
import common.entity.npc.EntityGargoyle;
import common.entity.npc.EntityGoblin;
import common.entity.npc.EntityHaunter;
import common.entity.npc.EntityHuman;
import common.entity.npc.EntityMage;
import common.entity.npc.EntityMagma;
import common.entity.npc.EntityMetalhead;
import common.entity.npc.EntityNPC;
import common.entity.npc.EntityOrc;
import common.entity.npc.EntityPrimarch;
import common.entity.npc.EntitySlime;
import common.entity.npc.EntitySpaceMarine;
import common.entity.npc.EntitySpirit;
import common.entity.npc.EntityTiefling;
import common.entity.npc.EntityUndead;
import common.entity.npc.EntityVampire;
import common.entity.npc.EntityWoodElf;
import common.entity.npc.EntityZombie;
import common.entity.npc.SpeciesInfo;

public abstract class SpeciesRegistry {
	public static enum ModelType {
		HUMANOID("humanoid", 0.6f, 1.8f, 64, 64, "Humanoid"), 
		ARACHNOID("arachnoid", 1.4f, 1.6f, 128, 64, "Arachnoidea"), 
		SLIME("slime", 1.0f, 1.0f, 64, 32, "Schleim"), 
		DWARF("dwarf", 0.58f, 1.56f, 64, 58, "Zwerg"),
		HALFLING("halfling", 0.62f, 1.40f, 64, 52, "Winzling"), 
		SPACE_MARINE("spacemarine", 1.3f, 3.1f, 128, 106, "Space Marine");
		
		public final float width;
		public final float height;
		public final int texWidth;
		public final int texHeight;
		
		private ModelType(String name, float width, float height, int texWidth, int texHeight, String display) {
			this.width = width;
			this.height = height;
			this.texWidth = texWidth;
			this.texHeight = texHeight;
		}		
	}
	
	public static final Map<String, ModelType> SKINS = Maps.newTreeMap();
	public static final Set<String> CAPES = Sets.newTreeSet();
	public static final Map<Class<? extends EntityNPC>, SpeciesInfo> CLASSES = Maps.newHashMap();
	public static final List<SpeciesInfo> SPECIMEN = Lists.<SpeciesInfo>newArrayList();
	
	private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, 
			int color1, int color2, Object ... names) {
		SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, ModelType.HUMANOID, color1, color2, names));
	}
	
	private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, ModelType renderer, 
			int color1, int color2) {
		SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, renderer, color1, color2, ""));
	}
	
	private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, int color1, 
			int color2) {
		SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, ModelType.HUMANOID, color1, color2, ""));
	}
	
	private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, String origin, 
			String name, int color1, int color2, Object ... names) {
		SPECIMEN.add(new SpeciesInfo(id, clazz, classEnum, true, origin, name, ModelType.HUMANOID, color1, color2, names));
	}
	
	private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, boolean prefix, 
			String origin, String name, ModelType renderer, int color1, int color2, Object ... names) {
		SPECIMEN.add(new SpeciesInfo(id, clazz, classEnum, prefix, origin, name, renderer, color1, color2, names));
	}
	
	static void register() {
		registerSpecies("Cpu", EntityCpu.class, null, "Test-NSC", 0x202020, 0x8000ff, "Sen", "Troll:trollface", "Hacker", "Herobrine");
		registerSpecies("Cultivator", EntityCultivator.class, "nienrath", "Kultivator", 0x000000, 0xff0000, "Wei Wuxian", 0x000000, 0xff0000,
			"Lan Wangji", 0xffffff, 0x80e0ff, "Jiang Cheng", 0x200000, 0xaf00ff, "Shen Qingqiu", 0xffffff, 0x80ff80, 
			"Luo Binghe", 0x600000, 0x000000);
		registerSpecies("Metalhead", EntityMetalhead.class, "thedric", "Metalhead", 0x606060, 0xf0f0f0, 
				":metalhead_1", ":metalhead_2", ":metalhead_3", 
				":metalhead_4", ":metalhead_5", ":metalhead_6", ":metalhead_7", ":metalhead_8", ":metalhead_9", ":metalhead_10",
				":metalhead_11", ":metalhead_12", ":metalhead_13", ":metalhead_14");
		registerSpecies("Elf", EntityElf.class, "gharoth", "Elbe", 0x054100, 0xd2d2d2, ":highelf", "Thranduil", 0x82888b, 0xeae7bd);
		registerSpecies("WoodElf", EntityWoodElf.class, "gharoth", "Waldelbe", 0x054100, 0x00bb00);
		registerSpecies("BloodElf", EntityBloodElf.class, "kyroth", "Blutelbe", 0x054100, 0x960000, "::bloodelf");
		registerSpecies("Human", EntityHuman.class, EntityHuman.ClassType.class, "terra", "NSC", 0x4f7d9a, 0x034c7a, 
				EntityHuman.ClassType.KNIGHT, 
				":knight_1", ":knight_2", ":knight_3", 
				":knight_4", ":knight_5", ":knight_6", ":knight_7", ":knight_8", EntityHuman.ClassType.PEASANT, 
				":peasant_1", ":peasant_2", ":peasant_3", 
				":peasant_4", ":peasant_5", ":peasant_6");
		registerSpecies("Spirit", EntitySpirit.class, "yrdinath", "Geist", 0xdfdfff, 0xbfbfff);
		registerSpecies("Haunter", EntityHaunter.class, "warp", "Verfolger", 0xffdfdf, 0xffbfbf);
		registerSpecies("FireDemon", EntityFireDemon.class, "ahrd", "Feuerdämon", 0xff0000, 0xff7f00);
		
		registerSpecies("DarkMage", EntityDarkMage.class, "kyroth", "Dunkler Magier", 0xf6b201, 0xfff87e);
		registerSpecies("Tiefling", EntityTiefling.class, "thedric", "Tiefling", 0xb01515, 0xb0736f);
		registerSpecies("Zombie", EntityZombie.class, "terra", "Zombie", 0x00afaf, 0x799c65, ":zombie_1", ":zombie_2", ":zombie_3", 
				":zombie_4", ":zombie_5", ":zombie_6");
		registerSpecies("Undead", EntityUndead.class, "terra", "Untoter", 0xc1c1c1, 0x494949, ":undead_1", ":undead_2", ":undead_3", 
				":undead_4");
		registerSpecies("Arachnoid", EntityArachnoid.class, "tbd", "Arachnoidea", ModelType.ARACHNOID, 0x342d27, 0xa80e0e);
		registerSpecies("Mage", EntityMage.class, "terra", "Magier", 0x340000, 0x51a03e, ":mage_1", ":mage_2", ":mage_3", 
				":mage_4", ":mage_5", ":mage_6");
		registerSpecies("Gargoyle", EntityGargoyle.class, "tbd", "Gargoyle", 0x401010, 0x534437);
		registerSpecies("Slime", EntitySlime.class, "tbd", "Schleim", ModelType.SLIME, 0x51a03e, 0x7ebf6e);
		registerSpecies("Magma", EntityMagma.class, "thedric", "Magmaschleim", ModelType.SLIME, 0x340000, 0xfcfc00);
		registerSpecies("Orc", EntityOrc.class, "tbd", "Ork", 0x00af00, 0x004000, ":orc_1", ":orc_2", ":orc_3", 
				":orc_4", ":orc_5", ":orc_6", ":orc_7", ":orc_8", ":orc_9", ":orc_10", ":orc_11", ":orc_12");
		registerSpecies("Vampire", EntityVampire.class, "transylvania", "Vampir", 0x7f0000, 0xff0000, ":vampire_1", ":vampire_2", ":vampire_3", 
				":vampire_4", ":vampire_5", ":vampire_6", ":vampire_7", ":vampire_8", "Alucard:alucard_1", "Alucard:alucard_2", 
				"Dracula:dracula_1", "Dracula:dracula_2", "Dracula:dracula_3", "Dracula:dracula_4", "Dracula:dracula_5", 
				"Dracula:dracula_6");
		registerSpecies("Dwarf", EntityDwarf.class, "tbd", "Zwerg", ModelType.DWARF, 0x523925, 0x975b2b);
		registerSpecies("Primarch", EntityPrimarch.class, EntityPrimarch.Founding.class, false, "terra", "Primarch", ModelType.HUMANOID, 
				0xaf0000, 0x400000, EntityPrimarch.Founding.PRIMARCHS);
		registerSpecies("SpaceMarine", EntitySpaceMarine.class, EntitySpaceMarine.Legion.class, true, "terra", "Space Marine", ModelType.SPACE_MARINE, 
				0x000000, 0xffffff, EntitySpaceMarine.Legion.MARINES);
		registerSpecies("ChaosMarine", EntityChaosMarine.class, EntityChaosMarine.Legion.class, true, "warp", "Chaos Marine", ModelType.SPACE_MARINE, 
				0x000000, 0xff0000, EntityChaosMarine.Legion.MARINES);
		registerSpecies("Goblin", EntityGoblin.class, "luna", "Goblin", ModelType.HALFLING, 0x50af50, 0x504050);
	}
}
