GameUty.cs 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using I2.Loc;
  8. using UnityEngine;
  9. using wf;
  10. public class GameUty
  11. {
  12. public static AFileSystemBase FileSystem
  13. {
  14. get
  15. {
  16. return GameUty.m_FileSystem;
  17. }
  18. }
  19. public static AFileSystemBase FileSystemOld
  20. {
  21. get
  22. {
  23. return GameUty.m_FileSystemOld;
  24. }
  25. }
  26. public static AFileSystemBase FileSystemMod
  27. {
  28. get
  29. {
  30. return GameUty.m_ModFileSystem;
  31. }
  32. }
  33. public static bool IsEnabledCompatibilityMode
  34. {
  35. get
  36. {
  37. return 0 < GameUty.PathListOld.Count;
  38. }
  39. }
  40. public static string[] MenuFiles
  41. {
  42. get
  43. {
  44. return GameUty.m_aryMenuFiles;
  45. }
  46. }
  47. public static string[] ModOnlysMenuFiles
  48. {
  49. get
  50. {
  51. return GameUty.m_aryModOnlysMenuFiles;
  52. }
  53. }
  54. public static Dictionary<int, string> RidMenuDic
  55. {
  56. get
  57. {
  58. return GameUty.rid_menu_dic_;
  59. }
  60. }
  61. public static Dictionary<string, AFileSystemBase> BgFiles { get; private set; }
  62. public static float MillisecondToSecond(int millisecond)
  63. {
  64. return (float)millisecond / 1000f;
  65. }
  66. public static Material GetSystemMaterial(GameUty.SystemMaterial f_mat)
  67. {
  68. Material material = GameUty.m_matSystem[(int)f_mat];
  69. if (material == null)
  70. {
  71. UnityEngine.Object original = Resources.Load(GameUty.m_strSystemMaterialName[(int)f_mat]);
  72. material = (UnityEngine.Object.Instantiate(original) as Material);
  73. GameUty.m_matSystem[(int)f_mat] = material;
  74. }
  75. return material;
  76. }
  77. public static GameObject LoadAssetBundle(string file_name)
  78. {
  79. if (GameUty.FileSystem == null || !GameUty.FileSystem.IsExistentFile(file_name))
  80. {
  81. return null;
  82. }
  83. UnityEngine.Object original = null;
  84. if (!GameUty.asset_bundle_dic.ContainsKey(file_name))
  85. {
  86. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(file_name))
  87. {
  88. AssetBundle assetBundle = AssetBundle.LoadFromMemory(afileBase.ReadAll());
  89. if (assetBundle.mainAsset != null)
  90. {
  91. original = assetBundle.mainAsset;
  92. }
  93. else
  94. {
  95. original = assetBundle.LoadAllAssets<GameObject>()[0];
  96. }
  97. GameUty.asset_bundle_dic.Add(file_name, assetBundle);
  98. }
  99. }
  100. else
  101. {
  102. original = GameUty.asset_bundle_dic[file_name].mainAsset;
  103. }
  104. GameObject gameObject = UnityEngine.Object.Instantiate(original) as GameObject;
  105. gameObject.name = gameObject.name.Replace("(Clone)", string.Empty);
  106. return gameObject;
  107. }
  108. public static void DeviceInitialize()
  109. {
  110. }
  111. public static void Init()
  112. {
  113. GameUty.m_FileSystem = new FileSystemArchive();
  114. GameUty.m_FileSystemOld = new FileSystemArchive();
  115. GameUty.PathListOld = new List<string>();
  116. if (!string.IsNullOrEmpty(GameMain.Instance.CMSystem.CM3D2Path))
  117. {
  118. GameUty.PathListOld = GameUty.ReadAutoPathFile("[2.0]", GameMain.Instance.CMSystem.CM3D2Path + "\\GameData\\paths.dat");
  119. if (GameUty.PathListOld == null)
  120. {
  121. GameUty.PathListOld = new List<string>();
  122. }
  123. }
  124. GameUty.UpdateFileSystemPath();
  125. GameUty.UpdateFileSystemPathOld();
  126. PluginData.CreateData(GameUty.m_FileSystem, (!GameUty.IsEnabledCompatibilityMode) ? null : GameUty.m_FileSystemOld);
  127. Debug.Log("■■■■■■■■ Plugin Check ■■■■■■■■");
  128. foreach (string text in PluginData.GetAllUniqueNames())
  129. {
  130. Debug.Log(string.Concat(new string[]
  131. {
  132. "[",
  133. PluginData.uniqueNameToId(text).ToString(),
  134. "]",
  135. text,
  136. " : ",
  137. (!PluginData.IsEnabled(text)) ? "×" : "○"
  138. }));
  139. }
  140. Debug.Log("■■■■■■■■■■■■■■■■■■■■");
  141. }
  142. public static void Finish()
  143. {
  144. foreach (KeyValuePair<string, AssetBundle> keyValuePair in GameUty.asset_bundle_dic)
  145. {
  146. keyValuePair.Value.Unload(true);
  147. }
  148. GameUty.asset_bundle_dic.Clear();
  149. GameUty.m_FileSystem.Dispose();
  150. GameUty.m_FileSystem = null;
  151. if (GameUty.m_FileSystemOld != null)
  152. {
  153. GameUty.m_FileSystemOld.Dispose();
  154. GameUty.m_FileSystemOld = null;
  155. }
  156. if (GameUty.m_ModFileSystem != null)
  157. {
  158. GameUty.m_ModFileSystem.Dispose();
  159. GameUty.m_ModFileSystem = null;
  160. }
  161. }
  162. public static Dictionary<string, HashSet<string>> GetGameDataResourceList(string gameDataPath)
  163. {
  164. string[] array = new string[]
  165. {
  166. "script_cbl",
  167. "motion_cbl",
  168. "voice_cbl"
  169. };
  170. int length = (gameDataPath + "\\").Length;
  171. string[] directories = Directory.GetDirectories(gameDataPath);
  172. Dictionary<string, HashSet<string>> dictionary = new Dictionary<string, HashSet<string>>();
  173. for (int i = 0; i < directories.Length; i++)
  174. {
  175. string text = directories[i].Substring(length, directories[i].Length - length).ToLower();
  176. int startIndex = 0;
  177. foreach (string text2 in array)
  178. {
  179. if (text.IndexOf(text2) == 0)
  180. {
  181. startIndex = text2.Length;
  182. break;
  183. }
  184. }
  185. int num = text.IndexOf('_', startIndex);
  186. if (0 <= num)
  187. {
  188. string text3 = text.Substring(0, num);
  189. if (!string.IsNullOrEmpty(text3))
  190. {
  191. string text4 = text.Substring(text3.Length + 1, text.Length - (text3.Length + 1));
  192. if (!string.IsNullOrEmpty(text4))
  193. {
  194. if (!dictionary.ContainsKey(text3))
  195. {
  196. dictionary.Add(text3, new HashSet<string>());
  197. }
  198. if (!dictionary[text3].Contains(text4))
  199. {
  200. dictionary[text3].Add(text4);
  201. }
  202. else
  203. {
  204. Debug.LogWarning(text3 + "_" + text4 + "は既にリストに存在します");
  205. }
  206. }
  207. }
  208. }
  209. else if (!dictionary.ContainsKey(text))
  210. {
  211. dictionary.Add(text, new HashSet<string>());
  212. }
  213. else
  214. {
  215. Debug.LogWarning(text + "は既にリストに存在します");
  216. }
  217. }
  218. return dictionary;
  219. }
  220. public static List<string> ReadAutoPathFile(string uniqueName, string filePath)
  221. {
  222. if (!File.Exists(filePath))
  223. {
  224. return null;
  225. }
  226. List<string> list = new List<string>();
  227. using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
  228. {
  229. using (BinaryReader binaryReader = new BinaryReader(fileStream))
  230. {
  231. string a = binaryReader.ReadString();
  232. NDebug.Assert(a == "CM3D2_PATHS", "パスファイルのヘッダーが不正です。");
  233. int num = binaryReader.ReadInt32();
  234. int num2 = binaryReader.ReadInt32();
  235. for (int i = 0; i < num2; i++)
  236. {
  237. string item = binaryReader.ReadString();
  238. list.Add(item);
  239. }
  240. }
  241. }
  242. return list;
  243. }
  244. public static void UpdateFileSystemPath()
  245. {
  246. string fullPath = Path.GetFullPath(".\\");
  247. string gameDataPath = "GameData";
  248. int check_ver_no = 3;
  249. Func<string, bool> AddFolderOrArchive = delegate(string name)
  250. {
  251. bool flag3 = GameUty.m_FileSystem.AddArchive(gameDataPath + "\\" + name + ".arc");
  252. if (flag3)
  253. {
  254. Debug.Log(string.Concat(new string[]
  255. {
  256. "[",
  257. gameDataPath,
  258. "\\",
  259. name,
  260. ".arc]を読み込みました"
  261. }));
  262. }
  263. return flag3;
  264. };
  265. HashSet<string> addedLegacyArchives = new HashSet<string>();
  266. Action<string> action = delegate(string name)
  267. {
  268. foreach (string text28 in GameUty.PathList)
  269. {
  270. string text29 = name + "_" + text28;
  271. bool flag3 = AddFolderOrArchive(text29);
  272. if (flag3 && !addedLegacyArchives.Contains(text29))
  273. {
  274. addedLegacyArchives.Add(text29);
  275. }
  276. if (flag3)
  277. {
  278. if (name == "csv")
  279. {
  280. GameUty.ExistCsvPathList.Add(text28);
  281. }
  282. for (int num14 = 2; num14 <= check_ver_no; num14++)
  283. {
  284. AddFolderOrArchive(text29 + "_" + num14);
  285. }
  286. }
  287. }
  288. };
  289. Action<string> action2 = delegate(string name)
  290. {
  291. foreach (string text28 in GameUty.PathList)
  292. {
  293. string text29 = name + "_" + text28;
  294. bool flag3 = AddFolderOrArchive(text29);
  295. if (!flag3 && addedLegacyArchives.Contains(text29))
  296. {
  297. flag3 = true;
  298. }
  299. if (flag3)
  300. {
  301. if (name == "csv")
  302. {
  303. GameUty.ExistCsvPathList.Add(text28);
  304. }
  305. for (int num14 = 2; num14 <= check_ver_no; num14++)
  306. {
  307. AddFolderOrArchive(string.Concat(new object[]
  308. {
  309. name,
  310. "_",
  311. text28,
  312. "_",
  313. num14
  314. }));
  315. }
  316. }
  317. }
  318. };
  319. Action<string> action3 = delegate(string name)
  320. {
  321. foreach (string text28 in GameUty.PathList)
  322. {
  323. if (AddFolderOrArchive(name + "_" + text28))
  324. {
  325. if (name == "csv")
  326. {
  327. GameUty.ExistCsvPathList.Add(text28);
  328. }
  329. for (int num14 = 2; num14 <= check_ver_no; num14++)
  330. {
  331. AddFolderOrArchive(string.Concat(new object[]
  332. {
  333. name,
  334. "_",
  335. text28,
  336. "_",
  337. num14
  338. }));
  339. }
  340. }
  341. }
  342. };
  343. string str = string.Empty;
  344. str = "必用アーカイブがありません。GameData\\";
  345. StopWatch stopWatch = new StopWatch();
  346. Debug.Log("IsEnabledCompatibilityMode:" + GameUty.IsEnabledCompatibilityMode.ToString());
  347. string text = "カスタムオーダーメイド3D 2";
  348. string str2 = "カスタムメイド3D 2";
  349. Debug.Log(string.Concat(new string[]
  350. {
  351. text,
  352. " GameVersion ",
  353. GameUty.GetGameVersionText(),
  354. "(BuildVersion : ",
  355. GameUty.GetBuildVersionText(),
  356. ")"
  357. }));
  358. if (!string.IsNullOrEmpty(GameMain.Instance.CMSystem.CM3D2Path))
  359. {
  360. Debug.Log(str2 + " GameVersion " + GameUty.GetLegacyGameVersionText());
  361. }
  362. if (GameUty.IsEnabledCompatibilityMode)
  363. {
  364. Debug.Log("■■■■■■■■ Archive Log[2.0] (CM3D2 GameData) ■■■■■■■■");
  365. GameUty.m_FileSystem.SetBaseDirectory(GameMain.Instance.CMSystem.CM3D2Path);
  366. GameUty.PathList = GameUty.PathListOld;
  367. AddFolderOrArchive("material");
  368. foreach (string text2 in GameUty.PathListOld)
  369. {
  370. string str3 = "material";
  371. if (text2 == "denkigai2015wTowelR")
  372. {
  373. AddFolderOrArchive(str3 + "_denkigai2015wTowel");
  374. }
  375. string text3 = str3 + "_" + text2;
  376. bool flag = AddFolderOrArchive(text3);
  377. if (flag && !addedLegacyArchives.Contains(text3))
  378. {
  379. addedLegacyArchives.Add(text3);
  380. }
  381. if (flag)
  382. {
  383. for (int i2 = 2; i2 <= check_ver_no; i2++)
  384. {
  385. AddFolderOrArchive(text3 + "_" + i2);
  386. }
  387. }
  388. }
  389. AddFolderOrArchive("material2");
  390. AddFolderOrArchive("menu");
  391. action("menu");
  392. AddFolderOrArchive("menu2");
  393. AddFolderOrArchive("model");
  394. action("model");
  395. AddFolderOrArchive("model2");
  396. AddFolderOrArchive("texture");
  397. action("texture");
  398. AddFolderOrArchive("texture2");
  399. AddFolderOrArchive("texture3");
  400. AddFolderOrArchive("prioritymaterial");
  401. Debug.Log("■■■■■■■■■■■■■■■■■■■■");
  402. }
  403. Debug.Log("■■■■■■■■ Archive Log[2.1 Compatibility] (GameData_20) ■■■■■■■■");
  404. gameDataPath = "GameData_20";
  405. GameUty.m_FileSystem.SetBaseDirectory(fullPath);
  406. if (GameUty.IsEnabledCompatibilityMode)
  407. {
  408. GameUty.m_FileSystem.AddPatchDecryptPreferredSearchDirectory(GameMain.Instance.CMSystem.CM3D2Path + "\\GameData");
  409. }
  410. GameUty.PathList = GameUty.ReadAutoPathFile("[2.1Compatibility]", fullPath + gameDataPath + "\\paths.dat");
  411. if (GameUty.PathList != null && 0 < GameUty.PathList.Count)
  412. {
  413. foreach (string text4 in GameUty.PathList)
  414. {
  415. string text5 = "material";
  416. if (text4 == "denkigai2015wTowelR")
  417. {
  418. AddFolderOrArchive(text5 + "_denkigai2015wTowel");
  419. }
  420. string text6 = text5 + "_" + text4;
  421. bool flag2 = AddFolderOrArchive(text6);
  422. if (!flag2 && addedLegacyArchives.Contains(text6))
  423. {
  424. flag2 = true;
  425. }
  426. if (flag2)
  427. {
  428. for (int j = 2; j <= check_ver_no; j++)
  429. {
  430. AddFolderOrArchive(string.Concat(new object[]
  431. {
  432. text5,
  433. "_",
  434. text4,
  435. "_",
  436. j
  437. }));
  438. }
  439. }
  440. }
  441. action2("menu");
  442. action2("model");
  443. action2("texture");
  444. AddFolderOrArchive("prioritymaterial");
  445. List<string> pathList = GameUty.PathList;
  446. GameUty.PathList = new List<string>();
  447. GameUty.PathList.Add("vp001");
  448. action2("bg");
  449. action2("motion");
  450. GameUty.PathList = pathList;
  451. }
  452. GameUty.m_FileSystem.ClearPatchDecryptPreferredSearchDirectory();
  453. Debug.Log("■■■■■■■■■■■■■■■■■■■■");
  454. Debug.Log("■■■■■■■■ Archive Log[2.1] (GameData) ■■■■■■■■");
  455. gameDataPath = "GameData";
  456. GameUty.PathList = GameUty.ReadAutoPathFile("[2.1]", fullPath + gameDataPath + "\\paths.dat");
  457. if (GameUty.PathList == null)
  458. {
  459. GameUty.PathList = new List<string>();
  460. NDebug.Assert("paths.datを読み込めませんでした", false);
  461. }
  462. AddFolderOrArchive("csv");
  463. foreach (string text7 in GameUty.PathList)
  464. {
  465. string text8 = "csv";
  466. if (AddFolderOrArchive(text8 + "_" + text7))
  467. {
  468. for (int k = 2; k <= check_ver_no; k++)
  469. {
  470. AddFolderOrArchive(string.Concat(new object[]
  471. {
  472. text8,
  473. "_",
  474. text7,
  475. "_",
  476. k
  477. }));
  478. }
  479. }
  480. }
  481. AddFolderOrArchive("prioritymaterial");
  482. NDebug.Assert(AddFolderOrArchive("motion"), str + "motion");
  483. foreach (string text9 in GameUty.PathList)
  484. {
  485. string text10 = "motion";
  486. if (AddFolderOrArchive(text10 + "_" + text9))
  487. {
  488. for (int l = 2; l <= check_ver_no; l++)
  489. {
  490. AddFolderOrArchive(string.Concat(new object[]
  491. {
  492. text10,
  493. "_",
  494. text9,
  495. "_",
  496. l
  497. }));
  498. }
  499. }
  500. }
  501. AddFolderOrArchive("motion2");
  502. NDebug.Assert(AddFolderOrArchive("script"), str + "script");
  503. foreach (string text11 in GameUty.PathList)
  504. {
  505. string text12 = "script";
  506. if (AddFolderOrArchive(text12 + "_" + text11))
  507. {
  508. for (int m = 2; m <= check_ver_no; m++)
  509. {
  510. AddFolderOrArchive(string.Concat(new object[]
  511. {
  512. text12,
  513. "_",
  514. text11,
  515. "_",
  516. m
  517. }));
  518. }
  519. }
  520. }
  521. AddFolderOrArchive("script_share");
  522. foreach (string text13 in GameUty.PathList)
  523. {
  524. string text14 = "script_share";
  525. if (AddFolderOrArchive(text14 + "_" + text13))
  526. {
  527. for (int n = 2; n <= check_ver_no; n++)
  528. {
  529. AddFolderOrArchive(string.Concat(new object[]
  530. {
  531. text14,
  532. "_",
  533. text13,
  534. "_",
  535. n
  536. }));
  537. }
  538. }
  539. }
  540. AddFolderOrArchive("script_share2");
  541. NDebug.Assert(AddFolderOrArchive("sound"), str + "sound");
  542. foreach (string text15 in GameUty.PathList)
  543. {
  544. string text16 = "sound";
  545. if (AddFolderOrArchive(text16 + "_" + text15))
  546. {
  547. for (int num = 2; num <= check_ver_no; num++)
  548. {
  549. AddFolderOrArchive(string.Concat(new object[]
  550. {
  551. text16,
  552. "_",
  553. text15,
  554. "_",
  555. num
  556. }));
  557. }
  558. }
  559. }
  560. AddFolderOrArchive("sound2");
  561. NDebug.Assert(AddFolderOrArchive("system"), str + "system");
  562. foreach (string text17 in GameUty.PathList)
  563. {
  564. string text18 = "system";
  565. if (AddFolderOrArchive(text18 + "_" + text17))
  566. {
  567. for (int num2 = 2; num2 <= check_ver_no; num2++)
  568. {
  569. AddFolderOrArchive(string.Concat(new object[]
  570. {
  571. text18,
  572. "_",
  573. text17,
  574. "_",
  575. num2
  576. }));
  577. }
  578. }
  579. }
  580. AddFolderOrArchive("system2");
  581. AddFolderOrArchive("language");
  582. foreach (string text19 in GameUty.PathList)
  583. {
  584. string text20 = "language";
  585. if (AddFolderOrArchive(text20 + "_" + text19))
  586. {
  587. for (int num3 = 2; num3 <= check_ver_no; num3++)
  588. {
  589. AddFolderOrArchive(string.Concat(new object[]
  590. {
  591. text20,
  592. "_",
  593. text19,
  594. "_",
  595. num3
  596. }));
  597. }
  598. }
  599. }
  600. foreach (string text21 in GameUty.PathList)
  601. {
  602. string text22 = "bg";
  603. if (AddFolderOrArchive(text22 + "_" + text21))
  604. {
  605. for (int num4 = 2; num4 <= check_ver_no; num4++)
  606. {
  607. AddFolderOrArchive(string.Concat(new object[]
  608. {
  609. text22,
  610. "_",
  611. text21,
  612. "_",
  613. num4
  614. }));
  615. }
  616. }
  617. }
  618. AddFolderOrArchive("voice");
  619. for (int num5 = 0; num5 < 25; num5++)
  620. {
  621. string arg = "voice";
  622. string arg2 = arg + "_" + (char)(97 + num5);
  623. AddFolderOrArchive(arg2);
  624. }
  625. foreach (string text23 in GameUty.PathList)
  626. {
  627. string text24 = "voice";
  628. if (AddFolderOrArchive(text24 + "_" + text23))
  629. {
  630. for (int num6 = 2; num6 <= check_ver_no; num6++)
  631. {
  632. AddFolderOrArchive(string.Concat(new object[]
  633. {
  634. text24,
  635. "_",
  636. text23,
  637. "_",
  638. num6
  639. }));
  640. }
  641. }
  642. }
  643. for (int num7 = 2; num7 <= check_ver_no; num7++)
  644. {
  645. string arg3 = "voice";
  646. AddFolderOrArchive(arg3 + num7);
  647. }
  648. string text25 = "parts";
  649. NDebug.Assert(AddFolderOrArchive(text25), str + text25);
  650. foreach (string text26 in GameUty.PathList)
  651. {
  652. if (AddFolderOrArchive(text25 + "_" + text26))
  653. {
  654. for (int num8 = 2; num8 <= check_ver_no; num8++)
  655. {
  656. AddFolderOrArchive(string.Concat(new object[]
  657. {
  658. text25,
  659. "_",
  660. text26,
  661. "_",
  662. num8
  663. }));
  664. }
  665. }
  666. }
  667. AddFolderOrArchive("parts2");
  668. Debug.Log("■■■■■■■■■■■■■■■■■■■■" + stopWatch.Stop().ToString() + " ms");
  669. GameUty.m_FileSystem.AddAutoPathForAllFolder();
  670. GameUty.BgFiles = new Dictionary<string, AFileSystemBase>();
  671. string[] list = GameUty.m_FileSystem.GetList("bg", AFileSystemBase.ListType.AllFile);
  672. if (list != null && 0 < list.Length)
  673. {
  674. foreach (string path in list)
  675. {
  676. string fileName = Path.GetFileName(path);
  677. if (!(Path.GetExtension(fileName) != ".asset_bg") && !GameUty.BgFiles.ContainsKey(fileName))
  678. {
  679. GameUty.BgFiles.Add(fileName, GameUty.m_FileSystem);
  680. }
  681. }
  682. }
  683. list = GameUty.m_FileSystem.GetList("languagesource", AFileSystemBase.ListType.AllFile);
  684. if (list != null && 0 < list.Length)
  685. {
  686. foreach (string path2 in list)
  687. {
  688. string fileName2 = Path.GetFileName(path2);
  689. if (!(Path.GetExtension(fileName2) != ".asset_language"))
  690. {
  691. if (!(fileName2 == "parts.asset_language"))
  692. {
  693. using (AFileBase afileBase = GameUty.m_FileSystem.FileOpen(fileName2))
  694. {
  695. AssetBundle assetBundle = AssetBundle.LoadFromMemory(afileBase.ReadAll());
  696. LanguageSource languageSource = UnityEngine.Object.Instantiate<LanguageSource>(assetBundle.LoadAllAssets<GameObject>()[0].GetComponent<LanguageSource>());
  697. if (GameMain.Instance.transform.Find("Language") == null)
  698. {
  699. new GameObject("Language").transform.SetParent(GameMain.Instance.transform);
  700. }
  701. languageSource.transform.SetParent(GameMain.Instance.transform.Find("Language"));
  702. assetBundle.Unload(true);
  703. }
  704. }
  705. }
  706. }
  707. }
  708. if (Directory.Exists(fullPath + "Mod"))
  709. {
  710. GameUty.m_ModFileSystem = new FileSystemWindows();
  711. GameUty.m_ModFileSystem.SetBaseDirectory(fullPath);
  712. GameUty.m_ModFileSystem.AddFolder("Mod");
  713. string[] list2 = GameUty.m_ModFileSystem.GetList(string.Empty, AFileSystemBase.ListType.AllFolder);
  714. foreach (string text27 in list2)
  715. {
  716. if (!GameUty.m_ModFileSystem.AddAutoPath(text27))
  717. {
  718. Debug.Log("m_ModFileSystemのAddAutoPathには既に " + text27 + " がありました。");
  719. }
  720. }
  721. }
  722. string[] fileListAtExtension = GameUty.m_FileSystem.GetFileListAtExtension(".menu");
  723. List<string> list3 = new List<string>();
  724. foreach (string path3 in fileListAtExtension)
  725. {
  726. list3.Add(Path.GetFileName(path3));
  727. }
  728. GameUty.m_aryMenuFiles = list3.ToArray();
  729. if (GameUty.m_ModFileSystem != null)
  730. {
  731. string[] list4 = GameUty.m_ModFileSystem.GetList(string.Empty, AFileSystemBase.ListType.AllFile);
  732. GameUty.m_aryModOnlysMenuFiles = Array.FindAll<string>(list4, (string i) => new Regex(".*\\.menu$").IsMatch(i));
  733. GameUty.m_aryMenuFiles = GameUty.m_aryMenuFiles.Concat(GameUty.m_aryModOnlysMenuFiles).ToArray<string>();
  734. }
  735. if (GameUty.m_aryModOnlysMenuFiles != null && GameUty.m_aryModOnlysMenuFiles.Length != 0)
  736. {
  737. GameUty.ModPriorityToModFolderInfo = string.Empty;
  738. Debug.Log(GameUty.ModPriorityToModFolderInfo + "■MOD有り。MODフォルダ優先モード" + GameUty.ModPriorityToModFolder.ToString());
  739. }
  740. if (GameUty.rid_menu_dic_.Count == 0)
  741. {
  742. string[] menuFiles = GameUty.MenuFiles;
  743. GameUty.rid_menu_dic_ = new Dictionary<int, string>();
  744. for (int num13 = 0; num13 < menuFiles.Length; num13++)
  745. {
  746. string fileName3 = Path.GetFileName(menuFiles[num13]);
  747. int hashCode = fileName3.ToLower().GetHashCode();
  748. if (!GameUty.rid_menu_dic_.ContainsKey(hashCode))
  749. {
  750. GameUty.rid_menu_dic_.Add(hashCode, fileName3);
  751. }
  752. else
  753. {
  754. NDebug.Assert(fileName3 == GameUty.rid_menu_dic_[hashCode], string.Concat(new string[]
  755. {
  756. "[",
  757. fileName3,
  758. "]と[",
  759. GameUty.rid_menu_dic_[hashCode],
  760. "]は同じハッシュキーです"
  761. }));
  762. }
  763. }
  764. }
  765. }
  766. public static void UpdateFileSystemPathOld()
  767. {
  768. if (!GameUty.IsEnabledCompatibilityMode)
  769. {
  770. return;
  771. }
  772. FileSystemArchive fileSystem = GameUty.m_FileSystemOld;
  773. Debug.Log("■■■■■■■■ Archive Log[Legacy]■■■■■■■■");
  774. Func<string, bool> AddFolderOrArchive = delegate(string name)
  775. {
  776. bool flag = fileSystem.AddArchive("GameData\\" + name + ".arc");
  777. if (flag)
  778. {
  779. Debug.Log("[GameData\\" + name + ".arc]を読み込みました");
  780. }
  781. return flag;
  782. };
  783. int check_ver_no = 3;
  784. Action<string> action = delegate(string name)
  785. {
  786. foreach (string text2 in GameUty.PathListOld)
  787. {
  788. if (AddFolderOrArchive(name + "_" + text2))
  789. {
  790. if (name == "csv")
  791. {
  792. GameUty.ExistCsvPathListOld.Add(text2);
  793. }
  794. for (int m = 2; m <= check_ver_no; m++)
  795. {
  796. AddFolderOrArchive(string.Concat(new object[]
  797. {
  798. name,
  799. "_",
  800. text2,
  801. "_",
  802. m
  803. }));
  804. }
  805. }
  806. }
  807. };
  808. fileSystem.SetBaseDirectory(GameMain.Instance.CMSystem.CM3D2Path);
  809. AddFolderOrArchive("csv");
  810. action("csv");
  811. AddFolderOrArchive("motion");
  812. action("motion");
  813. AddFolderOrArchive("motion2");
  814. AddFolderOrArchive("script");
  815. action("script");
  816. action("script_share");
  817. AddFolderOrArchive("script_share2");
  818. AddFolderOrArchive("sound");
  819. action("sound");
  820. AddFolderOrArchive("sound2");
  821. AddFolderOrArchive("texture");
  822. action("texture");
  823. AddFolderOrArchive("texture2");
  824. AddFolderOrArchive("texture3");
  825. AddFolderOrArchive("system");
  826. action("system");
  827. action("bg");
  828. AddFolderOrArchive("voice");
  829. AddFolderOrArchive("voice_a");
  830. AddFolderOrArchive("voice_b");
  831. AddFolderOrArchive("voice_c");
  832. foreach (string str in GameUty.PathListOld)
  833. {
  834. string str2 = "voice";
  835. string text = str2 + "_" + str;
  836. if (AddFolderOrArchive(text))
  837. {
  838. for (int i = 2; i <= check_ver_no; i++)
  839. {
  840. AddFolderOrArchive(text + "_" + i);
  841. }
  842. }
  843. text = str2 + "_" + str + "a";
  844. if (AddFolderOrArchive(text))
  845. {
  846. for (int j = 2; j <= check_ver_no; j++)
  847. {
  848. AddFolderOrArchive(text + "_" + j);
  849. }
  850. }
  851. text = str2 + "_" + str + "b";
  852. if (AddFolderOrArchive(text))
  853. {
  854. for (int k = 2; k <= check_ver_no; k++)
  855. {
  856. AddFolderOrArchive(text + "_" + k);
  857. }
  858. }
  859. }
  860. AddFolderOrArchive("voice2");
  861. AddFolderOrArchive("voice3");
  862. fileSystem.AddAutoPathForAllFolder();
  863. string[] list = fileSystem.GetList("bg", AFileSystemBase.ListType.AllFile);
  864. if (list != null && 0 < list.Length)
  865. {
  866. foreach (string path in list)
  867. {
  868. string fileName = Path.GetFileName(path);
  869. if (!(Path.GetExtension(fileName) != ".asset_bg") && !GameUty.BgFiles.ContainsKey(fileName))
  870. {
  871. GameUty.BgFiles.Add(fileName, fileSystem);
  872. }
  873. }
  874. }
  875. Debug.Log("■■■■■■■■■■■■■■■■■■■■");
  876. }
  877. public static AFileBase FileOpen(string fileName, AFileSystemBase priorityFileSystem = null)
  878. {
  879. if (priorityFileSystem == null)
  880. {
  881. priorityFileSystem = GameUty.m_FileSystem;
  882. }
  883. AFileSystemBase[] array;
  884. if (GameUty.ModPriorityToModFolder)
  885. {
  886. array = new AFileSystemBase[]
  887. {
  888. GameUty.m_ModFileSystem,
  889. priorityFileSystem
  890. };
  891. }
  892. else
  893. {
  894. array = new AFileSystemBase[]
  895. {
  896. priorityFileSystem,
  897. GameUty.m_ModFileSystem
  898. };
  899. }
  900. AFileBase result = null;
  901. foreach (AFileSystemBase afileSystemBase in array)
  902. {
  903. if (afileSystemBase != null && afileSystemBase.IsExistentFile(fileName))
  904. {
  905. result = afileSystemBase.FileOpen(fileName);
  906. break;
  907. }
  908. }
  909. return result;
  910. }
  911. public static bool IsExistFile(string fileName, AFileSystemBase priorityFileSystem = null)
  912. {
  913. if (priorityFileSystem == null)
  914. {
  915. priorityFileSystem = GameUty.m_FileSystem;
  916. }
  917. AFileSystemBase[] array;
  918. if (GameUty.ModPriorityToModFolder)
  919. {
  920. array = new AFileSystemBase[]
  921. {
  922. GameUty.m_ModFileSystem,
  923. priorityFileSystem
  924. };
  925. }
  926. else
  927. {
  928. array = new AFileSystemBase[]
  929. {
  930. priorityFileSystem,
  931. GameUty.m_ModFileSystem
  932. };
  933. }
  934. foreach (AFileSystemBase afileSystemBase in array)
  935. {
  936. if (afileSystemBase != null && afileSystemBase.IsExistentFile(fileName))
  937. {
  938. return true;
  939. }
  940. }
  941. return false;
  942. }
  943. public static string GetBuildVersionText()
  944. {
  945. int num = 1210;
  946. return (num >= 1000) ? ((float)num / 1000f).ToString("F2") : ((float)num / 100f).ToString("F2");
  947. }
  948. public static string GetGameVersionText()
  949. {
  950. string text = "COM3D2x64.exe";
  951. int num = 1210;
  952. string path = Path.GetFullPath(".\\") + "update.lst";
  953. string[] array = new string[0];
  954. if (File.Exists(path))
  955. {
  956. try
  957. {
  958. array = File.ReadAllLines(path, Encoding.GetEncoding("utf-8"));
  959. }
  960. catch (Exception ex)
  961. {
  962. Debug.LogError(ex.Message);
  963. array = new string[0];
  964. }
  965. }
  966. foreach (string text2 in array)
  967. {
  968. if (!string.IsNullOrEmpty(text2))
  969. {
  970. string[] array3 = text2.Split(new char[]
  971. {
  972. ','
  973. });
  974. if (array3 != null && array3.Length == 2 && array3[0].Trim().ToLower() == text.ToLower())
  975. {
  976. int.TryParse(array3[1].Trim(), out num);
  977. break;
  978. }
  979. }
  980. }
  981. string text3 = (num >= 1000) ? ((float)num / 1000f).ToString("F3") : ((float)num / 100f).ToString("F3");
  982. if (text3.Length == 5)
  983. {
  984. text3 = text3.Insert(4, ".");
  985. }
  986. return text3;
  987. }
  988. public static string GetLegacyGameVersionText()
  989. {
  990. if (!GameUty.IsEnabledCompatibilityMode)
  991. {
  992. return "0.0";
  993. }
  994. string text = "CM3D2x64.exe";
  995. string path = GameMain.Instance.CMSystem.CM3D2Path + "\\update.lst";
  996. string[] array = new string[0];
  997. if (File.Exists(path))
  998. {
  999. try
  1000. {
  1001. array = File.ReadAllLines(path, Encoding.GetEncoding("utf-8"));
  1002. }
  1003. catch (Exception ex)
  1004. {
  1005. Debug.LogError(ex.Message);
  1006. array = new string[0];
  1007. }
  1008. }
  1009. int num = 0;
  1010. foreach (string text2 in array)
  1011. {
  1012. if (!string.IsNullOrEmpty(text2))
  1013. {
  1014. string[] array3 = text2.Split(new char[]
  1015. {
  1016. ','
  1017. });
  1018. if (array3 != null && array3.Length == 2 && array3 != null && array3.Length == 2 && array3[0].Trim().ToLower() == text.ToLower())
  1019. {
  1020. int.TryParse(array3[1].Trim(), out num);
  1021. break;
  1022. }
  1023. }
  1024. }
  1025. string text3 = (num >= 1000) ? ((float)num / 1000f).ToString("F3") : ((float)num / 100f).ToString("F3");
  1026. if (text3.Length == 5)
  1027. {
  1028. text3 = text3.Insert(4, ".");
  1029. }
  1030. return text3;
  1031. }
  1032. private static FileSystemArchive m_FileSystem = null;
  1033. private static FileSystemArchive m_FileSystemOld = null;
  1034. private static FileSystemWindows m_ModFileSystem = null;
  1035. public static List<string> PathList = new List<string>();
  1036. public static List<string> ExistCsvPathList = new List<string>();
  1037. public static List<string> PathListOld = new List<string>();
  1038. public static List<string> ExistCsvPathListOld = new List<string>();
  1039. private static string[] m_aryMenuFiles = null;
  1040. private static string[] m_aryModOnlysMenuFiles = new string[0];
  1041. private static Dictionary<int, string> rid_menu_dic_ = new Dictionary<int, string>();
  1042. private static Dictionary<string, AssetBundle> asset_bundle_dic = new Dictionary<string, AssetBundle>();
  1043. private static string ModPriorityToModFolderInfo = "以下のフラグをtrueにするとMODフォルダのファイルが優先されるが、モザイクも安易に外すことが可能になる為に現在はオミット。";
  1044. public static bool ModPriorityToModFolder = false;
  1045. private static string[] m_strSystemMaterialName = new string[]
  1046. {
  1047. "System/Material/2dAlpha",
  1048. "System/Material/2dMultiply",
  1049. "System/Material/InfinityColor",
  1050. "System/Material/TexTo8bitTex"
  1051. };
  1052. private static Material[] m_matSystem = new Material[4];
  1053. public enum SystemMaterial
  1054. {
  1055. Alpha,
  1056. Multiply,
  1057. InfinityColor,
  1058. TexTo8bitTex,
  1059. Max
  1060. }
  1061. }