AppealData.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. namespace Kasizuki
  6. {
  7. public static class AppealData
  8. {
  9. public static int Count
  10. {
  11. get
  12. {
  13. AppealData.CreateData();
  14. return AppealData.commonIdManager.idMap.Count;
  15. }
  16. }
  17. public static bool Contains(int id)
  18. {
  19. AppealData.CreateData();
  20. return AppealData.commonIdManager.idMap.ContainsKey(id);
  21. }
  22. public static AppealData.Data GetData(int id)
  23. {
  24. AppealData.CreateData();
  25. NDebug.Assert(AppealData.basicDatas.ContainsKey(id), "傅き.アピール欄\nID[" + id + "]のデータは存在しません");
  26. return AppealData.basicDatas[id];
  27. }
  28. public static bool IsEnabled(int id)
  29. {
  30. AppealData.CreateData();
  31. return AppealData.commonIdManager.enabledIdList.Contains(id);
  32. }
  33. public static List<AppealData.Data> GetAllDatas(bool onlyEnabled)
  34. {
  35. AppealData.CreateData();
  36. List<AppealData.Data> list = new List<AppealData.Data>();
  37. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
  38. {
  39. if (!onlyEnabled || AppealData.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  40. {
  41. list.Add(AppealData.basicDatas[keyValuePair.Key]);
  42. }
  43. }
  44. return list;
  45. }
  46. public static List<AppealData.Data> GetDatas(Func<AppealData.Data, bool> customCheckFunction)
  47. {
  48. AppealData.CreateData();
  49. List<AppealData.Data> list = new List<AppealData.Data>();
  50. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
  51. {
  52. AppealData.Data data = AppealData.basicDatas[keyValuePair.Key];
  53. if (customCheckFunction(data))
  54. {
  55. list.Add(data);
  56. }
  57. }
  58. return list;
  59. }
  60. public static List<AppealData.Data> GetDatas(Maid maid)
  61. {
  62. Func<AppealData.Data, bool> customCheckFunction = (AppealData.Data data) => data.personalUniqueName == maid.status.personal.uniqueName;
  63. return AppealData.GetDatas(customCheckFunction);
  64. }
  65. public static void CreateData()
  66. {
  67. if (AppealData.commonIdManager != null)
  68. {
  69. return;
  70. }
  71. AppealData.commonIdManager = new CsvCommonIdManager("kasizuki_appeal", "傅き.アピール欄", CsvCommonIdManager.Type.IdOnly, null);
  72. AppealData.basicDatas = new Dictionary<int, AppealData.Data>();
  73. string[] array = new string[]
  74. {
  75. "list"
  76. };
  77. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  78. for (int i = 0; i < array2.Length; i++)
  79. {
  80. string text = "kasizuki_appeal_" + array[i] + ".nei";
  81. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  82. CsvParser csvParser = new CsvParser();
  83. bool condition = csvParser.Open(afileBase);
  84. NDebug.Assert(condition, text + "\nopen failed.");
  85. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  86. }
  87. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
  88. {
  89. int key = keyValuePair.Key;
  90. AppealData.Data value = new AppealData.Data(key, array2[0].Value);
  91. AppealData.basicDatas.Add(key, value);
  92. }
  93. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  94. {
  95. keyValuePair2.Value.Dispose();
  96. keyValuePair2.Key.Dispose();
  97. }
  98. }
  99. private const string csvTopCommonName = "kasizuki_appeal";
  100. private const string typeNameForErrorLog = "傅き.アピール欄";
  101. private static CsvCommonIdManager commonIdManager;
  102. private static Dictionary<int, AppealData.Data> basicDatas;
  103. public class Data
  104. {
  105. public Data(int uniqueID, CsvParser csv)
  106. {
  107. for (int i = 1; i < csv.max_cell_y; i++)
  108. {
  109. if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID)
  110. {
  111. int num = 1;
  112. this.ID = uniqueID;
  113. this.personalUniqueName = csv.GetCellAsString(num++, i);
  114. this.texName = csv.GetCellAsString(num++, i);
  115. }
  116. }
  117. }
  118. public Texture2D GetTexture()
  119. {
  120. if (!string.IsNullOrEmpty(this.texName))
  121. {
  122. string f_strFileName = this.texName + ".tex";
  123. if (GameUty.FileSystem.IsExistentFile(f_strFileName))
  124. {
  125. return ImportCM.CreateTexture(f_strFileName);
  126. }
  127. Debug.LogWarningFormat("テクスチャ「{0}」がない", new object[]
  128. {
  129. this.texName
  130. });
  131. }
  132. else
  133. {
  134. Debug.LogWarning("テクスチャ名が空でした");
  135. }
  136. return null;
  137. }
  138. public readonly int ID;
  139. public readonly string personalUniqueName;
  140. public readonly string texName;
  141. }
  142. }
  143. }