AbstractFreeModeItem.cs 3.3 KB

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