GameUty.cs 28 KB

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