GameUty.cs 26 KB

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