using System;
using System.Collections.Generic;
using UnityEngine;
using wf;

public class PhotoMaidItemData
{
	private PhotoMaidItemData()
	{
	}

	public static void Create()
	{
		if (PhotoMaidItemData.item_data_data_ != null)
		{
			return;
		}
		PhotoMaidItemData.category_mpn_dic_.Clear();
		PhotoMaidItemData.category_mpn_dic_["右手"] = MPN.handitem;
		PhotoMaidItemData.category_mpn_dic_["左手"] = MPN.seieki_naka;
		PhotoMaidItemData.category_mpn_dic_["上半身"] = MPN.kousoku_upper;
		PhotoMaidItemData.category_mpn_dic_["下半身"] = MPN.kousoku_lower;
		PhotoMaidItemData.category_mpn_dic_["前穴"] = MPN.accvag;
		PhotoMaidItemData.category_mpn_dic_["後穴"] = MPN.accanl;
		PhotoMaidItemData.item_data_data_ = new List<PhotoMaidItemData>();
		HashSet<int> hashSet = new HashSet<int>();
		CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "phot_maid_item_enabled_list", ref hashSet);
		using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_maid_item_list.nei"))
		{
			using (CsvParser csvParser = new CsvParser())
			{
				bool condition = csvParser.Open(afileBase);
				NDebug.Assert(condition, "phot_maid_item_list.nei\nopen failed.");
				for (int i = 1; i < csvParser.max_cell_y; i++)
				{
					if (csvParser.IsCellToExistData(0, i) && hashSet.Contains(csvParser.GetCellAsInteger(0, i)))
					{
						int num = 0;
						PhotoMaidItemData photoMaidItemData = new PhotoMaidItemData();
						photoMaidItemData.id = (long)csvParser.GetCellAsInteger(num++, i);
						photoMaidItemData.category = csvParser.GetCellAsString(num++, i);
						photoMaidItemData.name = csvParser.GetCellAsString(num++, i);
						photoMaidItemData.call_name = csvParser.GetCellAsString(num++, i);
						if (!string.IsNullOrEmpty(photoMaidItemData.call_name))
						{
							PhotoMaidItemData photoMaidItemData2 = photoMaidItemData;
							photoMaidItemData2.call_name += ".menu";
						}
						photoMaidItemData.init_item = (0 <= photoMaidItemData.call_name.IndexOf("_del"));
						string cellAsString = csvParser.GetCellAsString(num++, i);
						if (string.IsNullOrEmpty(cellAsString) || PluginData.IsEnabled(cellAsString))
						{
							PhotoMaidItemData.item_data_data_.Add(photoMaidItemData);
						}
					}
				}
			}
		}
		PhotoMaidItemData.category_list_ = new Dictionary<string, List<PhotoMaidItemData>>();
		PhotoMaidItemData.popup_menu_list_ = new List<KeyValuePair<string, UnityEngine.Object>>();
		HashSet<string> hashSet2 = new HashSet<string>();
		List<PhotoMaidItemData> data = PhotoMaidItemData.data;
		for (int j = 0; j < data.Count; j++)
		{
			if (!PhotoMaidItemData.category_list_.ContainsKey(data[j].category))
			{
				PhotoMaidItemData.category_list_.Add(data[j].category, new List<PhotoMaidItemData>());
			}
			PhotoMaidItemData.category_list_[data[j].category].Add(data[j]);
			if (!hashSet2.Contains(data[j].category))
			{
				PhotoMaidItemData.popup_menu_list_.Add(new KeyValuePair<string, UnityEngine.Object>(data[j].category, null));
				hashSet2.Add(data[j].category);
			}
		}
	}

	public static List<PhotoMaidItemData> data
	{
		get
		{
			return PhotoMaidItemData.item_data_data_;
		}
	}

	public static Dictionary<string, List<PhotoMaidItemData>> category_list
	{
		get
		{
			return PhotoMaidItemData.category_list_;
		}
	}

	public static List<KeyValuePair<string, UnityEngine.Object>> popup_category_list
	{
		get
		{
			return PhotoMaidItemData.popup_menu_list_;
		}
	}

	public static PhotoMaidItemData Get(long id)
	{
		for (int i = 0; i < PhotoMaidItemData.item_data_data_.Count; i++)
		{
			if (PhotoMaidItemData.item_data_data_[i].id == id)
			{
				return PhotoMaidItemData.item_data_data_[i];
			}
		}
		return null;
	}

	public static void Clear(Maid maid)
	{
		for (int i = 0; i < PhotoMaidItemData.item_data_data_.Count; i++)
		{
			if (PhotoMaidItemData.item_data_data_[i].init_item)
			{
				maid.SetProp(PhotoMaidItemData.category_mpn_dic_[PhotoMaidItemData.item_data_data_[i].category], PhotoMaidItemData.item_data_data_[i].call_name, 0, true, false);
			}
		}
	}

	public void Apply(Maid maid)
	{
		maid.SetProp(PhotoMaidItemData.category_mpn_dic_[this.category], this.call_name, 0, true, false);
		maid.AllProcProp();
	}

	public long id;

	public string category;

	public string name;

	public string call_name;

	public bool init_item;

	private static Dictionary<string, MPN> category_mpn_dic_ = new Dictionary<string, MPN>();

	private static List<PhotoMaidItemData> item_data_data_;

	private static Dictionary<string, List<PhotoMaidItemData>> category_list_;

	private static List<KeyValuePair<string, UnityEngine.Object>> popup_menu_list_;
}
