SubMaid.cs 13 KB

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