ManData.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using System;
  2. using System.Collections.Generic;
  3. using wf;
  4. namespace Kasizuki
  5. {
  6. public static class ManData
  7. {
  8. public static int Count
  9. {
  10. get
  11. {
  12. ManData.CreateData();
  13. return ManData.commonIdManager.idMap.Count;
  14. }
  15. }
  16. public static bool Contains(string name)
  17. {
  18. return ManData.commonIdManager.nameMap.ContainsKey(name);
  19. }
  20. public static bool Contains(int id)
  21. {
  22. return ManData.commonIdManager.idMap.ContainsKey(id);
  23. }
  24. public static int uniqueNameToId(string uniqueName)
  25. {
  26. ManData.CreateData();
  27. NDebug.Assert(ManData.commonIdManager.nameMap.ContainsKey(uniqueName), "傅き.男データ\nユニーク名[" + uniqueName + "]をIDに変換できませんでした");
  28. return ManData.commonIdManager.nameMap[uniqueName];
  29. }
  30. public static string IdToUniqueName(int id)
  31. {
  32. ManData.CreateData();
  33. NDebug.Assert(ManData.commonIdManager.idMap.ContainsKey(id), "傅き.男データ\nID[" + id + "]をユニーク名に変換できませんでした");
  34. return ManData.commonIdManager.idMap[id].Key;
  35. }
  36. public static ManData.Data GetData(int id)
  37. {
  38. ManData.CreateData();
  39. NDebug.Assert(ManData.basicDatas.ContainsKey(id), "傅き.男データ\nID[" + id + "]のデータは存在しません");
  40. return ManData.basicDatas[id];
  41. }
  42. public static ManData.Data GetData(string uniqueName)
  43. {
  44. return ManData.GetData(ManData.uniqueNameToId(uniqueName));
  45. }
  46. public static bool IsEnabled(string uniqueName)
  47. {
  48. ManData.CreateData();
  49. return ManData.commonIdManager.enabledIdList.Contains(ManData.uniqueNameToId(uniqueName));
  50. }
  51. public static bool IsEnabled(int id)
  52. {
  53. ManData.CreateData();
  54. return ManData.commonIdManager.enabledIdList.Contains(id);
  55. }
  56. public static List<ManData.Data> GetAllDatas(bool onlyEnabled, bool checkLockNTR = true)
  57. {
  58. ManData.CreateData();
  59. List<ManData.Data> list = new List<ManData.Data>();
  60. if (checkLockNTR && GameMain.Instance.CharacterMgr.status.lockNTRPlay)
  61. {
  62. list.Add(ManData.GetData(10));
  63. }
  64. else
  65. {
  66. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in ManData.commonIdManager.idMap)
  67. {
  68. if (!onlyEnabled || ManData.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  69. {
  70. list.Add(ManData.basicDatas[keyValuePair.Key]);
  71. }
  72. }
  73. }
  74. return list;
  75. }
  76. public static void CreateData()
  77. {
  78. if (ManData.commonIdManager != null)
  79. {
  80. return;
  81. }
  82. ManData.commonIdManager = new CsvCommonIdManager("kasizuki_man", "傅き.男データ", CsvCommonIdManager.Type.IdAndUniqueName, null);
  83. ManData.basicDatas = new Dictionary<int, ManData.Data>();
  84. string[] array = new string[]
  85. {
  86. "list"
  87. };
  88. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  89. for (int i = 0; i < array2.Length; i++)
  90. {
  91. string text = "kasizuki_man_" + array[i] + ".nei";
  92. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  93. CsvParser csvParser = new CsvParser();
  94. bool condition = csvParser.Open(afileBase);
  95. NDebug.Assert(condition, text + "\nopen failed.");
  96. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  97. }
  98. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in ManData.commonIdManager.idMap)
  99. {
  100. int key = keyValuePair.Key;
  101. ManData.Data value = new ManData.Data(key, array2[0].Value);
  102. ManData.basicDatas.Add(key, value);
  103. }
  104. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  105. {
  106. keyValuePair2.Value.Dispose();
  107. keyValuePair2.Key.Dispose();
  108. }
  109. }
  110. private const string csvTopCommonName = "kasizuki_man";
  111. private const string typeNameForErrorLog = "傅き.男データ";
  112. private static CsvCommonIdManager commonIdManager;
  113. private static Dictionary<int, ManData.Data> basicDatas;
  114. public class Data
  115. {
  116. public Data(int uniqueID, CsvParser csv)
  117. {
  118. for (int i = 1; i < csv.max_cell_y; i++)
  119. {
  120. if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID)
  121. {
  122. int num = 1;
  123. this.ID = uniqueID;
  124. this.uniqueName = csv.GetCellAsString(num++, i);
  125. this.drawName = csv.GetCellAsString(num++, i);
  126. this.modelResourceName = csv.GetCellAsString(num++, i);
  127. this.profileText = csv.GetCellAsString(num++, i);
  128. this.favoritePlayText = csv.GetCellAsString(num++, i);
  129. try
  130. {
  131. this.manType = (ManDataType)Enum.ToObject(typeof(ManDataType), this.ID);
  132. }
  133. catch (Exception e)
  134. {
  135. NDebug.AssertParseError("ManDataType", e);
  136. }
  137. }
  138. }
  139. }
  140. public readonly int ID;
  141. public readonly string uniqueName;
  142. public readonly string drawName;
  143. public readonly string modelResourceName;
  144. public readonly string profileText;
  145. public readonly string favoritePlayText;
  146. public readonly ManDataType manType;
  147. }
  148. }
  149. }