using System;
using System.Collections.Generic;
using Cute;
using UnityEngine;

namespace Wizard;

public static class ColorCode
{
	public const string MASTER_NAME = "color_code";

	private const char INFO_DELIMITER = ':';

	private static Dictionary<eColorCodeId, Color> _colorCodeDic = new Dictionary<eColorCodeId, Color>();

	public static void BuildData()
	{
		string[] array = (Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("color_code", ResourcesManager.AssetLoadPathType.MasterEtc, isfetch: true)) as TextAsset).text.Trim().Replace("\r", "").Split('\n');
		for (int i = 0; i < array.Length; i++)
		{
			string[] array2 = array[i].Split(':');
			if (Enum.TryParse<eColorCodeId>(array2[0], out var result))
			{
				ColorUtility.TryParseHtmlString(array2[1], out var color);
				_colorCodeDic[result] = color;
			}
		}
	}

	public static Color GetWithString(string id)
	{
		if (Enum.TryParse<eColorCodeId>(id, out var result))
		{
			return Get(result);
		}
		return Color.red;
	}

	public static Color Get(eColorCodeId id)
	{
		if (_colorCodeDic.TryGetValue(id, out var value))
		{
			return value;
		}
		return Color.red;
	}
}
