Personal.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. HashSet<int> additionalRelationEnabledIdList = new HashSet<int>();
  94. CsvCommonIdManager.ReadEnabledIdList(GameUty.FileSystem, GameUty.PathList, "maid_status_personal_additionalrelation_enabled_list", ref additionalRelationEnabledIdList);
  95. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in Personal.commonIdManager.idMap)
  96. {
  97. Personal.basicDatas.Add(keyValuePair.Key, new Personal.Data(keyValuePair.Key, array2[0].Value, array2[1].Value, additionalRelationEnabledIdList));
  98. }
  99. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  100. {
  101. keyValuePair2.Value.Dispose();
  102. keyValuePair2.Key.Dispose();
  103. }
  104. }
  105. private const string csvTopCommonName = "maid_status_personal";
  106. private const string typeNameForErrorLog = "性格";
  107. public const string termRootText = "MaidStatus/性格タイプ/";
  108. public const string additionalRelationEnabledCsvName = "maid_status_personal_additionalrelation_enabled_list";
  109. private static CsvCommonIdManager commonIdManager;
  110. private static Dictionary<int, Personal.Data> basicDatas;
  111. public class Data
  112. {
  113. public Data(int id, CsvParser basicCsv, CsvParser featureConditionsCsv, HashSet<int> additionalRelationEnabledIdList)
  114. {
  115. List<int> list = new List<int>();
  116. for (int i = 0; i < basicCsv.max_cell_y; i++)
  117. {
  118. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
  119. {
  120. this.id = id;
  121. int num = 1;
  122. this.uniqueName = basicCsv.GetCellAsString(num++, i);
  123. this.drawName = basicCsv.GetCellAsString(num++, i);
  124. this.replaceText = basicCsv.GetCellAsString(num++, i);
  125. this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg");
  126. string cellAsString = basicCsv.GetCellAsString(num++, i);
  127. this.oldPersonal = (cellAsString == "〇");
  128. cellAsString = basicCsv.GetCellAsString(num++, i);
  129. if (this.oldPersonal)
  130. {
  131. this.compatible = true;
  132. foreach (string text in cellAsString.Split(new char[]
  133. {
  134. ','
  135. }))
  136. {
  137. if (!string.IsNullOrEmpty(text) && !PluginData.IsEnabled(text))
  138. {
  139. this.compatible = false;
  140. break;
  141. }
  142. }
  143. }
  144. else
  145. {
  146. this.compatible = false;
  147. }
  148. cellAsString = basicCsv.GetCellAsString(num++, i);
  149. if (this.oldPersonal)
  150. {
  151. this.single = true;
  152. foreach (string text2 in cellAsString.Split(new char[]
  153. {
  154. ','
  155. }))
  156. {
  157. if (!string.IsNullOrEmpty(text2) && !PluginData.IsEnabled(text2))
  158. {
  159. this.single = false;
  160. break;
  161. }
  162. }
  163. }
  164. else
  165. {
  166. this.single = true;
  167. }
  168. string[] array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
  169. {
  170. '/'
  171. });
  172. this.competitiveMotionFileVictory = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
  173. array3 = basicCsv.GetCellAsString(num++, i).Split(new char[]
  174. {
  175. '/'
  176. });
  177. this.competitiveMotionFileDefeat = new KeyValuePair<string, string>(Path.ChangeExtension(array3[0], ".ks"), array3[1]);
  178. this.enabledAdditionalRelation = additionalRelationEnabledIdList.Contains(id);
  179. if (this.uniqueName == "Muku" || this.uniqueName == "Majime" || this.uniqueName == "Rindere")
  180. {
  181. this.enabledAdditionalRelation = true;
  182. }
  183. break;
  184. }
  185. }
  186. this.acquisitionFeatureList = new List<Personal.Data.LearnFeature>();
  187. for (int l = 0; l < featureConditionsCsv.max_cell_y; l++)
  188. {
  189. if (featureConditionsCsv.IsCellToExistData(0, l) && featureConditionsCsv.GetCellAsString(0, l) == this.uniqueName)
  190. {
  191. int num2 = 0;
  192. while (featureConditionsCsv.IsCellToExistData(1, l + num2))
  193. {
  194. this.acquisitionFeatureList.Add(new Personal.Data.LearnFeature(featureConditionsCsv, l + num2));
  195. num2++;
  196. }
  197. break;
  198. }
  199. }
  200. }
  201. public string termName
  202. {
  203. get
  204. {
  205. return "MaidStatus/性格タイプ/" + this.uniqueName;
  206. }
  207. }
  208. public readonly int id;
  209. public readonly string uniqueName;
  210. public readonly string drawName;
  211. public readonly string replaceText;
  212. public readonly string bgmFileName;
  213. public readonly bool oldPersonal;
  214. public readonly bool compatible;
  215. public readonly bool single;
  216. public readonly bool enabledAdditionalRelation;
  217. public readonly KeyValuePair<string, string> competitiveMotionFileVictory;
  218. public readonly KeyValuePair<string, string> competitiveMotionFileDefeat;
  219. public readonly List<Personal.Data.LearnFeature> acquisitionFeatureList;
  220. public class LearnFeature
  221. {
  222. public LearnFeature(CsvParser featureConditionsCsv, int lineY)
  223. {
  224. this.requestParameters = new ParametersPack();
  225. int cell_x = 1;
  226. string cellAsString = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  227. this.feature = Feature.GetData(cellAsString);
  228. this.requestSeikeikens = true;
  229. string cellAsString2 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  230. if (cellAsString2 == "両穴")
  231. {
  232. this.needSeikeiken = Seikeiken.Yes_Yes;
  233. }
  234. else if (cellAsString2 == "前穴")
  235. {
  236. this.needSeikeiken = Seikeiken.Yes_No;
  237. }
  238. else if (cellAsString2 == "後穴")
  239. {
  240. this.needSeikeiken = Seikeiken.No_Yes;
  241. }
  242. else
  243. {
  244. this.requestSeikeikens = false;
  245. }
  246. while (featureConditionsCsv.IsCellToExistData(cell_x, lineY))
  247. {
  248. string cellAsString3 = featureConditionsCsv.GetCellAsString(cell_x++, lineY);
  249. int cellAsInteger = featureConditionsCsv.GetCellAsInteger(cell_x++, lineY);
  250. this.requestParameters.Add(ParametersPack.NameToStatusType(cellAsString3), cellAsInteger);
  251. }
  252. }
  253. public bool isLearnPossible(Status status)
  254. {
  255. return (!this.requestSeikeikens || this.needSeikeiken == status.seikeiken) && this.requestParameters.GreaterThanOrEqualToStatus(status);
  256. }
  257. public readonly Feature.Data feature;
  258. public readonly bool requestSeikeikens;
  259. public readonly Seikeiken needSeikeiken;
  260. public readonly ParametersPack requestParameters;
  261. }
  262. }
  263. }
  264. }