GameUty.cs 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  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. }
  445. GameUty.m_FileSystem.ClearPatchDecryptPreferredSearchDirectory();
  446. Debug.Log("■■■■■■■■■■■■■■■■■■■■");
  447. Debug.Log("■■■■■■■■ Archive Log[2.1] (GameData) ■■■■■■■■");
  448. gameDataPath = "GameData";
  449. GameUty.PathList = GameUty.ReadAutoPathFile("[2.1]", fullPath + gameDataPath + "\\paths.dat");
  450. if (GameUty.PathList == null)
  451. {
  452. GameUty.PathList = new List<string>();
  453. NDebug.Assert("paths.datを読み込めませんでした", false);
  454. }
  455. AddFolderOrArchive("csv");
  456. foreach (string text7 in GameUty.PathList)
  457. {
  458. string text8 = "csv";
  459. if (AddFolderOrArchive(text8 + "_" + text7))
  460. {
  461. for (int k = 2; k <= check_ver_no; k++)
  462. {
  463. AddFolderOrArchive(string.Concat(new object[]
  464. {
  465. text8,
  466. "_",
  467. text7,
  468. "_",
  469. k
  470. }));
  471. }
  472. }
  473. }
  474. AddFolderOrArchive("prioritymaterial");
  475. NDebug.Assert(AddFolderOrArchive("motion"), str + "motion");
  476. foreach (string text9 in GameUty.PathList)
  477. {
  478. string text10 = "motion";
  479. if (AddFolderOrArchive(text10 + "_" + text9))
  480. {
  481. for (int l = 2; l <= check_ver_no; l++)
  482. {
  483. AddFolderOrArchive(string.Concat(new object[]
  484. {
  485. text10,
  486. "_",
  487. text9,
  488. "_",
  489. l
  490. }));
  491. }
  492. }
  493. }
  494. AddFolderOrArchive("motion2");
  495. NDebug.Assert(AddFolderOrArchive("script"), str + "script");
  496. foreach (string text11 in GameUty.PathList)
  497. {
  498. string text12 = "script";
  499. if (AddFolderOrArchive(text12 + "_" + text11))
  500. {
  501. for (int m = 2; m <= check_ver_no; m++)
  502. {
  503. AddFolderOrArchive(string.Concat(new object[]
  504. {
  505. text12,
  506. "_",
  507. text11,
  508. "_",
  509. m
  510. }));
  511. }
  512. }
  513. }
  514. AddFolderOrArchive("script_share");
  515. foreach (string text13 in GameUty.PathList)
  516. {
  517. string text14 = "script_share";
  518. if (AddFolderOrArchive(text14 + "_" + text13))
  519. {
  520. for (int n = 2; n <= check_ver_no; n++)
  521. {
  522. AddFolderOrArchive(string.Concat(new object[]
  523. {
  524. text14,
  525. "_",
  526. text13,
  527. "_",
  528. n
  529. }));
  530. }
  531. }
  532. }
  533. AddFolderOrArchive("script_share2");
  534. NDebug.Assert(AddFolderOrArchive("sound"), str + "sound");
  535. foreach (string text15 in GameUty.PathList)
  536. {
  537. string text16 = "sound";
  538. if (AddFolderOrArchive(text16 + "_" + text15))
  539. {
  540. for (int num = 2; num <= check_ver_no; num++)
  541. {
  542. AddFolderOrArchive(string.Concat(new object[]
  543. {
  544. text16,
  545. "_",
  546. text15,
  547. "_",
  548. num
  549. }));
  550. }
  551. }
  552. }
  553. AddFolderOrArchive("sound2");
  554. NDebug.Assert(AddFolderOrArchive("system"), str + "system");
  555. foreach (string text17 in GameUty.PathList)
  556. {
  557. string text18 = "system";
  558. if (AddFolderOrArchive(text18 + "_" + text17))
  559. {
  560. for (int num2 = 2; num2 <= check_ver_no; num2++)
  561. {
  562. AddFolderOrArchive(string.Concat(new object[]
  563. {
  564. text18,
  565. "_",
  566. text17,
  567. "_",
  568. num2
  569. }));
  570. }
  571. }
  572. }
  573. AddFolderOrArchive("system2");
  574. foreach (string text19 in GameUty.PathList)
  575. {
  576. string text20 = "bg";
  577. if (AddFolderOrArchive(text20 + "_" + text19))
  578. {
  579. for (int num3 = 2; num3 <= check_ver_no; num3++)
  580. {
  581. AddFolderOrArchive(string.Concat(new object[]
  582. {
  583. text20,
  584. "_",
  585. text19,
  586. "_",
  587. num3
  588. }));
  589. }
  590. }
  591. }
  592. AddFolderOrArchive("voice");
  593. for (int num4 = 0; num4 < 25; num4++)
  594. {
  595. string arg = "voice";
  596. string arg2 = arg + "_" + (char)(97 + num4);
  597. AddFolderOrArchive(arg2);
  598. }
  599. foreach (string text21 in GameUty.PathList)
  600. {
  601. string text22 = "voice";
  602. if (AddFolderOrArchive(text22 + "_" + text21))
  603. {
  604. for (int num5 = 2; num5 <= check_ver_no; num5++)
  605. {
  606. AddFolderOrArchive(string.Concat(new object[]
  607. {
  608. text22,
  609. "_",
  610. text21,
  611. "_",
  612. num5
  613. }));
  614. }
  615. }
  616. }
  617. for (int num6 = 2; num6 <= check_ver_no; num6++)
  618. {
  619. string arg3 = "voice";
  620. AddFolderOrArchive(arg3 + num6);
  621. }
  622. string text23 = "parts";
  623. NDebug.Assert(AddFolderOrArchive(text23), str + text23);
  624. foreach (string text24 in GameUty.PathList)
  625. {
  626. if (AddFolderOrArchive(text23 + "_" + text24))
  627. {
  628. for (int num7 = 2; num7 <= check_ver_no; num7++)
  629. {
  630. AddFolderOrArchive(string.Concat(new object[]
  631. {
  632. text23,
  633. "_",
  634. text24,
  635. "_",
  636. num7
  637. }));
  638. }
  639. }
  640. }
  641. AddFolderOrArchive("parts2");
  642. Debug.Log("■■■■■■■■■■■■■■■■■■■■" + stopWatch.Stop().ToString() + " ms");
  643. GameUty.m_FileSystem.AddAutoPathForAllFolder();
  644. GameUty.BgFiles = new Dictionary<string, AFileSystemBase>();
  645. string[] list = GameUty.m_FileSystem.GetList("bg", AFileSystemBase.ListType.AllFile);
  646. if (list != null && 0 < list.Length)
  647. {
  648. foreach (string path in list)
  649. {
  650. string fileName = Path.GetFileName(path);
  651. if (!(Path.GetExtension(fileName) != ".asset_bg") && !GameUty.BgFiles.ContainsKey(fileName))
  652. {
  653. GameUty.BgFiles.Add(fileName, GameUty.m_FileSystem);
  654. }
  655. }
  656. }
  657. if (Directory.Exists(fullPath + "Mod"))
  658. {
  659. GameUty.m_ModFileSystem = new FileSystemWindows();
  660. GameUty.m_ModFileSystem.SetBaseDirectory(fullPath);
  661. GameUty.m_ModFileSystem.AddFolder("Mod");
  662. string[] list2 = GameUty.m_ModFileSystem.GetList(string.Empty, AFileSystemBase.ListType.AllFolder);
  663. foreach (string text25 in list2)
  664. {
  665. if (!GameUty.m_ModFileSystem.AddAutoPath(text25))
  666. {
  667. Debug.Log("m_ModFileSystemのAddAutoPathには既に " + text25 + " がありました。");
  668. }
  669. }
  670. }
  671. string[] fileListAtExtension = GameUty.m_FileSystem.GetFileListAtExtension(".menu");
  672. List<string> list3 = new List<string>();
  673. foreach (string path2 in fileListAtExtension)
  674. {
  675. list3.Add(Path.GetFileName(path2));
  676. }
  677. GameUty.m_aryMenuFiles = list3.ToArray();
  678. if (GameUty.m_ModFileSystem != null)
  679. {
  680. string[] list4 = GameUty.m_ModFileSystem.GetList(string.Empty, AFileSystemBase.ListType.AllFile);
  681. GameUty.m_aryModOnlysMenuFiles = Array.FindAll<string>(list4, (string i) => new Regex(".*\\.menu$").IsMatch(i));
  682. GameUty.m_aryMenuFiles = GameUty.m_aryMenuFiles.Concat(GameUty.m_aryModOnlysMenuFiles).ToArray<string>();
  683. }
  684. if (GameUty.m_aryModOnlysMenuFiles != null && GameUty.m_aryModOnlysMenuFiles.Length != 0)
  685. {
  686. GameUty.ModPriorityToModFolderInfo = string.Empty;
  687. Debug.Log(GameUty.ModPriorityToModFolderInfo + "■MOD有り。MODフォルダ優先モード" + GameUty.ModPriorityToModFolder.ToString());
  688. }
  689. if (GameUty.rid_menu_dic_.Count == 0)
  690. {
  691. string[] menuFiles = GameUty.MenuFiles;
  692. GameUty.rid_menu_dic_ = new Dictionary<int, string>();
  693. for (int num11 = 0; num11 < menuFiles.Length; num11++)
  694. {
  695. string fileName2 = Path.GetFileName(menuFiles[num11]);
  696. int hashCode = fileName2.ToLower().GetHashCode();
  697. if (!GameUty.rid_menu_dic_.ContainsKey(hashCode))
  698. {
  699. GameUty.rid_menu_dic_.Add(hashCode, fileName2);
  700. }
  701. else
  702. {
  703. NDebug.Assert(fileName2 == GameUty.rid_menu_dic_[hashCode], string.Concat(new string[]
  704. {
  705. "[",
  706. fileName2,
  707. "]と[",
  708. GameUty.rid_menu_dic_[hashCode],
  709. "]は同じハッシュキーです"
  710. }));
  711. }
  712. }
  713. }
  714. }
  715. public static void UpdateFileSystemPathOld()
  716. {
  717. if (!GameUty.IsEnabledCompatibilityMode)
  718. {
  719. return;
  720. }
  721. FileSystemArchive fileSystem = GameUty.m_FileSystemOld;
  722. Debug.Log("■■■■■■■■ Archive Log[Legacy]■■■■■■■■");
  723. Func<string, bool> AddFolderOrArchive = delegate(string name)
  724. {
  725. bool flag = fileSystem.AddArchive("GameData\\" + name + ".arc");
  726. if (flag)
  727. {
  728. Debug.Log("[GameData\\" + name + ".arc]を読み込みました");
  729. }
  730. return flag;
  731. };
  732. int check_ver_no = 3;
  733. Action<string> action = delegate(string name)
  734. {
  735. foreach (string text2 in GameUty.PathListOld)
  736. {
  737. if (AddFolderOrArchive(name + "_" + text2))
  738. {
  739. if (name == "csv")
  740. {
  741. GameUty.ExistCsvPathListOld.Add(text2);
  742. }
  743. for (int m = 2; m <= check_ver_no; m++)
  744. {
  745. AddFolderOrArchive(string.Concat(new object[]
  746. {
  747. name,
  748. "_",
  749. text2,
  750. "_",
  751. m
  752. }));
  753. }
  754. }
  755. }
  756. };
  757. fileSystem.SetBaseDirectory(GameMain.Instance.CMSystem.CM3D2Path);
  758. AddFolderOrArchive("csv");
  759. action("csv");
  760. AddFolderOrArchive("motion");
  761. action("motion");
  762. AddFolderOrArchive("motion2");
  763. AddFolderOrArchive("script");
  764. action("script");
  765. action("script_share");
  766. AddFolderOrArchive("script_share2");
  767. AddFolderOrArchive("sound");
  768. action("sound");
  769. AddFolderOrArchive("sound2");
  770. AddFolderOrArchive("texture");
  771. action("texture");
  772. AddFolderOrArchive("texture2");
  773. AddFolderOrArchive("texture3");
  774. AddFolderOrArchive("system");
  775. action("system");
  776. action("bg");
  777. AddFolderOrArchive("voice");
  778. AddFolderOrArchive("voice_a");
  779. AddFolderOrArchive("voice_b");
  780. AddFolderOrArchive("voice_c");
  781. foreach (string str in GameUty.PathListOld)
  782. {
  783. string str2 = "voice";
  784. string text = str2 + "_" + str;
  785. if (AddFolderOrArchive(text))
  786. {
  787. for (int i = 2; i <= check_ver_no; i++)
  788. {
  789. AddFolderOrArchive(text + "_" + i);
  790. }
  791. }
  792. text = str2 + "_" + str + "a";
  793. if (AddFolderOrArchive(text))
  794. {
  795. for (int j = 2; j <= check_ver_no; j++)
  796. {
  797. AddFolderOrArchive(text + "_" + j);
  798. }
  799. }
  800. text = str2 + "_" + str + "b";
  801. if (AddFolderOrArchive(text))
  802. {
  803. for (int k = 2; k <= check_ver_no; k++)
  804. {
  805. AddFolderOrArchive(text + "_" + k);
  806. }
  807. }
  808. }
  809. AddFolderOrArchive("voice2");
  810. AddFolderOrArchive("voice3");
  811. fileSystem.AddAutoPathForAllFolder();
  812. string[] list = fileSystem.GetList("bg", AFileSystemBase.ListType.AllFile);
  813. if (list != null && 0 < list.Length)
  814. {
  815. foreach (string path in list)
  816. {
  817. string fileName = Path.GetFileName(path);
  818. if (!(Path.GetExtension(fileName) != ".asset_bg") && !GameUty.BgFiles.ContainsKey(fileName))
  819. {
  820. GameUty.BgFiles.Add(fileName, fileSystem);
  821. }
  822. }
  823. }
  824. Debug.Log("■■■■■■■■■■■■■■■■■■■■");
  825. }
  826. public static AFileBase FileOpen(string fileName, AFileSystemBase priorityFileSystem = null)
  827. {
  828. if (priorityFileSystem == null)
  829. {
  830. priorityFileSystem = GameUty.m_FileSystem;
  831. }
  832. AFileSystemBase[] array;
  833. if (GameUty.ModPriorityToModFolder)
  834. {
  835. array = new AFileSystemBase[]
  836. {
  837. GameUty.m_ModFileSystem,
  838. priorityFileSystem
  839. };
  840. }
  841. else
  842. {
  843. array = new AFileSystemBase[]
  844. {
  845. priorityFileSystem,
  846. GameUty.m_ModFileSystem
  847. };
  848. }
  849. AFileBase result = null;
  850. foreach (AFileSystemBase afileSystemBase in array)
  851. {
  852. if (afileSystemBase != null && afileSystemBase.IsExistentFile(fileName))
  853. {
  854. result = afileSystemBase.FileOpen(fileName);
  855. break;
  856. }
  857. }
  858. return result;
  859. }
  860. public static bool IsExistFile(string fileName, AFileSystemBase priorityFileSystem = null)
  861. {
  862. if (priorityFileSystem == null)
  863. {
  864. priorityFileSystem = GameUty.m_FileSystem;
  865. }
  866. AFileSystemBase[] array;
  867. if (GameUty.ModPriorityToModFolder)
  868. {
  869. array = new AFileSystemBase[]
  870. {
  871. GameUty.m_ModFileSystem,
  872. priorityFileSystem
  873. };
  874. }
  875. else
  876. {
  877. array = new AFileSystemBase[]
  878. {
  879. priorityFileSystem,
  880. GameUty.m_ModFileSystem
  881. };
  882. }
  883. foreach (AFileSystemBase afileSystemBase in array)
  884. {
  885. if (afileSystemBase != null && afileSystemBase.IsExistentFile(fileName))
  886. {
  887. return true;
  888. }
  889. }
  890. return false;
  891. }
  892. public static string GetBuildVersionText()
  893. {
  894. int num = 1130;
  895. return (num >= 1000) ? ((float)num / 1000f).ToString("F2") : ((float)num / 100f).ToString("F2");
  896. }
  897. public static string GetGameVersionText()
  898. {
  899. string text = "COM3D2x64.exe";
  900. int num = 1130;
  901. string path = Path.GetFullPath(".\\") + "update.lst";
  902. string[] array = new string[0];
  903. if (File.Exists(path))
  904. {
  905. try
  906. {
  907. array = File.ReadAllLines(path, Encoding.GetEncoding("utf-8"));
  908. }
  909. catch (Exception ex)
  910. {
  911. Debug.LogError(ex.Message);
  912. array = new string[0];
  913. }
  914. }
  915. foreach (string text2 in array)
  916. {
  917. if (!string.IsNullOrEmpty(text2))
  918. {
  919. string[] array3 = text2.Split(new char[]
  920. {
  921. ','
  922. });
  923. if (array3 != null && array3.Length == 2 && array3[0].Trim().ToLower() == text.ToLower())
  924. {
  925. int.TryParse(array3[1].Trim(), out num);
  926. break;
  927. }
  928. }
  929. }
  930. string text3 = (num >= 1000) ? ((float)num / 1000f).ToString("F3") : ((float)num / 100f).ToString("F3");
  931. if (text3.Length == 5)
  932. {
  933. text3 = text3.Insert(4, ".");
  934. }
  935. return text3;
  936. }
  937. public static string GetLegacyGameVersionText()
  938. {
  939. if (!GameUty.IsEnabledCompatibilityMode)
  940. {
  941. return "0.0";
  942. }
  943. string text = "CM3D2x64.exe";
  944. string path = GameMain.Instance.CMSystem.CM3D2Path + "\\update.lst";
  945. string[] array = new string[0];
  946. if (File.Exists(path))
  947. {
  948. try
  949. {
  950. array = File.ReadAllLines(path, Encoding.GetEncoding("utf-8"));
  951. }
  952. catch (Exception ex)
  953. {
  954. Debug.LogError(ex.Message);
  955. array = new string[0];
  956. }
  957. }
  958. int num = 0;
  959. foreach (string text2 in array)
  960. {
  961. if (!string.IsNullOrEmpty(text2))
  962. {
  963. string[] array3 = text2.Split(new char[]
  964. {
  965. ','
  966. });
  967. if (array3 != null && array3.Length == 2 && array3 != null && array3.Length == 2 && array3[0].Trim().ToLower() == text.ToLower())
  968. {
  969. int.TryParse(array3[1].Trim(), out num);
  970. break;
  971. }
  972. }
  973. }
  974. string text3 = (num >= 1000) ? ((float)num / 1000f).ToString("F3") : ((float)num / 100f).ToString("F3");
  975. if (text3.Length == 5)
  976. {
  977. text3 = text3.Insert(4, ".");
  978. }
  979. return text3;
  980. }
  981. private static FileSystemArchive m_FileSystem = null;
  982. private static FileSystemArchive m_FileSystemOld = null;
  983. private static FileSystemWindows m_ModFileSystem = null;
  984. public static List<string> PathList = new List<string>();
  985. public static List<string> ExistCsvPathList = new List<string>();
  986. public static List<string> PathListOld = new List<string>();
  987. public static List<string> ExistCsvPathListOld = new List<string>();
  988. private static string[] m_aryMenuFiles = null;
  989. private static string[] m_aryModOnlysMenuFiles = new string[0];
  990. private static Dictionary<int, string> rid_menu_dic_ = new Dictionary<int, string>();
  991. private static Dictionary<string, AssetBundle> asset_bundle_dic = new Dictionary<string, AssetBundle>();
  992. private static string ModPriorityToModFolderInfo = "以下のフラグをtrueにするとMODフォルダのファイルが優先されるが、モザイクも安易に外すことが可能になる為に現在はオミット。";
  993. public static bool ModPriorityToModFolder = false;
  994. private static string[] m_strSystemMaterialName = new string[]
  995. {
  996. "System/Material/2dAlpha",
  997. "System/Material/2dMultiply",
  998. "System/Material/InfinityColor",
  999. "System/Material/TexTo8bitTex"
  1000. };
  1001. private static Material[] m_matSystem = new Material[4];
  1002. public enum SystemMaterial
  1003. {
  1004. Alpha,
  1005. Multiply,
  1006. InfinityColor,
  1007. TexTo8bitTex,
  1008. Max
  1009. }
  1010. }