PersonalEventBlocker.cs 4.0 KB

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