package common.attributes;

public enum UsageSlot {
	HAND(0), HEAD(4, 0), BODY(3, 1), LEGS(2, 2), FEET(1, 3), INVENTORY(-1);
	
	private static final UsageSlot[] LOOKUP = new UsageSlot[UsageSlot.values().length];
	
	private final int index;
	private final int armor;
	
	static {
		for(UsageSlot slot : values()) {
			if(slot.index >= 0)
				LOOKUP[slot.index] = slot;
		}
	}
	
	private UsageSlot(int index, int armor) {
		this.index = index;
		this.armor = armor;
	}
	
	private UsageSlot(int index) {
		this(index, -1);
	}
	
	public int getIndex() {
		return this.index;
	}
	
	public int getArmorSlot() {
		return this.armor;
	}
	
	public static UsageSlot getByIndex(int index) {
		return index < 0 || index >= LOOKUP.length ? null : LOOKUP[index];
	}
}
