SubMaid.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using wf;
  6. namespace MaidStatus
  7. {
  8. public static class SubMaid
  9. {
  10. public static int Count
  11. {
  12. get
  13. {
  14. SubMaid.CreateData();
  15. return SubMaid.commonIdManager.idMap.Count;
  16. }
  17. }
  18. public static bool Contains(string name)
  19. {
  20. return SubMaid.commonIdManager.nameMap.ContainsKey(name);
  21. }
  22. public static bool Contains(int id)
  23. {
  24. return SubMaid.commonIdManager.idMap.ContainsKey(id);
  25. }
  26. public static int uniqueNameToId(string name)
  27. {
  28. SubMaid.CreateData();
  29. NDebug.Assert(SubMaid.commonIdManager.nameMap.ContainsKey(name), "Subメイド\nユニーク名[" + name + "]をIDに変換できませんでした");
  30. return SubMaid.commonIdManager.nameMap[name];
  31. }
  32. public static string IdToUniqueName(int id)
  33. {
  34. SubMaid.CreateData();
  35. NDebug.Assert(SubMaid.commonIdManager.idMap.ContainsKey(id), "Subメイド\nID[" + id + "]をユニーク名に変換できませんでした");
  36. return SubMaid.commonIdManager.idMap[id].Key;
  37. }
  38. public static SubMaid.Data GetData(int id)
  39. {
  40. SubMaid.CreateData();
  41. NDebug.Assert(SubMaid.basicDatas.ContainsKey(id), "Subメイド\nID[" + id + "]のデータは存在しません");
  42. return SubMaid.basicDatas[id];
  43. }
  44. public static SubMaid.Data GetData(string uniqueName)
  45. {
  46. return SubMaid.GetData(SubMaid.uniqueNameToId(uniqueName));
  47. }
  48. public static bool IsEnabled(string uniqueName)
  49. {
  50. SubMaid.CreateData();
  51. return SubMaid.commonIdManager.enabledIdList.Contains(SubMaid.uniqueNameToId(uniqueName));
  52. }
  53. public static bool IsEnabled(int id)
  54. {
  55. SubMaid.CreateData();
  56. return SubMaid.commonIdManager.enabledIdList.Contains(id);
  57. }
  58. public static List<SubMaid.Data> GetAllDatas(bool onlyEnabled)
  59. {
  60. SubMaid.CreateData();
  61. List<SubMaid.Data> list = new List<SubMaid.Data>();
  62. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in SubMaid.commonIdManager.idMap)
  63. {
  64. if (!onlyEnabled || SubMaid.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  65. {
  66. list.Add(SubMaid.basicDatas[keyValuePair.Key]);
  67. }
  68. }
  69. return list;
  70. }
  71. public static void CreateData()
  72. {
  73. if (SubMaid.commonIdManager != null)
  74. {
  75. return;
  76. }
  77. SubMaid.commonIdManager = new CsvCommonIdManager("maid_status_submaid", "Subメイド", CsvCommonIdManager.Type.IdAndUniqueName, null);
  78. SubMaid.basicDatas = new Dictionary<int, SubMaid.Data>();
  79. string[] array = new string[]
  80. {
  81. "list",
  82. "kiss_side_list"
  83. };
  84. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  85. for (int i = 0; i < array2.Length; i++)
  86. {
  87. string text = "maid_status_submaid_" + array[i] + ".nei";
  88. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  89. CsvParser csvParser = new CsvParser();
  90. bool condition = csvParser.Open(afileBase);
  91. NDebug.Assert(condition, text + "\nopen failed.");
  92. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  93. }
  94. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in SubMaid.commonIdManager.idMap)
  95. {
  96. SubMaid.basicDatas.Add(keyValuePair.Key, new SubMaid.Data(keyValuePair.Key, array2[0].Value, array2[1].Value));
  97. }
  98. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  99. {
  100. keyValuePair2.Value.Dispose();
  101. keyValuePair2.Key.Dispose();
  102. }
  103. }
  104. private const string csvTopCommonName = "maid_status_submaid";
  105. private const string typeNameForErrorLog = "Subメイド";
  106. private static CsvCommonIdManager commonIdManager;
  107. private static Dictionary<int, SubMaid.Data> basicDatas;
  108. public class Data
  109. {
  110. public Data(int id, CsvParser basicCsv, CsvParser kissSideCsv)
  111. {
  112. for (int i = 1; i < basicCsv.max_cell_y; i++)
  113. {
  114. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
  115. {
  116. int num = 1;
  117. this.id = id;
  118. this.uniqueName = basicCsv.GetCellAsString(num++, i);
  119. this.replaceText = basicCsv.GetCellAsString(num++, i);
  120. this.isEditPossible = (basicCsv.GetCellAsString(num++, i) == "〇");
  121. this.status = new SubMaid.Data.CharacterStatus(basicCsv, i);
  122. break;
  123. }
  124. }
  125. for (int j = 1; j < kissSideCsv.max_cell_y; j++)
  126. {
  127. if (kissSideCsv.IsCellToExistData(0, j) && kissSideCsv.GetCellAsInteger(0, j) == id)
  128. {
  129. this.secondStatus = new SubMaid.Data.CharacterStatus(kissSideCsv, j);
  130. break;
  131. }
  132. }
  133. }
  134. public void ApplyStatus(Status status, bool refSecondStatus)
  135. {
  136. if (status == null)
  137. {
  138. return;
  139. }
  140. SubMaid.Data.CharacterStatus characterStatus = (!refSecondStatus || this.secondStatus == null) ? this.status : this.secondStatus;
  141. status.heroineType = HeroineType.Sub;
  142. status.subCharaData = this;
  143. status.lastName = characterStatus.lastName;
  144. status.firstName = characterStatus.firstName;
  145. status.contract = characterStatus.contract;
  146. status.initSeikeiken = (status.seikeiken = characterStatus.initSeikeiken);
  147. status.likability = characterStatus.likability;
  148. status.baseLovely = characterStatus.lovely;
  149. status.baseElegance = characterStatus.elegance;
  150. status.baseCharm = characterStatus.charm;
  151. status.baseCare = characterStatus.care;
  152. status.baseReception = characterStatus.reception;
  153. status.baseCooking = characterStatus.cooking;
  154. status.baseDance = characterStatus.dance;
  155. status.baseVocal = characterStatus.vocal;
  156. status.playCountNightWork = characterStatus.playCountNightWork;
  157. int num = characterStatus.hp;
  158. status.currentHp = num;
  159. status.baseMaxHp = num;
  160. num = characterStatus.mind;
  161. status.currentMind = num;
  162. status.baseMaxMind = num;
  163. status.baseInyoku = characterStatus.inyoku;
  164. status.baseMvalue = characterStatus.mvalue;
  165. status.baseHentai = characterStatus.hentai;
  166. status.baseHousi = characterStatus.housi;
  167. status.playCountYotogi = characterStatus.playCountYotogi;
  168. }
  169. public void ApplyPreset(Maid maid, bool refSecondStatus)
  170. {
  171. if (maid == null)
  172. {
  173. return;
  174. }
  175. SubMaid.Data.CharacterStatus characterStatus = (!refSecondStatus || this.secondStatus == null) ? this.status : this.secondStatus;
  176. CharacterMgr.npcDatas[characterStatus.presetName].Apply(maid, true);
  177. maid.status.UpdateBodyParam();
  178. if (!string.IsNullOrEmpty(characterStatus.iconFileName))
  179. {
  180. Texture2D texture2D = ImportCM.CreateTexture(characterStatus.iconFileName);
  181. if (texture2D.format == TextureFormat.DXT1 || texture2D.format == TextureFormat.DXT5)
  182. {
  183. Texture2D texture2D2 = new Texture2D(texture2D.width, texture2D.height, TextureFormat.ARGB32, false);
  184. texture2D2.SetPixels(texture2D.GetPixels());
  185. texture2D2.Apply();
  186. UnityEngine.Object.Destroy(texture2D);
  187. maid.SetThumIcon(texture2D2);
  188. }
  189. else
  190. {
  191. maid.SetThumIcon(texture2D);
  192. }
  193. }
  194. else
  195. {
  196. Debug.LogError(string.Concat(new string[]
  197. {
  198. "サブメイド[",
  199. characterStatus.firstName,
  200. "]のアイコンファイル[",
  201. characterStatus.iconFileName,
  202. "]が見つかりません"
  203. }));
  204. }
  205. if (!string.IsNullOrEmpty(characterStatus.thumbnailFileName))
  206. {
  207. Texture2D texture2D3 = ImportCM.CreateTexture(characterStatus.thumbnailFileName);
  208. if (texture2D3.format == TextureFormat.DXT1 || texture2D3.format == TextureFormat.DXT5)
  209. {
  210. Texture2D texture2D4 = new Texture2D(texture2D3.width, texture2D3.height, TextureFormat.ARGB32, false);
  211. texture2D4.SetPixels(texture2D3.GetPixels());
  212. texture2D4.Apply();
  213. UnityEngine.Object.Destroy(texture2D3);
  214. maid.SetThumCard(texture2D4);
  215. }
  216. else
  217. {
  218. maid.SetThumCard(texture2D3);
  219. }
  220. }
  221. else
  222. {
  223. Debug.LogError(string.Concat(new string[]
  224. {
  225. "サブメイド[",
  226. characterStatus.firstName,
  227. "]のアイコンファイル[",
  228. characterStatus.thumbnailFileName,
  229. "]が見つかりません"
  230. }));
  231. }
  232. }
  233. public readonly int id;
  234. public readonly string uniqueName;
  235. public readonly string replaceText;
  236. public readonly bool isEditPossible;
  237. public readonly SubMaid.Data.CharacterStatus status;
  238. public readonly SubMaid.Data.CharacterStatus secondStatus;
  239. public class CharacterStatus
  240. {
  241. public CharacterStatus(CsvParser basicCsv, int lineY)
  242. {
  243. int num = 4;
  244. this.lastName = basicCsv.GetCellAsString(num++, lineY);
  245. this.firstName = basicCsv.GetCellAsString(num++, lineY);
  246. this.presetName = Path.GetFileNameWithoutExtension(basicCsv.GetCellAsString(num++, lineY));
  247. this.iconFileName = Path.GetFileNameWithoutExtension(basicCsv.GetCellAsString(num++, lineY)) + ".tex";
  248. this.thumbnailFileName = Path.GetFileNameWithoutExtension(basicCsv.GetCellAsString(num++, lineY)) + ".tex";
  249. try
  250. {
  251. this.contract = (Contract)Enum.Parse(typeof(Contract), basicCsv.GetCellAsString(num++, lineY));
  252. }
  253. catch (Exception e)
  254. {
  255. NDebug.AssertParseError("Contract", e);
  256. }
  257. this.contractText = basicCsv.GetCellAsString(num++, lineY);
  258. this.personalText = basicCsv.GetCellAsString(num++, lineY);
  259. this.relationText = basicCsv.GetCellAsString(num++, lineY);
  260. try
  261. {
  262. this.initSeikeiken = (Seikeiken)Enum.Parse(typeof(Seikeiken), basicCsv.GetCellAsString(num++, lineY));
  263. }
  264. catch (Exception e2)
  265. {
  266. NDebug.AssertParseError("Seikeiken", e2);
  267. }
  268. this.jobClassText = JobClass.GetData(basicCsv.GetCellAsString(num++, lineY)).drawName;
  269. this.jobClassLevel = basicCsv.GetCellAsInteger(num++, lineY);
  270. this.yotogiClassText = basicCsv.GetCellAsString(num++, lineY);
  271. this.yotogiClassLevel = basicCsv.GetCellAsInteger(num++, lineY);
  272. this.likability = basicCsv.GetCellAsInteger(num++, lineY);
  273. this.lovely = basicCsv.GetCellAsInteger(num++, lineY);
  274. this.elegance = basicCsv.GetCellAsInteger(num++, lineY);
  275. this.charm = basicCsv.GetCellAsInteger(num++, lineY);
  276. this.care = basicCsv.GetCellAsInteger(num++, lineY);
  277. this.reception = basicCsv.GetCellAsInteger(num++, lineY);
  278. this.cooking = basicCsv.GetCellAsInteger(num++, lineY);
  279. this.dance = basicCsv.GetCellAsInteger(num++, lineY);
  280. this.vocal = basicCsv.GetCellAsInteger(num++, lineY);
  281. this.playCountNightWork = basicCsv.GetCellAsInteger(num++, lineY);
  282. this.hp = basicCsv.GetCellAsInteger(num++, lineY);
  283. this.mind = basicCsv.GetCellAsInteger(num++, lineY);
  284. this.inyoku = basicCsv.GetCellAsInteger(num++, lineY);
  285. this.mvalue = basicCsv.GetCellAsInteger(num++, lineY);
  286. this.hentai = basicCsv.GetCellAsInteger(num++, lineY);
  287. this.housi = basicCsv.GetCellAsInteger(num++, lineY);
  288. this.playCountYotogi = basicCsv.GetCellAsInteger(num++, lineY);
  289. }
  290. public readonly string lastName;
  291. public readonly string firstName;
  292. public readonly string presetName;
  293. public readonly string iconFileName;
  294. public readonly string thumbnailFileName;
  295. public readonly Contract contract;
  296. public readonly string contractText;
  297. public readonly string personalText;
  298. public readonly string relationText;
  299. public readonly Seikeiken initSeikeiken;
  300. public readonly string jobClassText;
  301. public readonly int jobClassLevel;
  302. public readonly string yotogiClassText;
  303. public readonly int yotogiClassLevel;
  304. public readonly int likability;
  305. public readonly int lovely;
  306. public readonly int elegance;
  307. public readonly int charm;
  308. public readonly int care;
  309. public readonly int reception;
  310. public readonly int cooking;
  311. public readonly int dance;
  312. public readonly int vocal;
  313. public readonly int playCountNightWork;
  314. public readonly int hp;
  315. public readonly int mind;
  316. public readonly int inyoku;
  317. public readonly int mvalue;
  318. public readonly int hentai;
  319. public readonly int housi;
  320. public readonly int playCountYotogi;
  321. }
  322. }
  323. }
  324. }