AbstractFreeModeItem.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System;
  2. using System.Collections.Generic;
  3. public abstract class AbstractFreeModeItem
  4. {
  5. public abstract string title { get; }
  6. public abstract string titleTerm { get; }
  7. public abstract int item_id { get; }
  8. public abstract string text { get; }
  9. public abstract string textTerm { get; }
  10. public abstract string[] condition_texts { get; }
  11. public abstract string[] condition_text_terms { get; }
  12. public abstract bool is_enabled { get; }
  13. public abstract string play_file_name { get; }
  14. public abstract AbstractFreeModeItem.ItemType type { get; }
  15. protected static HashSet<int> GetEnabledIdList()
  16. {
  17. if (AbstractFreeModeItem.enabled_id_list_ != null)
  18. {
  19. return AbstractFreeModeItem.enabled_id_list_;
  20. }
  21. AbstractFreeModeItem.enabled_id_list_ = new HashSet<int>();
  22. AbstractFreeModeItem.enabled_id_list_ = AbstractFreeModeItem.ReadIdList(false);
  23. return AbstractFreeModeItem.enabled_id_list_;
  24. }
  25. protected static HashSet<int> GetEnabledOldIdList()
  26. {
  27. if (AbstractFreeModeItem.enabledOld_id_list_ != null)
  28. {
  29. return AbstractFreeModeItem.enabledOld_id_list_;
  30. }
  31. AbstractFreeModeItem.enabledOld_id_list_ = new HashSet<int>();
  32. AbstractFreeModeItem.enabledOld_id_list_ = AbstractFreeModeItem.ReadIdList(true);
  33. return AbstractFreeModeItem.enabledOld_id_list_;
  34. }
  35. protected static HashSet<int> ReadIdList(bool useOld)
  36. {
  37. HashSet<int> enabled_id_list = new HashSet<int>();
  38. AFileSystemBase fileSystemBase;
  39. if (useOld)
  40. {
  41. fileSystemBase = GameUty.FileSystemOld;
  42. }
  43. else
  44. {
  45. fileSystemBase = GameUty.FileSystem;
  46. }
  47. Func<string, bool> func = delegate(string file_name)
  48. {
  49. file_name += ".nei";
  50. if (!fileSystemBase.IsExistentFile(file_name))
  51. {
  52. return false;
  53. }
  54. using (AFileBase afileBase = fileSystemBase.FileOpen(file_name))
  55. {
  56. using (CsvParser csvParser = new CsvParser())
  57. {
  58. bool condition = csvParser.Open(afileBase);
  59. NDebug.Assert(condition, file_name + "\nopen failed.");
  60. for (int j = 1; j < csvParser.max_cell_y; j++)
  61. {
  62. if (csvParser.IsCellToExistData(0, j))
  63. {
  64. int cellAsInteger = csvParser.GetCellAsInteger(0, j);
  65. if (!enabled_id_list.Contains(cellAsInteger))
  66. {
  67. enabled_id_list.Add(cellAsInteger);
  68. }
  69. }
  70. }
  71. }
  72. }
  73. return true;
  74. };
  75. List<string> list;
  76. if (useOld)
  77. {
  78. list = GameUty.PathListOld;
  79. }
  80. else
  81. {
  82. list = GameUty.PathList;
  83. }
  84. if (func("recollection_enabled_id_list"))
  85. {
  86. for (int i = 0; i < list.Count; i++)
  87. {
  88. func("recollection_enabled_id_list_" + list[i]);
  89. }
  90. }
  91. return enabled_id_list;
  92. }
  93. public static bool EmptyEnableList(bool useOld)
  94. {
  95. if (useOld)
  96. {
  97. AbstractFreeModeItem.GetEnabledOldIdList();
  98. if (AbstractFreeModeItem.enabledOld_id_list_ == null || AbstractFreeModeItem.enabledOld_id_list_.Count == 0)
  99. {
  100. return false;
  101. }
  102. }
  103. else
  104. {
  105. AbstractFreeModeItem.GetEnabledIdList();
  106. if (AbstractFreeModeItem.enabled_id_list_ == null || AbstractFreeModeItem.enabled_id_list_.Count == 0)
  107. {
  108. return false;
  109. }
  110. }
  111. return true;
  112. }
  113. private static HashSet<int> enabled_id_list_;
  114. private static HashSet<int> enabledOld_id_list_;
  115. public enum ItemType
  116. {
  117. MainStory,
  118. Vip,
  119. Normal
  120. }
  121. public enum GameMode
  122. {
  123. CM3D2,
  124. COM3D
  125. }
  126. }