GameUty.cs 28 KB

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