123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using System;
- using System.Collections.Generic;
- using wf;
- namespace MaidStatus
- {
- public static class Feature
- {
- public static int Count
- {
- get
- {
- Feature.CreateData();
- return Feature.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(string name)
- {
- return Feature.commonIdManager.nameMap.ContainsKey(name);
- }
- public static bool Contains(int id)
- {
- return Feature.commonIdManager.idMap.ContainsKey(id);
- }
- public static int uniqueNameToId(string name)
- {
- Feature.CreateData();
- NDebug.Assert(Feature.commonIdManager.nameMap.ContainsKey(name), "特徴\nユニーク名[" + name + "]をIDに変換できませんでした");
- return Feature.commonIdManager.nameMap[name];
- }
- public static string IdToUniqueName(int id)
- {
- Feature.CreateData();
- NDebug.Assert(Feature.commonIdManager.idMap.ContainsKey(id), "特徴\nID[" + id + "]をユニーク名に変換できませんでした");
- return Feature.commonIdManager.idMap[id].Key;
- }
- public static Feature.Data GetData(int id)
- {
- Feature.CreateData();
- NDebug.Assert(Feature.basicDatas.ContainsKey(id), "特徴\nID[" + id + "]のデータは存在しません");
- return Feature.basicDatas[id];
- }
- public static Feature.Data GetData(string uniqueName)
- {
- return Feature.GetData(Feature.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(string uniqueName)
- {
- Feature.CreateData();
- return Feature.commonIdManager.enabledIdList.Contains(Feature.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(int id)
- {
- Feature.CreateData();
- return Feature.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<Feature.Data> GetAllDatas(bool onlyEnabled)
- {
- Feature.CreateData();
- List<Feature.Data> list = new List<Feature.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Feature.commonIdManager.idMap)
- {
- if (!onlyEnabled || Feature.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(Feature.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (Feature.commonIdManager != null)
- {
- return;
- }
- Feature.commonIdManager = new CsvCommonIdManager("maid_status_feature", "特徴", CsvCommonIdManager.Type.IdAndUniqueName, null);
- Feature.basicDatas = new Dictionary<int, Feature.Data>();
- string[] array = new string[]
- {
- "list",
- "correction"
- };
- KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
- for (int i = 0; i < array2.Length; i++)
- {
- string text = "maid_status_feature_" + 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>(afileBase, csvParser);
- }
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Feature.commonIdManager.idMap)
- {
- Feature.basicDatas.Add(keyValuePair.Key, new Feature.Data(keyValuePair.Key, array2[0].Value, array2[1].Value));
- }
- foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
- {
- keyValuePair2.Value.Dispose();
- keyValuePair2.Key.Dispose();
- }
- }
- private const string csvTopCommonName = "maid_status_feature";
- private const string typeNameForErrorLog = "特徴";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, Feature.Data> basicDatas;
- public class Data
- {
- public Data(int id, CsvParser basicCsv, CsvParser bonusCorrectionCsv)
- {
- for (int i = 1; i < basicCsv.max_cell_y; i++)
- {
- if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
- {
- int num = 1;
- this.id = id;
- this.uniqueName = basicCsv.GetCellAsString(num++, i);
- this.drawName = basicCsv.GetCellAsString(num++, i);
- break;
- }
- }
- for (int j = 1; j < bonusCorrectionCsv.max_cell_y; j++)
- {
- if (bonusCorrectionCsv.IsCellToExistData(0, j) && bonusCorrectionCsv.GetCellAsInteger(0, j) == id)
- {
- int num2 = 1;
- this.bonusCorrection = new ParametersPack();
- this.bonusCorrection.Parse(bonusCorrectionCsv.GetCellAsString(num2++, j), ',');
- break;
- }
- }
- }
- public readonly int id;
- public readonly string uniqueName;
- public readonly string drawName;
- public readonly ParametersPack bonusCorrection;
- }
- }
- }
|