using System.Globalization;

namespace Decal.Filters;

public class ComponentType
{
	private static ComponentType[] sTypes = new ComponentType[7]
	{
		new ComponentType(0, "Scarab"),
		new ComponentType(1, "Herb"),
		new ComponentType(2, "Powder"),
		new ComponentType(3, "Potion"),
		new ComponentType(4, "Talisman"),
		new ComponentType(5, "Taper"),
		new ComponentType(6, "Pea")
	};

	private int mId;

	private string mName;

	public int Id => mId;

	public string Name => mName;

	public static ComponentType GetById(int id)
	{
		for (int i = 0; i < sTypes.Length; i++)
		{
			if (sTypes[i].Id == id)
			{
				return sTypes[i];
			}
		}
		return null;
	}

	public static ComponentType GetByName(string name)
	{
		for (int i = 0; i < sTypes.Length; i++)
		{
			if (string.Compare(sTypes[i].Name, name, ignoreCase: true, CultureInfo.InvariantCulture) == 0)
			{
				return sTypes[i];
			}
		}
		return null;
	}

	private ComponentType(int id, string Name)
	{
		mId = id;
		mName = Name;
	}

	public override string ToString()
	{
		return mName;
	}
}
