PersonalEventBlocker.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using System;
  2. using System.Collections.Generic;
  3. namespace MaidStatus
  4. {
  5. public static class PersonalEventBlocker
  6. {
  7. public static void CreateData()
  8. {
  9. if (PersonalEventBlocker.blockerDataList != null)
  10. {
  11. return;
  12. }
  13. PersonalEventBlocker.blockerDataList = new List<PersonalEventBlocker.Data>();
  14. string text = string.Empty;
  15. string str = string.Empty;
  16. if (Product.type == Product.Type.EnAdult)
  17. {
  18. text = "maid_personaleventblocker_list.nei";
  19. str = "maid_personaleventblocker_unlocklist_";
  20. }
  21. else if (Product.type == Product.Type.JpAdult)
  22. {
  23. text = "maid_personaleventblocker_list_jp.nei";
  24. str = "maid_personaleventblocker_unlocklist_jp_";
  25. }
  26. if (string.IsNullOrEmpty(text) || !GameUty.FileSystem.IsExistentFile(text))
  27. {
  28. return;
  29. }
  30. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  31. {
  32. using (CsvParser csvParser = new CsvParser())
  33. {
  34. bool flag = csvParser.Open(afileBase);
  35. if (flag)
  36. {
  37. int num = 1;
  38. while (csvParser.IsCellToExistData(0, num))
  39. {
  40. PersonalEventBlocker.Data item = new PersonalEventBlocker.Data(csvParser, num);
  41. PersonalEventBlocker.blockerDataList.Add(item);
  42. num++;
  43. }
  44. }
  45. }
  46. }
  47. if (GameUty.PathList != null)
  48. {
  49. HashSet<PersonalEventBlocker.Data> hashSet = new HashSet<PersonalEventBlocker.Data>();
  50. foreach (string str2 in GameUty.PathList)
  51. {
  52. string f_strFileName = str + str2 + ".nei";
  53. if (GameUty.FileSystem.IsExistentFile(f_strFileName))
  54. {
  55. using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen(f_strFileName))
  56. {
  57. using (CsvParser csvParser2 = new CsvParser())
  58. {
  59. bool flag2 = csvParser2.Open(afileBase2);
  60. if (flag2)
  61. {
  62. int num2 = 1;
  63. while (csvParser2.IsCellToExistData(0, num2))
  64. {
  65. Personal.Data data = Personal.GetData(csvParser2.GetCellAsString(0, num2));
  66. foreach (PersonalEventBlocker.Data data2 in PersonalEventBlocker.blockerDataList)
  67. {
  68. if (data == data2.personal)
  69. {
  70. hashSet.Add(data2);
  71. break;
  72. }
  73. }
  74. num2++;
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
  81. foreach (PersonalEventBlocker.Data item2 in hashSet)
  82. {
  83. PersonalEventBlocker.blockerDataList.Remove(item2);
  84. }
  85. }
  86. }
  87. public static PersonalEventBlocker.Data GetData(Personal.Data personal)
  88. {
  89. foreach (PersonalEventBlocker.Data data in PersonalEventBlocker.blockerDataList)
  90. {
  91. if (personal == data.personal)
  92. {
  93. return data;
  94. }
  95. }
  96. return null;
  97. }
  98. public static List<PersonalEventBlocker.Data> GetAllDatas()
  99. {
  100. return PersonalEventBlocker.blockerDataList;
  101. }
  102. public static bool IsEnabledYotodiSkill(Personal.Data personal, int yotogiSkillId)
  103. {
  104. PersonalEventBlocker.Data data = PersonalEventBlocker.GetData(personal);
  105. return data == null || !data.blockYotogiIdList.Contains(yotogiSkillId);
  106. }
  107. public static bool IsEnabledScheduleTask(Personal.Data personal, int taskId)
  108. {
  109. PersonalEventBlocker.Data data = PersonalEventBlocker.GetData(personal);
  110. return data == null || !data.blockScheduleIdList.Contains(taskId);
  111. }
  112. public static bool IsEnabledLifeMode(Personal.Data personal)
  113. {
  114. return Product.type != Product.Type.EnAdult || PersonalEventBlocker.GetData(personal) == null;
  115. }
  116. private static List<PersonalEventBlocker.Data> blockerDataList;
  117. public class Data
  118. {
  119. public Data(CsvParser csv, int readLineY)
  120. {
  121. if (!csv.IsValid() || !csv.IsCellToExistData(0, readLineY))
  122. {
  123. return;
  124. }
  125. Func<string, HashSet<int>> func = delegate(string cellText)
  126. {
  127. HashSet<int> hashSet = new HashSet<int>();
  128. if (!string.IsNullOrEmpty(cellText))
  129. {
  130. foreach (string text in cellText.Split(new char[]
  131. {
  132. ','
  133. }))
  134. {
  135. int item;
  136. if (int.TryParse(text.Trim(), out item))
  137. {
  138. hashSet.Add(item);
  139. }
  140. }
  141. }
  142. return hashSet;
  143. };
  144. int num = 0;
  145. this.personal = Personal.GetData(csv.GetCellAsString(num++, readLineY));
  146. this.blockScheduleIdList = func(csv.GetCellAsString(num++, readLineY));
  147. this.blockYotogiIdList = func(csv.GetCellAsString(num++, readLineY));
  148. }
  149. public readonly Personal.Data personal;
  150. public readonly HashSet<int> blockScheduleIdList;
  151. public readonly HashSet<int> blockYotogiIdList;
  152. }
  153. }
  154. }