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

public static class FacilityDataTable
{
	public static void Init()
	{
		FacilityDataTable.m_FacilityMaterialCategoryNameArray = new Dictionary<int, string>();
		FacilityDataTable.ReadCSV("facility_material_category.nei", delegate(CsvParser csv)
		{
			for (int i = 1; i < csv.max_cell_y; i++)
			{
				if (!csv.IsCellToExistData(0, i))
				{
					break;
				}
				int num = 0;
				int cellAsInteger = csv.GetCellAsInteger(num++, i);
				string cellAsString = csv.GetCellAsString(num++, i);
				FacilityDataTable.m_FacilityMaterialCategoryNameArray.Add(cellAsInteger, cellAsString);
			}
		});
		FacilityDataTable.m_FacilityParameterNameArray = new Dictionary<int, string>();
		FacilityDataTable.ReadCSV("facility_parameters.nei", delegate(CsvParser csv)
		{
			for (int i = 1; i < csv.max_cell_y; i++)
			{
				if (!csv.IsCellToExistData(0, i))
				{
					break;
				}
				int num = 0;
				int cellAsInteger = csv.GetCellAsInteger(num++, i);
				string cellAsString = csv.GetCellAsString(num++, i);
				FacilityDataTable.m_FacilityParameterNameArray.Add(cellAsInteger, cellAsString);
			}
		});
		FacilityDataTable.m_FacilityCostumeEnableMPN = new List<MPN>();
		FacilityDataTable.ReadCSV("facility_costume_mpn_enable_list.nei", delegate(CsvParser csv)
		{
			List<MPN> list = new List<MPN>();
			for (int i = 1; i < csv.max_cell_y; i++)
			{
				if (!csv.IsCellToExistData(0, i))
				{
					break;
				}
				string cellAsString = csv.GetCellAsString(0, i);
				MPN item = MPN.null_mpn;
				try
				{
					item = (MPN)Enum.Parse(typeof(MPN), cellAsString);
				}
				catch (Exception e)
				{
					NDebug.AssertParseError("MPN", e);
				}
				FacilityDataTable.m_FacilityCostumeEnableMPN.Add(item);
			}
		});
		FacilityDataTable.m_FacilityDefaultCostumeArray = new Dictionary<int, Dictionary<MPN, KeyValuePair<bool, string>>>();
		FacilityDataTable.m_FacilityDefaultCostumeThumbnailArray = new Dictionary<int, string>();
		FacilityDataTable.ReadCSV("facility_default_costume.nei", delegate(CsvParser csv)
		{
			int i = 1;
			int j = 4;
			while (i < csv.max_cell_x)
			{
				Dictionary<MPN, KeyValuePair<bool, string>> dictionary = new Dictionary<MPN, KeyValuePair<bool, string>>();
				int cellAsInteger = csv.GetCellAsInteger(i, 3);
				for (j = 4; j < csv.max_cell_y; j++)
				{
					if (!csv.IsCellToExistData(0, j))
					{
						break;
					}
					string cellAsString = csv.GetCellAsString(0, j);
					string text = csv.GetCellAsString(i, j);
					MPN mpn = MPN.null_mpn;
					try
					{
						mpn = (MPN)Enum.Parse(typeof(MPN), cellAsString);
					}
					catch (Exception ex)
					{
						FacilityDataTable.m_FacilityDefaultCostumeThumbnailArray.Add(cellAsInteger, text);
						break;
					}
					bool key = !string.IsNullOrEmpty(text);
					if (!string.IsNullOrEmpty(text) && text.ToLower() != "del")
					{
						text += ".menu";
					}
					else if (!CM3.dicDelItem.TryGetValue(mpn, out text))
					{
						Debug.LogWarningFormat("[FacilityDataTable]MPN[{0}]のDelPropの取得に失敗しました", new object[]
						{
							mpn
						});
					}
					dictionary.Add(mpn, new KeyValuePair<bool, string>(key, text));
				}
				FacilityDataTable.m_FacilityDefaultCostumeArray.Add(cellAsInteger, dictionary);
				i++;
			}
		});
		FacilityDataTable.m_FacilityBusinessTypeDataArray = new Dictionary<int, FacilityDataTable.BusinessTypeData>();
		FacilityDataTable.ReadCSVBusinessTypeData();
		FacilityDataTable.m_FacilityDefaultDataArray = new Dictionary<int, FacilityDataTable.FacilityDefaultData>();
		FacilityDataTable.m_FacilityRecipeDataArray = new Dictionary<int, FacilityDataTable.FacilityRecipeData>();
		FacilityDataTable.m_FacilityMaterialDataArray = new Dictionary<int, FacilityDataTable.FacilityMaterialData>();
		FacilityDataTable.ReadCSVFacilityDefaultData();
		FacilityDataTable.ReadCSVFacilityPowerUpData();
		FacilityDataTable.ReadCSVFacilityMaterialData();
	}

