Personal.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using wf;
  5. namespace MaidStatus
  6. {
  7. public static class Personal
  8. {
  9. public static int Count
  10. {
  11. get
  12. {
  13. Personal.CreateData();
  14. return Personal.commonIdManager.idMap.Count;
  15. }
  16. }
  17. public static bool Contains(string name)
  18. {
  19. return Personal.commonIdManager.nameMap.ContainsKey(name);
  20. }
  21. public static bool Contains(int id)
  22. {
  23. return Personal.commonIdManager.idMap.ContainsKey(id);
  24. }
  25. public static int uniqueNameToId(string name)
  26. {
  27. Personal.CreateData();
  28. NDebug.Assert(Personal.commonIdManager.nameMap.ContainsKey(name), "性格\nユニーク名[" + name + "]をIDに変換できませんでした");
  29. return Personal.commonIdManager.nameMap[name];
  30. }
  31. public static string IdToUniqueName(int id)
  32. {
  33. Personal.CreateData();
  34. NDebug.Assert(Personal.commonIdManager.idMap.ContainsKey(id), "性格\nID[" + id + "]をユニーク名に変換できませんでした");
  35. return Personal.commonIdManager.idMap[id].Key;
  36. }
  37. public static Personal.Data GetData(int id)
  38. {
  39. Personal.CreateData();
  40. NDebug.Assert(Personal.basicDatas.ContainsKey(id), "性格\nID[" + id + "]のデータは存在しません");
  41. return Personal.basicDatas[id];
  42. }
  43. public static Personal.Data GetData(string uniqueName)
  44. {
  45. return Personal.GetData(Personal.uniqueNameToId(uniqueName));
  46. }
  47. public static bool IsEnabled(string uniqueName)
  48. {
  49. Personal.CreateData();
  50. return Personal.commonIdManager.enabledIdList.Contains(Personal.uniqueNameToId(uniqueName));
  51. }
  52. public static bool IsEnabled(int id)
  53. {
  54. Personal.CreateData();
  55. return Personal.commonIdManager.enabledIdList.Contains(id);
  56. }
  57. public static List<Personal.Data> GetAllDatas(bool onlyEnabled)
  58. {
  59. Personal.CreateData();
  60. List<Personal.Data> list = new List<Personal.Data>();
  61. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
  62. {
  63. if (!onlyEnabled || Personal.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  64. {
  65. list.Add(Personal.basicDatas[keyValuePair.Key]);
  66. }
  67. }
  68. return list;
  69. }
  70. public static void CreateData()
  71. {
  72. if (Personal.commonIdManager != null)
  73. {
  74. return;
  75. }
  76. Personal.commonIdManager = new CsvCommonIdManager("maid_status_personal", "性格", CsvCommonIdManager.Type.IdAndUniqueName, null);
  77. Personal.basicDatas = new Dictionary<int, Personal.Data>();
  78. string[] array = new string[]
  79. {
  80. "list",
  81. "feature_condition"
  82. };
  83. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  84. for (int i = 0; i < array2.Length; i++)
  85. {
  86. string text = "maid_status_personal_" + array[i] + ".nei";
  87. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  88. CsvParser csvParser = new CsvParser();
  89. bool condition = csvParser.Open(afileBase);
  90. NDebug.Assert(condition, text + "\nopen failed.");
  91. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  92. }
  93. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
  94. {
  95. Personal.basicDatas.Add(keyValuePair.Key, new Personal.Data(keyValuePair.Key, array2[0].Value, array2[1].Value));
  96. }
  97. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  98. {
  99. keyValuePair2.Value.Dispose();
  100. keyValuePair2.Key.Dispose();
  101. }
  102. }
  103. private const string csvTopCommonName = "maid_status_personal";
  104. private const string typeNameForErrorLog = "性格";
  105. public const string termRootText = "MaidStatus/性格タイプ/";
  106. private static CsvCommonIdManager commonIdManager;
  107. private static Dictionary<int, Personal.Data> basicDatas;
  108. public class Data
  109. {
  110. public Data(int id, CsvParser basicCsv, CsvParser featureConditionsCsv)
  111. {
  112. List<int> list = new List<int>();
  113. for (int i = 0; i < basicCsv.max_cell_y; i++)
  114. {
  115. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
  116. {
  117. this.id = id;
  118. int num = 1;
  119. this.uniqueName = basicCsv.GetCellAsString(num++, i);
  120. this.drawName = basicCsv.GetCellAsString(num++, i);
  121. this.replaceText = basicCsv.GetCellAsString(num++, i);
  122. this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg");
  123. string cellAsString = basicCsv.GetCellAsString(num++, i);
  124. this.oldPersonal = (cellAsString == "〇");
  125. cellAsString = basicCsv.GetCellAsString(num++, i);
  126. if (this.oldPersonal)
  127. {
  128. this.compatible = true;
  129. foreach (string text in cellAsString.Split(new char[]
  130. {
  131. ','
  132. }))
  133. {
  134. if (!string.IsNullOrEmpty(text) && !PluginData.IsEnabled(text))
  135. {
  136. this.compatible = false;
  137. break;
  138. }
  139. }
  140. }
  141. else
  142. {
  143. this.compatible = false;
  144. }
  145. cellAsString = basicCsv.GetCellAsString(num++, i);
  146. if (this.oldPersonal)
  147. {
  148. this.single = true;
  149. foreach (string text2 in cellAsString.Split(new char[]
  150. {
  151. ','
  152. }))
  153. {
  154. if (!string.IsNullOrEmpty(text2) && !PluginData.IsEnabled(text2))
  155. {
  156. this.single = false;
  157. break;
  158. }
  159. }
  160. }
  161. else
  162. {
  163. this.single = true;
  164. }
  165. string[] array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
  166. {
  167. '/'
  168. });
  169. this.competitiveMotionFileVictory = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
  170. array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
  171. {
  172. '/'
  173. });
  174. this.competitiveMotionFileDefeat = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
  175. break;
  176. }
  177. }
  178. this.acquisitionFeatureList = new List<Personal.Data.LearnFeature>();
  179. for (int l = 0; l < featureConditionsCsv.max_cell_y; l++)
  180. {
  181. if (featureConditionsCsv.IsCellToExistData(0, l) && featureConditionsCsv.GetCellAsString(0, l) == this.uniqueName)
  182. {
  183. int num2 = 0;
  184. while (featureConditionsCsv.IsCellToExistData(1, l + num2))
  185. {
  186. this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, l + num2));
  187. num2++;
  188. }
  189. break;
  190. }
  191. }
  192. }
  193. public string termName
  194. {
  195. get
  196. {
  197. return "MaidStatus/性格タイプ/" + this.uniqueName;
  198. }
  199. }
  200. public readonly int id;
  201. public readonly string uniqueName;
  202. public readonly string drawName;
  203. public readonly string replaceText;
  204. public readonly string bgmFileName;
  205. public readonly bool oldPersonal;
  206. public readonly bool compatible;
  207. public readonly bool single;
  208. public readonly KeyValuePair<string, string> competitiveMotionFileVictory;
  209. public readonly KeyValuePair<string, string> competitiveMotionFileDefeat;
  210. public readonly List<Personal.Data.LearnFeature> acquisitionFeatureList;
  211. public class LearnFeature
  212. {
  213. public LearnFeature(CsvParser featureConditionsCsv, int lineY)
  214. {
  215. this.requestParameters = new ParametersPack();
  216. int cell_x = 1;
  217. string cellAsString = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  218. this.feature = Feature.GetData(cellAsString);
  219. this.requestSeikeikens = true;
  220. string cellAsString2 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  221. if (cellAsString2 == "両穴")
  222. {
  223. this.needSeikeiken = Seikeiken.Yes_Yes;
  224. }
  225. else if (cellAsString2 == "前穴")
  226. {
  227. this.needSeikeiken = Seikeiken.Yes_No;
  228. }
  229. else if (cellAsString2 == "後穴")
  230. {
  231. this.needSeikeiken = Seikeiken.No_Yes;
  232. }
  233. else
  234. {
  235. this.requestSeikeikens = false;
  236. }
  237. while (featureConditionsCsv.IsCellToExistData(cell_x, lineY))
  238. {
  239. string cellAsString3 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  240. int cellAsInteger = featureConditionsCsv.GetCellAsInteger(cell_x++, lineY);
  241. this.requestParameters.Add(ParametersPack.NameToStatusType(cellAsString3), cellAsInteger);
  242. }
  243. }
  244. public bool isLearnPossible(Status status)
  245. {
  246. return (!this.requestSeikeikens || this.needSeikeiken == status.seikeiken) && this.requestParameters.GreaterThanOrEqualToStatus(status);
  247. }
  248. public readonly Feature.Data feature;
  249. public readonly bool requestSeikeikens;
  250. public readonly Seikeiken needSeikeiken;
  251. public readonly ParametersPack requestParameters;
  252. }
  253. }
  254. }
  255. }