AbstractFreeModeItem.cs 3.1 KB

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