123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using System;
- using System.Collections.Generic;
- using wf;
- namespace MaidStatus
- {
- public static class Propensity
- {
- public static int Count
- {
- get
- {
- Propensity.CreateData();
- return Propensity.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(string name)
- {
- return Propensity.commonIdManager.nameMap.ContainsKey(name);
- }
- public static bool Contains(int id)
- {
- return Propensity.commonIdManager.idMap.ContainsKey(id);
- }
- public static int uniqueNameToId(string name)
- {
- Propensity.CreateData();
- NDebug.Assert(Propensity.commonIdManager.nameMap.ContainsKey(name), "性癖\nユニーク名[" + name + "]をIDに変換できませんでした");
- return Propensity.commonIdManager.nameMap[name];
- }
- public static string IdToUniqueName(int id)
- {
- Propensity.CreateData();
- NDebug.Assert(Propensity.commonIdManager.idMap.ContainsKey(id), "性癖\nID[" + id + "]をユニーク名に変換できませんでした");
- return Propensity.commonIdManager.idMap[id].Key;
- }
- public static Propensity.Data GetData(int id)
- {
- Propensity.CreateData();
- NDebug.Assert(Propensity.basicDatas.ContainsKey(id), "性癖\nID[" + id + "]のデータは存在しません");
- return Propensity.basicDatas[id];
- }
- public static Propensity.Data GetData(string uniqueName)
- {
- return Propensity.GetData(Propensity.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(string uniqueName)
- {
- Propensity.CreateData();
- return Propensity.commonIdManager.enabledIdList.Contains(Propensity.uniqueNameToId(uniqueName));
- }
- public static bool IsEnabled(int id)
- {
- Propensity.CreateData();
- return Propensity.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<Propensity.Data> GetAllDatas(bool onlyEnabled)
- {
- Propensity.CreateData();
- List<Propensity.Data> list = new List<Propensity.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Propensity.commonIdManager.idMap)
- {
- if (!onlyEnabled || Propensity.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(Propensity.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static void CreateData()
- {
- if (Propensity.commonIdManager != null)
- {
- return;
- }
- Propensity.commonIdManager = new CsvCommonIdManager("maid_status_propensity", "性癖", CsvCommonIdManager.Type.IdAndUniqueName, null);
- Propensity.basicDatas = new Dictionary<int, Propensity.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_propensity_" + 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 Propensity.commonIdManager.idMap)
- {
- Propensity.basicDatas.Add(keyValuePair.Key, new Propensity.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_propensity";
- private const string typeNameForErrorLog = "性癖";
- public const string termRootText = "MaidStatus/性癖タイプ/";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, Propensity.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 string termName
- {
- get
- {
- return "MaidStatus/性癖タイプ/" + this.uniqueName;
- }
- }
- public readonly int id;
- public readonly string uniqueName;
- public readonly string drawName;
- public readonly ParametersPack bonusCorrection;
- }
- }
- }
|