	private static CsvParser GetCSV(string name)
	{
		if (!GameUty.FileSystem.IsExistentFile(name))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]csv「{0}」が見つからない", name));
			return null;
		}
		AFileBase file = GameUty.FileSystem.FileOpen(name);
		CsvParser csvParser = new CsvParser();
		if (!csvParser.Open(file))
		{
			Debug.LogError(string.Format("[FacilityDataTable]csv「{0}」を開くのに失敗", name));
		}
		return csvParser;
	}

	private static void ReadCSV(string fileName, Action<CsvParser> callback)
	{
		using (AFileBase afileBase = GameUty.FileSystem.FileOpen(fileName))
		{
			using (CsvParser csvParser = new CsvParser())
			{
				bool condition = csvParser.Open(afileBase);
				NDebug.Assert(condition, fileName + "\nopen failed.");
				callback(csvParser);
			}
		}
	}

	private static void ReadCSVFacilityDefaultData()
	{
		CsvParser csv = FacilityDataTable.GetCSV("facility_power_up.nei");
		Dictionary<int, int[]> dictionary = new Dictionary<int, int[]>();
		for (int i = 1; i < csv.max_cell_y; i++)
		{
			int cell_x = 0;
			int cellAsInteger = csv.GetCellAsInteger(cell_x++, i);
			string text = string.Empty;
			int[] array = null;
			if (csv.IsCellToExistData(cell_x, i))
			{
				text = csv.GetCellAsString(cell_x++, i);
			}
			if (!string.IsNullOrEmpty(text))
			{
				string[] array2 = text.Split(new char[]
				{
					','
				});
				array = new int[array2.Length];
				for (int j = 0; j < array.Length; j++)
				{
					array[j] = int.Parse(array2[j]);
				}
			}
			dictionary.Add(cellAsInteger, array);
		}
		Dictionary<int, List<int>> dictionary2 = new Dictionary<int, List<int>>();
		CsvParser csv2 = FacilityDataTable.GetCSV("facility_level_table.nei");
		for (int k = 1; k < csv2.max_cell_y; k++)
		{
			int num = 0;
			if (!csv2.IsCellToExistData(0, k))
			{
				break;
			}
			int cellAsInteger2 = csv2.GetCellAsInteger(num++, k);
			num++;
			List<int> list = new List<int>();
			for (int l = 0; l < 5; l++)
			{
				if (csv2.IsCellToExistData(num, k))
				{
					list.Add(csv2.GetCellAsInteger(num, k));
				}
				else
				{
					list.Add(l * 100);
				}
				num++;
			}
			dictionary2.Add(cellAsInteger2, list);
		}
		HashSet<int> enableList = new HashSet<int>();
		string[] array3 = new string[]
		{
			"facility_enabled_list"
		};
		foreach (string fileName in array3)
		{
			CsvCommonIdManager.ReadEnabledIdList(GameUty.FileSystem, GameUty.PathList, fileName, ref enableList);
		}
		CsvParser csv3 = FacilityDataTable.GetCSV("facility.nei");
		for (int n = 1; n < csv3.max_cell_y; n++)
		{
			if (!csv3.IsCellToExistData(0, n))
			{
				break;
			}
			FacilityDataTable.FacilityDefaultData facilityDefaultData = new FacilityDataTable.FacilityDefaultData(csv3, dictionary, dictionary2, enableList, n);
			FacilityDataTable.m_FacilityDefaultDataArray.Add(facilityDefaultData.ID, facilityDefaultData);
		}
	}

	private static void ReadCSVFacilityPowerUpData()
	{
		CsvParser csv = FacilityDataTable.GetCSV("facility_power_up_list.nei");
		for (int i = 1; i < csv.max_cell_y; i++)
		{
			if (!csv.IsCellToExistData(0, i))
			{
				break;
			}
			FacilityDataTable.FacilityRecipeData facilityRecipeData = new FacilityDataTable.FacilityRecipeData(csv, i);
			FacilityDataTable.m_FacilityRecipeDataArray.Add(facilityRecipeData.ID, facilityRecipeData);
		}
	}

	private static void ReadCSVFacilityMaterialData()
	{
		CsvParser csv = FacilityDataTable.GetCSV("facility_material.nei");
		for (int i = 1; i < csv.max_cell_y; i++)
		{
			if (!csv.IsCellToExistData(0, i))
			{
				break;
			}
			FacilityDataTable.FacilityMaterialData facilityMaterialData = new FacilityDataTable.FacilityMaterialData(csv, i);
			FacilityDataTable.m_FacilityMaterialDataArray.Add(facilityMaterialData.ID, facilityMaterialData);
		}
	}

	private static void ReadCSVBusinessTypeData()
	{
		CsvParser csv = FacilityDataTable.GetCSV("facility_business_type.nei");
		for (int i = 1; i < csv.max_cell_y; i++)
		{
			if (!csv.IsCellToExistData(0, i))
			{
				break;
			}
			FacilityDataTable.BusinessTypeData businessTypeData = new FacilityDataTable.BusinessTypeData(csv, i);
			FacilityDataTable.m_FacilityBusinessTypeDataArray.Add(businessTypeData.ID, businessTypeData);
		}
	}

	public static FacilityDataTable.FacilityDefaultData GetFacilityDefaultData(int facilityTypeID, bool enableDataOnly = true)
	{
		if (FacilityDataTable.m_FacilityDefaultDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]施設の基本情報の配列が未初期化です");
			return null;
		}
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityTypeID))
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID[{0}]は存在しないデータです", facilityTypeID));
			return null;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID[{0}]は有効ではありません", facilityTypeID));
			return null;
		}
		return FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID];
	}

	public static int GetFacilityTypeID(string facilityName)
	{
		FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.GetFacilityDefaultData(facilityName, true);
		if (facilityDefaultData != null)
		{
			return facilityDefaultData.ID;
		}
		return -1;
	}

	public static FacilityDataTable.FacilityDefaultData GetFacilityDefaultData(string facilityDefaultName, bool enableDataOnly = true)
	{
		if (FacilityDataTable.m_FacilityDefaultDataArray == null)
		{
			NDebug.Assert("[FacilityDataTable]施設の基本情報の配列が未初期化です", false);
			return null;
		}
		foreach (KeyValuePair<int, FacilityDataTable.FacilityDefaultData> keyValuePair in FacilityDataTable.m_FacilityDefaultDataArray)
		{
			if (!(keyValuePair.Value.name != facilityDefaultName))
			{
				if (enableDataOnly && !keyValuePair.Value.isEnableData)
				{
					Debug.Log(string.Format("[FacilityDataTable]施設名[{0}]は有効ではありません", facilityDefaultName));
					return null;
				}
				return keyValuePair.Value;
			}
		}
		Debug.LogWarning(string.Format("施設名[{0}]は存在しないデータです", facilityDefaultName));
		return null;
	}

	public static Dictionary<int, ScheduleCSVData.Work> GetAllWorkData(bool enableDataOnly = true)
	{
		if (FacilityDataTable.m_FacilityDefaultDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]施設の基本情報の配列が未初期化です");
			return null;
		}
		Dictionary<int, ScheduleCSVData.Work> dictionary = new Dictionary<int, ScheduleCSVData.Work>();
		List<FacilityDataTable.FacilityDefaultData> list = new List<FacilityDataTable.FacilityDefaultData>(FacilityDataTable.m_FacilityDefaultDataArray.Values);
		for (int i = 0; i < list.Count; i++)
		{
			if (!enableDataOnly || list[i].isEnableData)
			{
				if (list[i].workData != null)
				{
					if (list[i].workData.id > 0)
					{
						if (dictionary.ContainsKey(list[i].workData.id))
						{
							NDebug.Assert("[営業施設と強化素材.xlsx]施設のスケジュールID" + list[i].workData.id + "が重複しています", false);
							return null;
						}
						dictionary.Add(list[i].workData.id, list[i].workData);
					}
				}
			}
		}
		return dictionary;
	}

	public static FacilityDataTable.FacilityRecipeData GetFacilityRecipeData(int recipeID)
	{
		if (FacilityDataTable.m_FacilityRecipeDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]施設強化レシピの基本情報の配列が未初期化です");
			return null;
		}
		if (!FacilityDataTable.m_FacilityRecipeDataArray.ContainsKey(recipeID))
		{
			Debug.LogFormat("[FacilityDataTable]施設強化レシピID[{0}]は存在しないデータです", new object[]
			{
				recipeID
			});
			return null;
		}
		return FacilityDataTable.m_FacilityRecipeDataArray[recipeID];
	}

	public static Facility.FacilityStatus GetFacilityStatus(int facilityTypeID, bool enableDataOnly = true)
	{
		if (FacilityDataTable.m_FacilityDefaultDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]施設の基本情報の配列が未初期化です");
			return null;
		}
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityTypeID))
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID[{0}]は存在しないデータです", facilityTypeID));
			return null;
		}
		FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID];
		if (enableDataOnly && !facilityDefaultData.isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID[{0}]は有効ではありません", facilityTypeID));
			return null;
		}
		return new Facility.FacilityStatus
		{
			name = facilityDefaultData.name,
			typeID = facilityDefaultData.ID,
			parameter = new Facility.FacilityParameter(facilityDefaultData.income, facilityDefaultData.valuation, facilityDefaultData.experienceValue)
		};
	}

	public static Facility.PowerUpRecipe GetFacilityPowerUpRecipe(int recipeID)
	{
		if (FacilityDataTable.m_FacilityRecipeDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]強化レシピ情報の配列が未初期化です");
			return null;
		}
		if (!FacilityDataTable.m_FacilityRecipeDataArray.ContainsKey(recipeID))
		{
			Debug.Log(string.Format("[FacilityDataTable]施設強化レシピID[{0}]は存在しないデータです", recipeID));
			return null;
		}
		FacilityDataTable.FacilityRecipeData facilityRecipeData = FacilityDataTable.m_FacilityRecipeDataArray[recipeID];
		return new Facility.PowerUpRecipe
		{
			id = facilityRecipeData.ID,
			materialCategoryIDArray = facilityRecipeData.materialIDArray,
			name = facilityRecipeData.name,
			parameter = new Facility.FacilityParameter(facilityRecipeData.income, facilityRecipeData.valuation, facilityRecipeData.experienceValue)
		};
	}

	public static Facility.PowerUpMaterial GetFacilityPowerUpMaterial(int materialID)
	{
		if (FacilityDataTable.m_FacilityMaterialDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]強化素材の情報の配列が未初期化です");
			return null;
		}
		if (!FacilityDataTable.m_FacilityMaterialDataArray.ContainsKey(materialID))
		{
			Debug.Log(string.Format("[FacilityDataTable]強化素材ID[{0}]は存在しないデータです", materialID));
			return null;
		}
		FacilityDataTable.FacilityMaterialData facilityMaterialData = FacilityDataTable.m_FacilityMaterialDataArray[materialID];
		return new Facility.PowerUpMaterial
		{
			id = facilityMaterialData.ID,
			categoryID = facilityMaterialData.categoryID,
			name = facilityMaterialData.name,
			parameter = new Facility.FacilityParameter(facilityMaterialData.income, facilityMaterialData.valuation, facilityMaterialData.experienceValue)
		};
	}

	public static Facility.PowerUpMaterial GetFacilityPowerUpMaterial(string materialName)
	{
		if (FacilityDataTable.m_FacilityMaterialDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]強化素材の情報の配列が未初期化です");
			return null;
		}
		foreach (KeyValuePair<int, FacilityDataTable.FacilityMaterialData> keyValuePair in FacilityDataTable.m_FacilityMaterialDataArray)
		{
			if (!(keyValuePair.Value.name != materialName))
			{
				return FacilityDataTable.GetFacilityPowerUpMaterial(keyValuePair.Value.ID);
			}
		}
		NDebug.Warning(string.Format("強化素材「{0}」の情報は存在しません", materialName));
		return null;
	}

	public static int GetFacilityPowerUpMaterialID(string materialName)
	{
		Facility.PowerUpMaterial facilityPowerUpMaterial = FacilityDataTable.GetFacilityPowerUpMaterial(materialName);
		if (facilityPowerUpMaterial != null)
		{
			return facilityPowerUpMaterial.id;
		}
		return -1;
	}

	public static Facility.FacilityStatus[] GetFacilityStatusArray(bool enableDataOnly = true)
	{
		if (FacilityDataTable.m_FacilityDefaultDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]施設の基本情報の配列が未初期化です");
			return null;
		}
		List<Facility.FacilityStatus> list = new List<Facility.FacilityStatus>();
		List<FacilityDataTable.FacilityDefaultData> list2 = new List<FacilityDataTable.FacilityDefaultData>(FacilityDataTable.m_FacilityDefaultDataArray.Values);
		for (int i = 0; i < list2.Count; i++)
		{
			if (!enableDataOnly || list2[i].isEnableData)
			{
				list.Add(FacilityDataTable.GetFacilityStatus(list2[i].ID, true));
			}
		}
		return list.ToArray();
	}

	public static int[] GetFacilityPowerUpMaterialIDArray()
	{
		if (FacilityDataTable.m_FacilityMaterialDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]施設の強化素材情報の配列が未初期化です");
			return null;
		}
		List<int> list = new List<int>(FacilityDataTable.m_FacilityMaterialDataArray.Keys);
		return list.ToArray();
	}

	public static Facility.PowerUpRecipe[] GetFacilityPowerUpRecipeArray()
	{
		if (FacilityDataTable.m_FacilityRecipeDataArray == null)
		{
			Debug.LogError("[FacilityDataTable]施設強化レシピ情報の配列が未初期化です");
			return null;
		}
		List<Facility.PowerUpRecipe> list = new List<Facility.PowerUpRecipe>();
		List<FacilityDataTable.FacilityRecipeData> list2 = new List<FacilityDataTable.FacilityRecipeData>(FacilityDataTable.m_FacilityRecipeDataArray.Values);
		for (int i = 0; i < list2.Count; i++)
		{
			list.Add(FacilityDataTable.GetFacilityPowerUpRecipe(list2[i].ID));
		}
		return list.ToArray();
	}

	public static bool IsExistFacilityData(int facilityTypeID, bool enableDataOnly = true)
	{
		return FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityTypeID) && (!enableDataOnly || FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID].isEnableData);
	}

	public static bool IsExistPowerUpMaterial(int materialID)
	{
		return FacilityDataTable.m_FacilityMaterialDataArray.ContainsKey(materialID);
	}

	public static Facility.PowerUpMaterial[] GetFacilityPowerUpMaterialArray(int materialCategoryID)
	{
		List<Facility.PowerUpMaterial> list = new List<Facility.PowerUpMaterial>();
		List<FacilityDataTable.FacilityMaterialData> list2 = new List<FacilityDataTable.FacilityMaterialData>(FacilityDataTable.m_FacilityMaterialDataArray.Values);
		for (int i = 0; i < list2.Count; i++)
		{
			if (list2[i].categoryID == materialCategoryID)
			{
				list.Add(FacilityDataTable.GetFacilityPowerUpMaterial(list2[i].ID));
			}
		}
		return list.ToArray();
	}

	public static int GetFacilityPowerUpMaterialCount()
	{
		return FacilityDataTable.m_FacilityMaterialDataArray.Count;
	}

	public static bool IsExistFacilityPowerUpRecipe(int facilityTypeID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityTypeID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは存在しない", facilityTypeID));
			return false;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityTypeID));
			return false;
		}
		FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID];
		return facilityDefaultData.powerUpRecipeIDArray != null;
	}

	public static int[] GetFacilityPowerUpRecipeIDArray(int facilityTypeID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityTypeID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは存在しない", facilityTypeID));
			return null;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityTypeID));
			return null;
		}
		return FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID].powerUpRecipeIDArray;
	}

	public static string GetFacilityPowerUpMaterialCategoryName(int categoryID)
	{
		if (!FacilityDataTable.m_FacilityMaterialCategoryNameArray.ContainsKey(categoryID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]素材カテゴリID「{0}」のデータは存在しない", categoryID));
			return null;
		}
		return FacilityDataTable.m_FacilityMaterialCategoryNameArray[categoryID];
	}

	public static int[] GetFacilityPowerUpMaterialCategoryIDArray()
	{
		List<int> list = new List<int>(FacilityDataTable.m_FacilityMaterialCategoryNameArray.Keys);
		return list.ToArray();
	}

	public static string GetFacilityParameterName(int parameterID)
	{
		if (!FacilityDataTable.m_FacilityParameterNameArray.ContainsKey(parameterID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設パラメータID「{0}」のデータは存在しない", parameterID));
			return null;
		}
		return FacilityDataTable.m_FacilityParameterNameArray[parameterID];
	}

	public static bool GetFacilityCanBeUsedBusiness(int facilityID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは存在しない", facilityID));
			return false;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityID));
			return false;
		}
		return FacilityDataTable.m_FacilityDefaultDataArray[facilityID].isBusiness;
	}

	public static bool GetFacilityCanBeDestroy(int facilityID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは存在しない", facilityID));
			return false;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityID));
			return false;
		}
		return FacilityDataTable.m_FacilityDefaultDataArray[facilityID].isRemoval;
	}

	public static bool GetFacilityDefaultPlacement(int facilityID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは存在しない", facilityID));
			return false;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityID));
			return false;
		}
		return FacilityDataTable.m_FacilityDefaultDataArray[facilityID].isDefaultPlace;
	}

	public static int GetFacilityDefaultCost(int facilityID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは存在しない", facilityID));
			return 0;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityID));
			return 0;
		}
		return FacilityDataTable.m_FacilityDefaultDataArray[facilityID].cost;
	}

	public static Sprite GetFacilityThumbnail(int facilityTypeID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultDataArray.ContainsKey(facilityTypeID))
		{
			Debug.LogWarning(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは存在しない", facilityTypeID));
			return null;
		}
		if (FacilityDataTable.m_FacilityThumbnailCacheDic == null)
		{
			FacilityDataTable.m_FacilityThumbnailCacheDic = new Dictionary<int, Sprite>();
		}
		Sprite sprite;
		if (FacilityDataTable.m_FacilityThumbnailCacheDic.TryGetValue(facilityTypeID, out sprite))
		{
			return sprite;
		}
		FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID];
		if (enableDataOnly && !facilityDefaultData.isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityTypeID));
			return null;
		}
		string text = facilityDefaultData.imageThumbnailName + ".tex";
		if (string.IsNullOrEmpty(text))
		{
			Debug.Log(string.Format("施設の種類ID[{0}]にはサムネイル画像情報がありません", facilityTypeID));
			return null;
		}
		if (!GameUty.FileSystem.IsExistentFile(text))
		{
			Debug.Log(string.Format("施設『{0}』のサムネイル画像「{1}」が見つかりませんでした", facilityDefaultData.name, text));
			return null;
		}
		Texture2D tex = ImportCM.CreateTexture(text);
		sprite = uGUIUtility.CreateSprite(tex);
		FacilityDataTable.m_FacilityThumbnailCacheDic.Add(facilityTypeID, sprite);
		return sprite;
	}

	public static Dictionary<MPN, KeyValuePair<bool, string>> GetFacilityDefaultCostume(int facilityTypeID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultCostumeArray.ContainsKey(facilityTypeID))
		{
			return null;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityTypeID));
			return null;
		}
		Dictionary<MPN, KeyValuePair<bool, string>> dictionary = FacilityDataTable.m_FacilityDefaultCostumeArray[facilityTypeID];
		MPN[] facilityCostumeEnableMPN = FacilityDataTable.GetFacilityCostumeEnableMPN();
		Dictionary<MPN, KeyValuePair<bool, string>> dictionary2 = new Dictionary<MPN, KeyValuePair<bool, string>>();
		foreach (MPN key in facilityCostumeEnableMPN)
		{
			if (dictionary.ContainsKey(key))
			{
				dictionary2.Add(key, dictionary[key]);
			}
		}
		return dictionary2;
	}

	public static string GetFacilityDefaultCostumeThumbnailName(int facilityTypeID, bool enableDataOnly = true)
	{
		if (!FacilityDataTable.m_FacilityDefaultCostumeThumbnailArray.ContainsKey(facilityTypeID))
		{
			return null;
		}
		if (enableDataOnly && !FacilityDataTable.m_FacilityDefaultDataArray[facilityTypeID].isEnableData)
		{
			Debug.Log(string.Format("[FacilityDataTable]施設の種類ID「{0}」のデータは有効ではありません", facilityTypeID));
			return null;
		}
		return FacilityDataTable.m_FacilityDefaultCostumeThumbnailArray[facilityTypeID];
	}

	public static MPN[] GetFacilityCostumeEnableMPN()
	{
		return FacilityDataTable.m_FacilityCostumeEnableMPN.ToArray();
	}

	public static bool IsEnableFacilityCostumeMPN(MPN mpn)
	{
		return FacilityDataTable.m_FacilityCostumeEnableMPN.Contains(mpn);
	}

	public static int[] GetFacilityBusinessTypeIDArray(bool isExclusionEmptyData = true)
	{
		List<int> list = null;
		if (isExclusionEmptyData)
		{
			list = new List<int>();
			foreach (KeyValuePair<int, FacilityDataTable.BusinessTypeData> keyValuePair in FacilityDataTable.m_FacilityBusinessTypeDataArray)
			{
				if (keyValuePair.Key != 9999)
				{
					list.Add(keyValuePair.Key);
				}
			}
		}
		else
		{
			list = new List<int>(FacilityDataTable.m_FacilityBusinessTypeDataArray.Keys);
		}
		return list.ToArray();
	}

	public static FacilityDataTable.BusinessTypeData[] GetFacilityBusinessTypeDataArray(bool isExclusionEmptyData = true)
	{
		List<FacilityDataTable.BusinessTypeData> list = null;
		if (isExclusionEmptyData)
		{
			list = new List<FacilityDataTable.BusinessTypeData>();
			foreach (KeyValuePair<int, FacilityDataTable.BusinessTypeData> keyValuePair in FacilityDataTable.m_FacilityBusinessTypeDataArray)
			{
				if (keyValuePair.Key != 9999)
				{
					list.Add(keyValuePair.Value);
				}
			}
		}
		else
		{
			list = new List<FacilityDataTable.BusinessTypeData>(FacilityDataTable.m_FacilityBusinessTypeDataArray.Values);
		}
		return list.ToArray();
	}

	public static FacilityDataTable.BusinessTypeData GetFacilityBusinessTypeData(int businessTypeID)
	{
		if (!FacilityDataTable.m_FacilityBusinessTypeDataArray.ContainsKey(businessTypeID))
		{
			Debug.LogWarningFormat("[FacilityDataTable]事業の種類ID「{0}」に対応する情報がありません", new object[]
			{
				businessTypeID
			});
			return null;
		}
		return FacilityDataTable.m_FacilityBusinessTypeDataArray[businessTypeID];
	}

	public static bool IsExistFacilityBusinessTypeData(int businessTypeID)
	{
		return FacilityDataTable.m_FacilityBusinessTypeDataArray.ContainsKey(businessTypeID);
	}

	public static FacilityDataTable.BusinessTypeData GetFacilityBusinessTypeData(string businessName)
	{
		foreach (KeyValuePair<int, FacilityDataTable.BusinessTypeData> keyValuePair in FacilityDataTable.m_FacilityBusinessTypeDataArray)
		{
			if (!(keyValuePair.Value.name != businessName))
			{
				return keyValuePair.Value;
			}
		}
		Debug.LogWarningFormat("[FacilityDataTable]事業の名前「{0}」に対応する情報がありません", new object[]
		{
			businessName
		});
		return null;
	}

	private static Dictionary<int, FacilityDataTable.FacilityDefaultData> m_FacilityDefaultDataArray;

	private static Dictionary<int, FacilityDataTable.FacilityRecipeData> m_FacilityRecipeDataArray;

	private static Dictionary<int, FacilityDataTable.FacilityMaterialData> m_FacilityMaterialDataArray;

	private static Dictionary<int, FacilityDataTable.BusinessTypeData> m_FacilityBusinessTypeDataArray;

	private static Dictionary<int, string> m_FacilityMaterialCategoryNameArray;

	private static Dictionary<int, string> m_FacilityParameterNameArray;

	private static Dictionary<int, Dictionary<MPN, KeyValuePair<bool, string>>> m_FacilityDefaultCostumeArray;

	private static Dictionary<int, string> m_FacilityDefaultCostumeThumbnailArray;

	private static List<MPN> m_FacilityCostumeEnableMPN;

	private static Dictionary<int, Sprite> m_FacilityThumbnailCacheDic = new Dictionary<int, Sprite>();

	public enum BusinessType
	{
		接待系 = 100,
		営業系 = 200,
		アイドル系 = 300,
		無し = 9999
	}

	public class FacilityDefaultData
	{
		public FacilityDefaultData(CsvParser csv, Dictionary<int, int[]> recipeIDArray, Dictionary<int, List<int>> levelTableList, HashSet<int> enableList, int y)
		{
			int num = 0;
			this.ID = csv.GetCellAsInteger(num++, y);
			int cellAsInteger = csv.GetCellAsInteger(num++, y);
			this.name = csv.GetCellAsString(num++, y);
			csv.GetCellAsString(num++, y);
			this.businessTypeName = csv.GetCellAsString(num++, y);
			this.businessTypeID = FacilityDataTable.GetFacilityBusinessTypeData(this.businessTypeName).ID;
			this.upwardFacilityID = csv.GetCellAsInteger(num++, y);
			this.fileName = csv.GetCellAsString(num++, y);
			this.fileNameNight = csv.GetCellAsString(num++, y);
			this.rank = csv.GetCellAsInteger(num++, y);
			string cellAsString = csv.GetCellAsString(num++, y);
			this.cost = csv.GetCellAsInteger(num++, y);
			this.income = csv.GetCellAsInteger(num++, y);
			this.valuation = csv.GetCellAsInteger(num++, y);
			this.experienceValue = csv.GetCellAsInteger(num++, y);
			this.isBusiness = (csv.GetCellAsString(num++, y) == "〇");
			this.isDefaultPlace = (csv.GetCellAsString(num++, y) == "〇");
			this.isRemoval = (csv.GetCellAsString(num++, y) == "〇");
			string cellAsString2 = csv.GetCellAsString(num++, y);
			this.imageThumbnailName = csv.GetCellAsString(num++, y);
			string cellAsString3 = csv.GetCellAsString(num++, y);
			this.minMaidCount = csv.GetCellAsInteger(num++, y);
			this.maxMaidCount = csv.GetCellAsInteger(num++, y);
			this.heroineMagnification = csv.GetCellAsInteger(num++, y);
			string cellAsString4 = csv.GetCellAsString(num++, y);
			this.isEnableData = enableList.Contains(this.ID);
			if (string.IsNullOrEmpty(cellAsString2))
			{
				this.isEnableNTR = true;
				this.isOnlyNTR = false;
			}
			else if (cellAsString2 == "×")
			{
				this.isEnableNTR = false;
				this.isOnlyNTR = false;
			}
			else if (cellAsString2 == "〇" || cellAsString2 == "○")
			{
				this.isEnableNTR = true;
				this.isOnlyNTR = true;
			}
			if (recipeIDArray.ContainsKey(this.ID))
			{
				this.powerUpRecipeIDArray = recipeIDArray[this.ID];
			}
			else
			{
				this.powerUpRecipeIDArray = null;
			}
			string[] array = cellAsString.Split(new char[]
			{
				','
			});
			this.staffRankArray = new int[4];
			for (int i = 0; i < this.staffRankArray.Length; i++)
			{
				try
				{
					int.TryParse(array[i], out this.staffRankArray[i]);
				}
				catch (Exception ex)
				{
					this.staffRankArray[i] = 0;
				}
			}
			if (levelTableList.ContainsKey(this.ID))
			{
				this.levelTable = levelTableList[this.ID];
			}
			else
			{
				this.levelTable = new List<int>();
				this.levelTable.Add(0);
				this.levelTable.Add(100);
				this.levelTable.Add(200);
				this.levelTable.Add(300);
				this.levelTable.Add(400);
			}
			try
			{
				this.businessType = (FacilityDataTable.BusinessType)Enum.Parse(typeof(FacilityDataTable.BusinessType), this.businessTypeName);
			}
			catch (Exception e)
			{
				NDebug.AssertParseError("BusinessType", e);
			}
			if (cellAsInteger < 0)
			{
				return;
			}
			this.workData = new ScheduleCSVData.Work();
			this.workData.type = ScheduleTaskCtrl.TaskType.Work;
			this.workData.id = cellAsInteger;
			this.workData.name = csv.GetCellAsString(num++, y);
			this.workData.icon = cellAsString3;
			string cellAsString5 = csv.GetCellAsString(num++, y);
			if (!string.IsNullOrEmpty(cellAsString5) && Enum.IsDefined(typeof(ScheduleCSVData.TrainingType), cellAsString5))
			{
				this.workData.trainingType = (ScheduleCSVData.TrainingType)Enum.Parse(typeof(ScheduleCSVData.TrainingType), cellAsString5, false);
			}
			this.workData.study_rate = csv.GetCellAsInteger(num++, y);
			this.workData.reception = csv.GetCellAsInteger(num++, y);
			this.workData.care = csv.GetCellAsInteger(num++, y);
			this.workData.lovely = csv.GetCellAsInteger(num++, y);
			this.workData.elegance = csv.GetCellAsInteger(num++, y);
			this.workData.charm = csv.GetCellAsInteger(num++, y);
			this.workData.teach_rate = csv.GetCellAsInteger(num++, y);
			this.workData.cooking = csv.GetCellAsInteger(num++, y);
			this.workData.vocal = csv.GetCellAsInteger(num++, y);
			this.workData.dance = csv.GetCellAsInteger(num++, y);
			this.workData.appealPoint = csv.GetCellAsInteger(num++, y);
			this.workData.exp = csv.GetCellAsInteger(num++, y);
			this.workData.income = csv.GetCellAsInteger(num++, y);
			this.workData.cmdExp = csv.GetCellAsInteger(num++, y);
			string cellAsString6 = csv.GetCellAsString(num++, y);
			this.workData.condContract = new List<Contract>();
			string[] array2 = cellAsString6.Split(new char[]
			{
				'|'
			}, StringSplitOptions.RemoveEmptyEntries);
			for (int j = 0; j < array2.Length; j++)
			{
				if (Enum.IsDefined(typeof(Contract), array2[j]))
				{
					this.workData.condContract.Add((Contract)Enum.Parse(typeof(Contract), array2[j], false));
				}
			}
			string cellAsString7 = csv.GetCellAsString(num++, y);
			this.workData.condMaidClass = new List<int>();
			string[] array3 = cellAsString7.Split(new char[]
			{
				'&'
			}, StringSplitOptions.RemoveEmptyEntries);
			for (int k = 0; k < array3.Length; k++)
			{
				int id = JobClass.GetData(array3[k]).id;
				this.workData.condMaidClass.Add(id);
			}
			this.workData.needEventItemIdList = new List<int>();
			if (csv.GetCellAsString(num, 0) == "必要状態")
			{
				this.workData.needMaidStatus = csv.GetCellAsString(num++, y);
				string cellAsString8 = csv.GetCellAsString(num++, y);
				if (!string.IsNullOrEmpty(cellAsString8))
				{
					string[] array4 = cellAsString8.Split(new char[]
					{
						'|'
					});
					foreach (string s in array4)
					{
						this.workData.needEventItemIdList.Add(int.Parse(s));
					}
				}
			}
			if (num < csv.max_cell_x)
			{
				string cellAsString9 = csv.GetCellAsString(num, y);
				if (cellAsString9 != null)
				{
					if (!(cellAsString9 == "表示"))
					{
						if (cellAsString9 == "非表示")
						{
							this.workData.disableIfRentalMaid = true;
						}
					}
					else
					{
						this.workData.visibleIfRentalMaid = true;
					}
				}
			}
			num++;
			this.workData.condPackage = new List<string>();
			if (this.workData.id > 0)
			{
				this.workData.categoryID = 52;
			}
			this.workData.facility = this;
		}

		public bool isExistUpwardFacility
		{
			get
			{
				return FacilityDataTable.IsExistFacilityData(this.upwardFacilityID, true);
			}
		}

		public FacilityDataTable.FacilityDefaultData upwardFacility
		{
			get
			{
				if (!this.isExistUpwardFacility)
				{
					return null;
				}
				return FacilityDataTable.GetFacilityDefaultData(this.upwardFacilityID, true);
			}
		}

		public readonly int ID;

		public readonly string name;

		public readonly string businessTypeName;

		public readonly int businessTypeID;

		public readonly FacilityDataTable.BusinessType businessType;

		public readonly string fileName;

		public readonly string fileNameNight;

		public readonly int cost;

		public readonly int income;

		public readonly int valuation;

		public readonly int experienceValue;

		public readonly bool isBusiness;

		public readonly bool isDefaultPlace;

		public readonly bool isRemoval;

		public readonly string imageThumbnailName;

		public readonly int[] powerUpRecipeIDArray;

		public readonly int minMaidCount;

		public readonly int maxMaidCount;

		public readonly int heroineMagnification;

		public readonly int rank;

		public readonly int[] staffRankArray;

		public readonly List<int> levelTable;

		public readonly ScheduleCSVData.Work workData;

		public readonly bool isEnableNTR;

		public readonly bool isOnlyNTR;

		public readonly bool isEnableData;

		private readonly int upwardFacilityID;
	}

	public class FacilityRecipeData
	{
		public FacilityRecipeData(CsvParser csv, int y)
		{
			int num = 0;
			this.ID = csv.GetCellAsInteger(num++, y);
			this.name = csv.GetCellAsString(num++, y);
			string cellAsString = csv.GetCellAsString(num++, y);
			this.conditions = new string[FacilityDataTable.FacilityRecipeData.CONDITIONS_NUM];
			for (int i = 0; i < FacilityDataTable.FacilityRecipeData.CONDITIONS_NUM; i++)
			{
				this.conditions[i] = csv.GetCellAsString(num++, y);
			}
			this.salonGrade = csv.GetCellAsInteger(num++, y);
			string cellAsString2 = csv.GetCellAsString(num++, y);
			if (!string.IsNullOrEmpty(cellAsString2))
			{
				string[] array = cellAsString2.Split(new char[]
				{
					','
				});
				ParametersPack.StatusType key = ParametersPack.NameToStatusType(array[0]);
				this.statusType = new KeyValuePair<ParametersPack.StatusType, int>(key, int.Parse(array[1]));
			}
			this.income = csv.GetCellAsInteger(num++, y);
			this.valuation = csv.GetCellAsInteger(num++, y);
			this.experienceValue = csv.GetCellAsInteger(num++, y);
			if (!string.IsNullOrEmpty(cellAsString))
			{
				string[] array2 = cellAsString.Split(new char[]
				{
					','
				});
				this.materialIDArray = new int[array2.Length];
				for (int j = 0; j < array2.Length; j++)
				{
					this.materialIDArray[j] = int.Parse(array2[j]);
				}
			}
			else
			{
				this.materialIDArray = null;
			}
		}

		public bool IsSatisfyTheConditions()
		{
			Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
			bool flag = true;
			flag &= (this.salonGrade <= GameMain.Instance.CharacterMgr.status.clubGrade);
			if (maid != null && this.statusType.Value > 0)
			{
				flag &= (this.statusType.Value <= FacilityDataTable.FacilityRecipeData.GetMaidStatusValue(maid, this.statusType.Key.ToString()));
			}
			else
			{
				Debug.LogWarning("メイド0番が見つかりません");
			}
			return flag;
		}

		private static int GetMaidStatusValue(Maid maid, string name)
		{
			switch (name)
			{
			case "接待":
				return maid.status.reception;
			case "お世話":
				return maid.status.care;
			case "可憐":
				return maid.status.lovely;
			case "気品":
				return maid.status.elegance;
			case "魅惑":
				return maid.status.charm;
			case "料理":
				return maid.status.cooking;
			case "ボーカル":
				return maid.status.vocal;
			case "ダンス":
				return maid.status.dance;
			case "アピールポイント":
				return maid.status.appealPoint;
			case "淫欲":
				return maid.status.inyoku;
			case "M性":
				return maid.status.mvalue;
			case "変態":
				return maid.status.hentai;
			case "奉仕":
				return maid.status.housi;
			case "指導":
				return maid.status.teachRate;
			case "経験人数":
				return maid.status.sexPlayNumberOfPeople;
			case "人気ランク":
				return maid.status.popularRank;
			case "評価":
				return maid.status.evaluation;
			}
			Debug.LogWarning("メイドパラメータ名" + name + "に対応する処理は未定義でした");
			return 9999;
		}

		public static readonly int CONDITIONS_NUM = 4;

		public readonly int ID;

		public readonly string name;

		public readonly int[] materialIDArray;

		public readonly int income;

		public readonly int valuation;

		public readonly int experienceValue;

		public readonly string[] conditions;

		public readonly int salonGrade;

		public readonly KeyValuePair<ParametersPack.StatusType, int> statusType;
	}

	public class FacilityMaterialData
	{
		public FacilityMaterialData(CsvParser csv, int y)
		{
			int num = 0;
			this.ID = csv.GetCellAsInteger(num++, y);
			this.name = csv.GetCellAsString(num++, y);
			this.categoryID = csv.GetCellAsInteger(num++, y);
			this.income = csv.GetCellAsInteger(num++, y);
			this.valuation = csv.GetCellAsInteger(num++, y);
			this.experienceValue = csv.GetCellAsInteger(num++, y);
		}

		public readonly int ID;

		public readonly string name;

		public readonly int categoryID;

		public readonly int income;

		public readonly int valuation;

		public readonly int experienceValue;
	}

	public class BusinessTypeData
	{
		public BusinessTypeData(CsvParser csv, int y)
		{
			int num = 0;
			this.ID = csv.GetCellAsInteger(num++, y);
			this.name = csv.GetCellAsString(num++, y);
			this.fileName = csv.GetCellAsString(num++, y);
			this.description = csv.GetCellAsString(num++, y);
			this.conditions = new string[FacilityDataTable.BusinessTypeData.CONDITIONS_NUM];
			for (int i = 0; i < FacilityDataTable.BusinessTypeData.CONDITIONS_NUM; i++)
			{
				this.conditions[i] = csv.GetCellAsString(num++, y);
			}
		}

		public static readonly int CONDITIONS_NUM = 2;

		public readonly int ID;

		public readonly string name;

		public readonly string fileName;

		public readonly string description;

		public readonly string[] conditions;
	}
}
