using System; using System.Collections.Generic; using System.IO; using wf; namespace MaidStatus { public static class Personal { public static int Count { get { Personal.CreateData(); return Personal.commonIdManager.idMap.Count; } } public static bool Contains(string name) { return Personal.commonIdManager.nameMap.ContainsKey(name); } public static bool Contains(int id) { return Personal.commonIdManager.idMap.ContainsKey(id); } public static int uniqueNameToId(string name) { Personal.CreateData(); NDebug.Assert(Personal.commonIdManager.nameMap.ContainsKey(name), "性格\nユニーク名[" + name + "]をIDに変換できませんでした"); return Personal.commonIdManager.nameMap[name]; } public static string IdToUniqueName(int id) { Personal.CreateData(); NDebug.Assert(Personal.commonIdManager.idMap.ContainsKey(id), "性格\nID[" + id + "]をユニーク名に変換できませんでした"); return Personal.commonIdManager.idMap[id].Key; } public static Personal.Data GetData(int id) { Personal.CreateData(); NDebug.Assert(Personal.basicDatas.ContainsKey(id), "性格\nID[" + id + "]のデータは存在しません"); return Personal.basicDatas[id]; } public static Personal.Data GetData(string uniqueName) { return Personal.GetData(Personal.uniqueNameToId(uniqueName)); } public static bool IsEnabled(string uniqueName) { Personal.CreateData(); return Personal.commonIdManager.enabledIdList.Contains(Personal.uniqueNameToId(uniqueName)); } public static bool IsEnabled(int id) { Personal.CreateData(); return Personal.commonIdManager.enabledIdList.Contains(id); } public static List GetAllDatas(bool onlyEnabled) { Personal.CreateData(); List list = new List(); foreach (KeyValuePair> keyValuePair in Personal.commonIdManager.idMap) { if (!onlyEnabled || Personal.commonIdManager.enabledIdList.Contains(keyValuePair.Key)) { list.Add(Personal.basicDatas[keyValuePair.Key]); } } return list; } public static void CreateData() { if (Personal.commonIdManager != null) { return; } Personal.commonIdManager = new CsvCommonIdManager("maid_status_personal", "性格", CsvCommonIdManager.Type.IdAndUniqueName, null); Personal.basicDatas = new Dictionary(); string[] array = new string[] { "list", "feature_condition" }; KeyValuePair[] array2 = new KeyValuePair[array.Length]; for (int i = 0; i < array2.Length; i++) { string text = "maid_status_personal_" + array[i] + ".nei"; AFileBase afileBase = GameUty.FileSystem.FileOpen(text); CsvParser csvParser = new CsvParser(); bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, text + "\nopen failed."); array2[i] = new KeyValuePair(afileBase, csvParser); } HashSet additionalRelationEnabledIdList = new HashSet(); CsvCommonIdManager.ReadEnabledIdList(GameUty.FileSystem, GameUty.PathList, "maid_status_personal_additionalrelation_enabled_list", ref additionalRelationEnabledIdList); foreach (KeyValuePair> keyValuePair in Personal.commonIdManager.idMap) { Personal.basicDatas.Add(keyValuePair.Key, new Personal.Data(keyValuePair.Key, array2[0].Value, array2[1].Value, additionalRelationEnabledIdList)); } foreach (KeyValuePair keyValuePair2 in array2) { keyValuePair2.Value.Dispose(); keyValuePair2.Key.Dispose(); } } private const string csvTopCommonName = "maid_status_personal"; private const string typeNameForErrorLog = "性格"; public const string termRootText = "MaidStatus/性格タイプ/"; public const string additionalRelationEnabledCsvName = "maid_status_personal_additionalrelation_enabled_list"; private static CsvCommonIdManager commonIdManager; private static Dictionary basicDatas; public class Data { public Data(int id, CsvParser basicCsv, CsvParser featureConditionsCsv, HashSet additionalRelationEnabledIdList) { List list = new List(); for (int i = 0; i < basicCsv.max_cell_y; i++) { if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id) { this.id = id; int num = 1; this.uniqueName = basicCsv.GetCellAsString(num++, i); this.drawName = basicCsv.GetCellAsString(num++, i); this.replaceText = basicCsv.GetCellAsString(num++, i); this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg"); string cellAsString = basicCsv.GetCellAsString(num++, i); this.oldPersonal = (cellAsString == "〇"); cellAsString = basicCsv.GetCellAsString(num++, i); if (this.oldPersonal) { this.compatible = true; foreach (string text in cellAsString.Split(new char[] { ',' })) { if (!string.IsNullOrEmpty(text) && !PluginData.IsEnabled(text)) { this.compatible = false; break; } } } else { this.compatible = false; } cellAsString = basicCsv.GetCellAsString(num++, i); if (this.oldPersonal) { this.single = true; foreach (string text2 in cellAsString.Split(new char[] { ',' })) { if (!string.IsNullOrEmpty(text2) && !PluginData.IsEnabled(text2)) { this.single = false; break; } } } else { this.single = true; } string[] array3 = basicCsv.GetCellAsString(num++, i).Split(new char[] { '/' }); this.competitiveMotionFileVictory = new KeyValuePair(Path.ChangeExtension(array3[0], ".ks"), array3[1]); array3 = basicCsv.GetCellAsString(num++, i).Split(new char[] { '/' }); this.competitiveMotionFileDefeat = new KeyValuePair(Path.ChangeExtension(array3[0], ".ks"), array3[1]); this.enabledAdditionalRelation = additionalRelationEnabledIdList.Contains(id); if (this.uniqueName == "Muku" || this.uniqueName == "Majime" || this.uniqueName == "Rindere") { this.enabledAdditionalRelation = true; } break; } } this.acquisitionFeatureList = new List(); for (int l = 0; l < featureConditionsCsv.max_cell_y; l++) { if (featureConditionsCsv.IsCellToExistData(0, l) && featureConditionsCsv.GetCellAsString(0, l) == this.uniqueName) { int num2 = 0; while (featureConditionsCsv.IsCellToExistData(1, l + num2)) { this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, l + num2)); num2++; } break; } } } public string termName { get { return "MaidStatus/性格タイプ/" + this.uniqueName; } } public readonly int id; public readonly string uniqueName; public readonly string drawName; public readonly string replaceText; public readonly string bgmFileName; public readonly bool oldPersonal; public readonly bool compatible; public readonly bool single; public readonly bool enabledAdditionalRelation; public readonly KeyValuePair competitiveMotionFileVictory; public readonly KeyValuePair competitiveMotionFileDefeat; public readonly List acquisitionFeatureList; public class LearnFeature { public LearnFeature(CsvParser featureConditionsCsv, int lineY) { this.requestParameters = new ParametersPack(); int cell_x = 1; string cellAsString = featureConditionsCsv.GetCellAsString(cell_x++, lineY); this.feature = Feature.GetData(cellAsString); this.requestSeikeikens = true; string cellAsString2 = featureConditionsCsv.GetCellAsString(cell_x++, lineY); if (cellAsString2 == "両穴") { this.needSeikeiken = Seikeiken.Yes_Yes; } else if (cellAsString2 == "前穴") { this.needSeikeiken = Seikeiken.Yes_No; } else if (cellAsString2 == "後穴") { this.needSeikeiken = Seikeiken.No_Yes; } else { this.requestSeikeikens = false; } while (featureConditionsCsv.IsCellToExistData(cell_x, lineY)) { string cellAsString3 = featureConditionsCsv.GetCellAsString(cell_x++, lineY); int cellAsInteger = featureConditionsCsv.GetCellAsInteger(cell_x++, lineY); this.requestParameters.Add(ParametersPack.NameToStatusType(cellAsString3), cellAsInteger); } } public bool isLearnPossible(Status status) { return (!this.requestSeikeikens || this.needSeikeiken == status.seikeiken) && this.requestParameters.GreaterThanOrEqualToStatus(status); } public readonly Feature.Data feature; public readonly bool requestSeikeikens; public readonly Seikeiken needSeikeiken; public readonly ParametersPack requestParameters; } } } }