From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs | 11 + .../XUtliPoolLib/XUpdater/AssetLevel.cs.meta | 12 + .../XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs | 12 + .../XUpdater/AsyncAssemblyRequest.cs.meta | 12 + .../XUtliPoolLib/XUpdater/AsyncCachedRequest.cs | 13 + .../XUpdater/AsyncCachedRequest.cs.meta | 12 + .../XUpdater/AsyncDecompressRequest.cs | 13 + .../XUpdater/AsyncDecompressRequest.cs.meta | 12 + .../XUtliPoolLib/XUpdater/AsyncExtractRequest.cs | 11 + .../XUpdater/AsyncExtractRequest.cs.meta | 12 + .../XUtliPoolLib/XUpdater/AsyncLogRequest.cs | 9 + .../XUtliPoolLib/XUpdater/AsyncLogRequest.cs.meta | 12 + .../XUtliPoolLib/XUpdater/AsyncReadRequest.cs | 11 + .../XUtliPoolLib/XUpdater/AsyncReadRequest.cs.meta | 12 + .../XUpdater/AsyncVersionProcessRequest.cs | 11 + .../XUpdater/AsyncVersionProcessRequest.cs.meta | 12 + .../XUtliPoolLib/XUpdater/AsyncWriteRequest.cs | 17 + .../XUpdater/AsyncWriteRequest.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs | 12 + .../XUtliPoolLib/XUpdater/BuildTarget.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs | 7 + .../XUtliPoolLib/XUpdater/BundleMetaRes.cs.meta | 12 + .../XUtliPoolLib/XUpdater/HandleBundleDownload.cs | 7 + .../XUpdater/HandleBundleDownload.cs.meta | 12 + .../XUtliPoolLib/XUpdater/HandleFetchBundle.cs | 7 + .../XUpdater/HandleFetchBundle.cs.meta | 12 + .../XUtliPoolLib/XUpdater/HandleLoadAsset.cs | 7 + .../XUtliPoolLib/XUpdater/HandleLoadAsset.cs.meta | 12 + .../XUtliPoolLib/XUpdater/HandleLoadBundle.cs | 7 + .../XUtliPoolLib/XUpdater/HandleLoadBundle.cs.meta | 12 + .../XUpdater/HandlePreDecompressing.cs | 6 + .../XUpdater/HandlePreDecompressing.cs.meta | 12 + .../XUtliPoolLib/XUpdater/HandleVersionDownload.cs | 7 + .../XUpdater/HandleVersionDownload.cs.meta | 12 + .../XUtliPoolLib/XUpdater/HandleVersionLoaded.cs | 6 + .../XUpdater/HandleVersionLoaded.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/ResourceType.cs | 11 + .../XUtliPoolLib/XUpdater/ResourceType.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XBundle.cs | 64 + .../Scripts/XUtliPoolLib/XUpdater/XBundle.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XBundleData.cs | 16 + .../XUtliPoolLib/XUpdater/XBundleData.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XCaching.cs | 404 +++++ .../Scripts/XUtliPoolLib/XUpdater/XCaching.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XDownloader.cs | 149 ++ .../XUtliPoolLib/XUpdater/XDownloader.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs | 11 + .../XUtliPoolLib/XUpdater/XLaunchMode.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs | 238 +++ .../XUtliPoolLib/XUpdater/XLoadingUI.cs.meta | 12 + .../XUtliPoolLib/XUpdater/XMetaResPackage.cs | 16 + .../XUtliPoolLib/XUpdater/XMetaResPackage.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XResPackage.cs | 16 + .../XUtliPoolLib/XUpdater/XResPackage.cs.meta | 12 + .../Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs | 229 +++ .../Scripts/XUtliPoolLib/XUpdater/XShell.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XUpdater.cs | 1644 ++++++++++++++++++++ .../Scripts/XUtliPoolLib/XUpdater/XUpdater.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XVersion.cs | 174 +++ .../Scripts/XUtliPoolLib/XUpdater/XVersion.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/XVersionData.cs | 287 ++++ .../XUtliPoolLib/XUpdater/XVersionData.cs.meta | 12 + .../Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs | 20 + .../XUtliPoolLib/XUpdater/eUPdatePhase.cs.meta | 12 + 64 files changed, 3837 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs.meta create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs.meta (limited to 'Client/Assets/Scripts/XUtliPoolLib/XUpdater') diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs new file mode 100644 index 00000000..8d4ac78b --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs @@ -0,0 +1,11 @@ +using System; + +namespace XUpdater +{ + public enum AssetLevel + { + Memory, + Image, + Disk + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs.meta new file mode 100644 index 00000000..bebf8f33 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AssetLevel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 11511373ad6c83c4ebf7b1a96b877ae9 +timeCreated: 1611465291 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs new file mode 100644 index 00000000..8ce94783 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Reflection; + +namespace XUpdater +{ + public sealed class AsyncAssemblyRequest + { + public Assembly Main = null; + + public bool IsDone = false; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs.meta new file mode 100644 index 00000000..96a8513d --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncAssemblyRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ab80306a5baed0b438a50ef96d8ed683 +timeCreated: 1611465741 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs new file mode 100644 index 00000000..a3809d6d --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs @@ -0,0 +1,13 @@ +using System; + +namespace XUpdater +{ + internal sealed class AsyncCachedRequest + { + public bool Cached = false; + + public bool MaybeCached = false; + + public bool IsDone = false; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs.meta new file mode 100644 index 00000000..ab02c220 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncCachedRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fefa949f138c8da418ebb1ac4c88d742 +timeCreated: 1611465813 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs new file mode 100644 index 00000000..44410f71 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs @@ -0,0 +1,13 @@ +using System; + +namespace XUpdater +{ + public sealed class AsyncDecompressRequest + { + public bool IsDone = false; + + public bool HasError = false; + + public float Ratio = 0f; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs.meta new file mode 100644 index 00000000..80baef0a --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncDecompressRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c1b139bb74e9c65488af36d532dbe8ec +timeCreated: 1611465753 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs new file mode 100644 index 00000000..697345a0 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs @@ -0,0 +1,11 @@ +using System; + +namespace XUpdater +{ + internal sealed class AsyncExtractRequest + { + public bool IsDone = false; + + public byte[] Data = null; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs.meta new file mode 100644 index 00000000..876e2aad --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncExtractRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5011231640afbcc4c8ac6dc741d6862f +timeCreated: 1611465643 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs new file mode 100644 index 00000000..138ca5f3 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs @@ -0,0 +1,9 @@ +using System; + +namespace XUpdater +{ + internal sealed class AsyncLogRequest + { + public bool IsDone = false; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs.meta new file mode 100644 index 00000000..2292840b --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncLogRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 266c9c0b4ff1d5f44b4dc47febd01fa8 +timeCreated: 1611465301 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs new file mode 100644 index 00000000..6cddb9e3 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs @@ -0,0 +1,11 @@ +using System; + +namespace XUpdater +{ + internal sealed class AsyncReadRequest + { + public bool IsDone = false; + + public byte[] bytes = null; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs.meta new file mode 100644 index 00000000..63a452d2 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncReadRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c49dde5a2c4330d43a70cb229f191ee3 +timeCreated: 1611465755 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs new file mode 100644 index 00000000..35d4bf1d --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs @@ -0,0 +1,11 @@ +using System; + +namespace XUpdater +{ + internal sealed class AsyncVersionProcessRequest + { + public bool IsDone = false; + + public bool IsCorrect = false; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs.meta new file mode 100644 index 00000000..e563b514 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncVersionProcessRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a9c0ae94ae541204d9b38b7b61fcaa13 +timeCreated: 1611465739 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs new file mode 100644 index 00000000..53577bdd --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs @@ -0,0 +1,17 @@ +using System; + +namespace XUpdater +{ + internal sealed class AsyncWriteRequest + { + public bool IsDone = false; + + public bool HasError = false; + + public string Location = null; + + public string Name = null; + + public uint Size = 0u; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs.meta new file mode 100644 index 00000000..37f0f188 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/AsyncWriteRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e366103fe3b18ee4d95e430c195d3e06 +timeCreated: 1611465801 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs new file mode 100644 index 00000000..4b58adae --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs @@ -0,0 +1,12 @@ +using System; + +namespace XUpdater +{ + public enum BuildTarget + { + Unknown, + IOS, + Android, + Standalone + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs.meta new file mode 100644 index 00000000..544f6004 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BuildTarget.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 29d77a42d1136f0429c70b41706ba425 +timeCreated: 1611465303 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs new file mode 100644 index 00000000..37e47794 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs @@ -0,0 +1,7 @@ +using System; +using System.Collections.Generic; + +namespace XUpdater +{ + public delegate List BundleMetaRes(List rawList, string destFoler); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs.meta new file mode 100644 index 00000000..96b725a2 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/BundleMetaRes.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2f6317ec5b64c3c4a9291fdbeafb266e +timeCreated: 1611465307 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs new file mode 100644 index 00000000..08e62a97 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs @@ -0,0 +1,7 @@ +using System; +using UnityEngine; + +namespace XUpdater +{ + internal delegate AsyncWriteRequest HandleBundleDownload(WWW www, XBundleData bundle, string error); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs.meta new file mode 100644 index 00000000..776a5042 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleBundleDownload.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4e48883f185e30c498dbd279d7ceddf7 +timeCreated: 1611465642 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs new file mode 100644 index 00000000..9270b174 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs @@ -0,0 +1,7 @@ +using System; +using UnityEngine; + +namespace XUpdater +{ + internal delegate void HandleFetchBundle(WWW bundle, byte[] bytes, XBundleData data, bool newdownload); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs.meta new file mode 100644 index 00000000..0ee08764 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleFetchBundle.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 54c07dfa9833fa14abfce085cbf6dc3e +timeCreated: 1611465645 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs new file mode 100644 index 00000000..eacf231b --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs @@ -0,0 +1,7 @@ +using System; +using UnityEngine; + +namespace XUpdater +{ + internal delegate void HandleLoadAsset(XResPackage package, UnityEngine.Object asset); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs.meta new file mode 100644 index 00000000..ef4377e4 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadAsset.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6d4aa5d1cc5ccba43a34283eb79b80d8 +timeCreated: 1611465685 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs new file mode 100644 index 00000000..55482def --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs @@ -0,0 +1,7 @@ +using System; +using UnityEngine; + +namespace XUpdater +{ + internal delegate void HandleLoadBundle(AssetBundle bundle); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs.meta new file mode 100644 index 00000000..ae3b1392 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleLoadBundle.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 93f6995e1f9a4de44a45bbd084448aed +timeCreated: 1611465707 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs new file mode 100644 index 00000000..b4436ea3 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs @@ -0,0 +1,6 @@ +using System; + +namespace XUpdater +{ + public delegate void HandlePreDecompressing(string error); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs.meta new file mode 100644 index 00000000..345a87bb --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandlePreDecompressing.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9c4e5dd84410a0e40a0423a53f181555 +timeCreated: 1611465711 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs new file mode 100644 index 00000000..77435200 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs @@ -0,0 +1,7 @@ +using System; +using UnityEngine; + +namespace XUpdater +{ + internal delegate AsyncVersionProcessRequest HandleVersionDownload(TextAsset text); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs.meta new file mode 100644 index 00000000..48c83647 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionDownload.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 15065b61bf5ac3d478f327cb5ae7a10b +timeCreated: 1611465294 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs new file mode 100644 index 00000000..efc66aa0 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs @@ -0,0 +1,6 @@ +using System; + +namespace XUpdater +{ + internal delegate void HandleVersionLoaded(bool correct); +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs.meta new file mode 100644 index 00000000..de47e11e --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/HandleVersionLoaded.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cffebd77213e132488f925c85afdb585 +timeCreated: 1611465760 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs new file mode 100644 index 00000000..a4e52b27 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs @@ -0,0 +1,11 @@ +using System; + +namespace XUpdater +{ + public enum ResourceType + { + Assets, + Scene, + Script + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs.meta new file mode 100644 index 00000000..19ade6ce --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/ResourceType.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4bed5f3fc6adece4f9497c3d92c4fa51 +timeCreated: 1611465641 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs new file mode 100644 index 00000000..acb8fa42 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections; +using UnityEngine; + +namespace XUpdater +{ + internal sealed class XBundle : MonoBehaviour + { + private AssetBundleRequest _assetloader = null; + + public void GetBundle(WWW www, byte[] data, HandleLoadBundle callback, bool load) + { + base.StartCoroutine(this.LoadBundle(www, data, callback, load)); + } + + public void GetAsset(AssetBundle bundle, XResPackage package, HandleLoadAsset callback) + { + base.StartCoroutine(this.LoadAsset(bundle, package, callback)); + } + + private IEnumerator LoadBundle(WWW www, byte[] data, HandleLoadBundle callback, bool load) + { + AssetBundle bundle = null; + if (load) + { + bool flag = www != null; + if (flag) + { + bundle = www.assetBundle; + } + else + { + bundle = AssetBundle.LoadFromMemory(data); + } + yield return null; + } + bool flag2 = callback != null; + if (flag2) + { + callback(bundle); + } + bool flag3 = www != null; + if (flag3) + { + www.Dispose(); + } + www = null; + yield break; + } + + private IEnumerator LoadAsset(AssetBundle bundle, XResPackage package, HandleLoadAsset callback) + { + this._assetloader = bundle.LoadAssetAsync(base.name, XUpdater.Ass.GetType(package.type)); + yield return this._assetloader; + bool flag = callback != null; + if (flag) + { + callback(package, this._assetloader.asset); + } + this._assetloader = null; + yield break; + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs.meta new file mode 100644 index 00000000..4c9a9bdb --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d74b1473d4088034d828831e70be9ad7 +timeCreated: 1611465764 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs new file mode 100644 index 00000000..e42cb345 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs @@ -0,0 +1,16 @@ +using System; + +namespace XUpdater +{ + [Serializable] + public class XBundleData + { + public string Name; + + public string MD5; + + public uint Size; + + public AssetLevel Level = AssetLevel.Memory; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs.meta new file mode 100644 index 00000000..2fa3cc7b --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundleData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 77c36f6c000743e479e8dce789a1d43e +timeCreated: 1611465691 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs new file mode 100644 index 00000000..a4780a7a --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs @@ -0,0 +1,404 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; +using System.Threading; +using UnityEngine; +using XUtliPoolLib; + +namespace XUpdater +{ + public sealed class XCaching : XSingleton + { + public string VersionServer + { + get + { + return this._version_server; + } + } + + public string HostUrl + { + get + { + return this._host_url; + } + } + + public string UpdatePath + { + get + { + return this._update_path; + } + } + + public XDownloader Downloader + { + get + { + return this._down_loader; + } + } + + private string _version_server = null; + + private string _host_url = null; + + internal static readonly string UPDATE_DIRECTORY = "/update/"; + + private string _update_path = null; + + private StringBuilder _log = new StringBuilder(); + + private XDownloader _down_loader = null; + + private MD5CryptoServiceProvider _md5Generator = null; + + private AsyncExtractRequest _aer = null; + + private AsyncWriteRequest _meta_awr = null; + + internal string GetLocalPath(XBundleData data) + { + return string.Format("{0}{1}.assetbundle", this._update_path, data.Name); + } + + internal string GetLocalUrl(XBundleData data) + { + bool flag = XSingleton.singleton.RunTimePlatform == BuildTarget.Standalone; + string arg; + if (flag) + { + arg = "file:///"; + } + else + { + arg = "file://"; + } + string text = string.Format("{0}{1}{2}.assetbundle", arg, this._update_path, data.Name); + XSingleton.singleton.AddLog("LocalURL: ", text, null, null, null, null, XDebugColor.XDebug_None); + return text; + } + + public string GetLoginServerAddress(string loginType) + { + IPlatform xplatform = XSingleton.singleton.XPlatform; + return xplatform.GetHostWithHttpDns(xplatform.GetLoginServer(loginType)); + } + + internal string GetDownloadUrl(XBundleData data) + { + return this.MakeToken(string.Format("{0}{1}/{2}.assetbundle", this.HostUrl, XSingleton.singleton.Platform, data.Name)); + } + + internal string MakeToken(string url) + { + return string.Format("{0}?token={1}", url, DateTime.Now.Ticks); + } + + public override bool Init() + { + IPlatform xplatform = XSingleton.singleton.XPlatform; + this._version_server = xplatform.GetHostWithHttpDns(xplatform.GetVersionServer()); + this._host_url = xplatform.GetHostUrl(); + this._md5Generator = new MD5CryptoServiceProvider(); + this._down_loader = XUpdater.XGameRoot.AddComponent(); + this._update_path = Application.persistentDataPath + XCaching.UPDATE_DIRECTORY; + return true; + } + + internal bool EnableCache() + { + bool flag = !Directory.Exists(this._update_path); + if (flag) + { + XSingleton.singleton.AddLog("Create new path " + this._update_path, null, null, null, null, null, XDebugColor.XDebug_None); + try + { + Directory.CreateDirectory(this._update_path); + return Directory.Exists(this._update_path); + } + catch (Exception ex) + { + XSingleton.singleton.AddErrorLog(string.Format("Error ", ex.Message), null, null, null, null, null); + return false; + } + } + XSingleton.singleton.AddLog(string.Format("Path {0} exists.", this._update_path), null, null, null, null, null, XDebugColor.XDebug_None); + return true; + } + + internal AsyncCachedRequest IsBundleCached(XBundleData bundle, uint size) + { + string fullpath = this.GetLocalPath(bundle); + AsyncCachedRequest req = new AsyncCachedRequest(); + bool flag = bundle.Size < size; + if (flag) + { + new Thread((ThreadStart) delegate + { + bool flag2 = File.Exists(fullpath); + if (flag2) + { + byte[] bundle2 = this.LoadFile(fullpath); + string a = this.CalculateMD5(bundle2); + req.Cached = (a == bundle.MD5); + req.MaybeCached = true; + } + req.IsDone = true; + }).Start(); + } + else + { + req.MaybeCached = File.Exists(fullpath); + req.IsDone = true; + } + return req; + } + + internal bool CleanCache() + { + string path = ((int)Application.platform == 8) ? ("/private" + this._update_path) : this._update_path; + bool result; + try + { + bool flag = Directory.Exists(path); + if (flag) + { + DirectoryInfo directoryInfo = new DirectoryInfo(path); + directoryInfo.Delete(true); + bool flag2 = !Directory.Exists(path); + bool flag3 = flag2; + if (flag3) + { + result = this.EnableCache(); + } + else + { + result = false; + } + } + else + { + result = true; + } + } + catch (Exception ex) + { + XSingleton.singleton.AddErrorLog("CleanCache error: ", ex.Message, null, null, null, null); + result = false; + } + return result; + } + + internal byte[] LoadFile(string fullpath) + { + return File.ReadAllBytes(fullpath); + } + + private AsyncReadRequest LoadFileAsync(string fullpath) + { + AsyncReadRequest arr = new AsyncReadRequest(); + new Thread((ThreadStart) delegate + { + arr.bytes = File.ReadAllBytes(fullpath); + arr.IsDone = true; + }).Start(); + return arr; + } + + internal void Download(XBundleData bundle, HandleFetchBundle callback, float percent) + { + this._down_loader.GetBundle(bundle, this.GetDownloadUrl(bundle), new HandleBundleDownload(this.OnBundleDownload), callback, percent); + } + + internal AsyncWriteRequest Download(string meta, uint size, float percent) + { + this._meta_awr = new AsyncWriteRequest(); + this._meta_awr.Size = size; + this._meta_awr.Location = meta; + this._meta_awr.Name = meta.Substring(meta.LastIndexOf('/') + 1); + this._meta_awr.HasError = false; + string name = meta.Substring(meta.LastIndexOf("/") + 1); + meta = this.MakeToken(this.HostUrl + XSingleton.singleton.Platform + meta); + this._down_loader.GetMeta(meta, name, new XDownloader.HandleBytesDownload(this.OnMetaDownload), percent); + return this._meta_awr; + } + + internal bool Extract(XBundleData bundle, HandleFetchBundle callback, float percent) + { + bool flag =(int) Application.platform == 8; + bool result; + if (flag) + { + bool flag2 = this._aer == null; + if (flag2) + { + this._aer = new AsyncExtractRequest(); + new Thread((ThreadStart)delegate + { + string localPath = this.GetLocalPath(bundle); + this._aer.Data = File.ReadAllBytes(localPath); + this._aer.IsDone = true; + }).Start(); + } + bool isDone = this._aer.IsDone; + if (isDone) + { + callback(null, this._aer.Data, bundle, false); + this._aer.Data = null; + this._aer = null; + result = true; + } + else + { + result = false; + } + } + else + { + this._down_loader.GetBundle(bundle, this.GetLocalUrl(bundle), null, callback, percent); + result = true; + } + return result; + } + + private void OnMetaDownload(WWW www, string error) + { + bool flag = string.IsNullOrEmpty(error); + if (flag) + { + byte[] bs = www.bytes; + new Thread((ThreadStart)delegate + { + try + { + bool needCheckFile = XSingleton.singleton.NeedCheckFile; + if (needCheckFile) + { + bool flag2 = Path.GetExtension(this._meta_awr.Location).Contains("ab"); + if (flag2) + { + bool flag3 = bs[0] != 85 || bs[1] != 110 || bs[2] != 105 || bs[3] != 116 || bs[4] != 121 || bs[5] != 70 || bs[6] != 83; + if (flag3) + { + throw new Exception("Meta head check failed."); + } + } + } + string text = Path.Combine(this._update_path, "AssetBundles"); + string fileName = Path.GetFileName(this._meta_awr.Location); + bool flag4 = !Directory.Exists(text); + if (flag4) + { + Directory.CreateDirectory(text); + } + string text2 = Path.Combine(text, fileName); + File.WriteAllBytes(text2, bs); + bool needCheckFile2 = XSingleton.singleton.NeedCheckFile; + if (needCheckFile2) + { + Thread.Sleep(1); + bool flag5 = this.CheckFileSize(text2, (long)((ulong)this._meta_awr.Size)); + if (!flag5) + { + throw new Exception("Meta File size " + this._meta_awr.Size + " not match."); + } + XSingleton.singleton.XPlatform.SetNoBackupFlag(text2); + this._meta_awr.IsDone = true; + } + else + { + XSingleton.singleton.XPlatform.SetNoBackupFlag(text2); + this._meta_awr.IsDone = true; + } + } + catch (Exception ex) + { + this.OnDownloadFailed(ex.Message, this._meta_awr); + } + }).Start(); + } + else + { + this.OnDownloadFailed(error, this._meta_awr); + } + } + + private void OnDownloadFailed(string error, AsyncWriteRequest awr) + { + XSingleton.singleton.AddErrorLog("Download Meta ", awr.Name, " error: ", error, null, null); + awr.HasError = true; + } + + private AsyncWriteRequest OnBundleDownload(WWW www, XBundleData bundle, string error) + { + AsyncWriteRequest req = new AsyncWriteRequest(); + bool flag = string.IsNullOrEmpty(error); + if (flag) + { + byte[] bs = www.bytes; + new Thread((ThreadStart)delegate + { + req.Location = this.GetLocalPath(bundle); + try + { + File.WriteAllBytes(req.Location, bs); + req.IsDone = true; + } + catch (Exception ex) + { + this.OnDownloadFailed(ex.Message, req); + } + }).Start(); + } + else + { + this.OnDownloadFailed(error, req); + } + return req; + } + + internal string CalculateMD5(byte[] bundle) + { + byte[] value = this._md5Generator.ComputeHash(bundle); + return BitConverter.ToString(value); + } + + internal string CalculateMD5(byte[] bundle, int offset, int count) + { + byte[] value = this._md5Generator.ComputeHash(bundle, offset, count); + return BitConverter.ToString(value); + } + + public bool CheckFileSize(string filePath, long fileSize) + { + bool result; + try + { + bool flag = !File.Exists(filePath); + if (flag) + { + result = false; + } + else + { + FileInfo fileInfo = new FileInfo(filePath); + result = (fileSize == fileInfo.Length); + } + } + catch (Exception ex) + { + XSingleton.singleton.AddErrorLog("XCaching.CheckFileSize: " + ex.Message, null, null, null, null, null); + result = false; + } + return result; + } + + public override void Uninit() + { + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs.meta new file mode 100644 index 00000000..6ab14d04 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XCaching.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e212f5e587fc78e44bfa392acdcc623d +timeCreated: 1611465800 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs new file mode 100644 index 00000000..00e347ae --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Text; +using UnityEngine; +using XUtliPoolLib; + +namespace XUpdater +{ + public sealed class XDownloader : MonoBehaviour + { + private StringBuilder _log = new StringBuilder(); + + private WWW _downloader = null; + + private bool _download = true; + + private uint _token = 0u; + + private float _total_percent = 0f; + + private string _current_name = null; + + private XTimerMgr.ElapsedEventHandler _progressCb = null; + + public delegate void HandleBytesDownload(WWW www, string error); + + private void Awake() + { + this._progressCb = new XTimerMgr.ElapsedEventHandler(this.Progress); + } + + internal void GetBundle(XBundleData bundle, string url, HandleBundleDownload callback1, HandleFetchBundle callback2, float percent) + { + this._download = url.Contains("?token="); + this._current_name = bundle.Name; + this._total_percent = percent; + base.StartCoroutine(this.Download(bundle, url, callback1, callback2)); + } + + public void GetMeta(string url, string name, XDownloader.HandleBytesDownload callback, float percent) + { + this._download = true; + this._current_name = name; + this._total_percent = percent; + base.StartCoroutine(this.MetaDownload(url, callback)); + } + + public void GetBytes(string url, XDownloader.HandleBytesDownload callback) + { + base.StartCoroutine(this.BytesDownload(url, callback)); + } + + private IEnumerator MetaDownload(string url, XDownloader.HandleBytesDownload callback) + { + XSingleton.singleton.KillTimer(this._token); + this._token = XSingleton.singleton.SetTimer(0.1f, this._progressCb, null); + this._downloader = new WWW(url); + yield return this._downloader; + XSingleton.singleton.KillTimer(this._token); + this.Progress(null); + XSingleton.singleton.KillTimer(this._token); + bool flag = callback != null; + if (flag) + { + callback(this._downloader, this._downloader.error); + } + this._downloader.Dispose(); + this._downloader = null; + yield break; + } + + private IEnumerator BytesDownload(string url, XDownloader.HandleBytesDownload callback) + { + WWW www = new WWW(url); + yield return www; + bool flag = callback != null; + if (flag) + { + callback(www, www.error); + } + www.Dispose(); + www = null; + yield break; + } + + private IEnumerator Download(XBundleData bundle, string url, HandleBundleDownload callback1, HandleFetchBundle callback2) + { + XSingleton.singleton.KillTimer(this._token); + this._token = XSingleton.singleton.SetTimer(0.1f, this._progressCb, null); + this._downloader = new WWW(url); + yield return this._downloader; + XSingleton.singleton.KillTimer(this._token); + this.Progress(null); + XSingleton.singleton.KillTimer(this._token); + bool error = false; + bool flag = callback1 != null; + if (flag) + { + AsyncWriteRequest awr = callback1(this._downloader, bundle, this._downloader.error); + while (!awr.IsDone) + { + bool hasError = awr.HasError; + if (hasError) + { + error = true; + break; + } + yield return null; + } + XSingleton.singleton.XPlatform.SetNoBackupFlag(awr.Location); + awr = null; + } + bool flag2 = error; + if (flag2) + { + this._log.Length = 0; + this._log.AppendFormat(XSingleton.singleton.GetString("XUPDATE_ERROR_DOWNLOADRESFAILED"), bundle.Name); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + } + else + { + bool flag3 = callback2 != null; + if (flag3) + { + callback2(this._downloader, this._downloader.bytes, bundle, this._download); + } + } + this._downloader = null; + yield break; + } + + private void Progress(object o) + { + this._log.Remove(0, this._log.Length); + int num = Mathf.FloorToInt(this._total_percent * 100f); + bool download = this._download; + if (download) + { + this._log.AppendFormat(XSingleton.singleton.GetString("XUPDATE_INFO_DOWNLOADING"), num); + } + else + { + this._log.AppendFormat(XSingleton.singleton.GetString("XUPDATE_INFO_EXTRACTING"), num); + } + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + this._token = XSingleton.singleton.SetTimer(0.1f, this._progressCb, o); + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs.meta new file mode 100644 index 00000000..637a01b8 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XDownloader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 011390f5919ea604ba6a551c2601f729 +timeCreated: 1611465284 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs new file mode 100644 index 00000000..9b9e8e8e --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs @@ -0,0 +1,11 @@ +using System; + +namespace XUpdater +{ + public enum XLaunchMode + { + Live = 100, + PreProduct, + Dev = 200 + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs.meta new file mode 100644 index 00000000..e559afb3 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLaunchMode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a9dca030da976a842a72f0ce356aa6a5 +timeCreated: 1611465740 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs new file mode 100644 index 00000000..b74f8e39 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs @@ -0,0 +1,238 @@ +using System; +using UILib; +using UnityEngine; +using XUtliPoolLib; + +namespace XUpdater +{ + internal class XLoadingUI : XSingleton + { + private IXUISprite JY; + + private IXUISprite Black; + + private IXUITweenTool JYPlayTween; + + private IXUITweenTool BlackPlayTween; + + private IXUILabel StatusText; + + private IXUILabel VersionText; + + private IXUISprite ClickBox; + + public bool LoadingOK = false; + + private bool TweenOK = false; + + private Transform mTextureTransform; + + private Transform mDialogTransform; + + private IXUIButton mDialogSureBtn; + + private IXUIButton mDialogCancelBtn; + + private IXUILabel mDialogCapacityLabel; + + private IXUITexture mDownLoadTexture; + + private IXUIButton mDownLoadNewBtn; + + private Transform mDownLoadTransform; + + private XLoadingUI.OnSureCallBack mDialogCallBack; + + private XLoadingUI.OnSureCallBack mDialogCancelCallBack; + + private XLoadingUI.OnSureCallBack mDownCallBack; + + public delegate void OnSureCallBack(); + + public override bool Init() + { + PlayerPrefs.SetString("Language", "Language"); + GameObject gameObject = GameObject.Find("UIRoot/StartLoadingDlg/Bg/Ailin"); + GameObject gameObject2 = GameObject.Find("UIRoot/StartLoadingDlg/Bg/JY"); + GameObject gameObject3 = GameObject.Find("UIRoot/StartLoadingDlg/Bg").transform.Find("Black").gameObject; + this.StatusText = (GameObject.Find("UIRoot/StartLoadingDlg/Bg/LabelStatus").GetComponent("XUILabel") as IXUILabel); + this.VersionText = (GameObject.Find("UIRoot/StartLoadingDlg/Bg/LabelVersion").GetComponent("XUILabel") as IXUILabel); + this.JY = (gameObject2.GetComponent("XUISprite") as IXUISprite); + this.Black = (gameObject3.GetComponent("XUISprite") as IXUISprite); + this.JYPlayTween = (gameObject2.GetComponent("XUIPlayTween") as IXUITweenTool); + this.BlackPlayTween = (gameObject3.GetComponent("XUIPlayTween") as IXUITweenTool); + this.JYPlayTween.SetTargetGameObject(gameObject2); + this.JYPlayTween.RegisterOnFinishEventHandler(new OnTweenFinishEventHandler(this.OnJYPlayTweenFinish)); + this.Black.SetVisible(true); + this.BlackPlayTween.SetTargetGameObject(gameObject3); + this.BlackPlayTween.RegisterOnFinishEventHandler(new OnTweenFinishEventHandler(this.OnBlackPlayTweenFinish)); + this.StatusText.SetVisible(false); + this.VersionText.SetVisible(false); + this.Black.SetVisible(false); + this.JY.SetVisible(true); + this.JYPlayTween.PlayTween(true, -1f); + this.ClickBox = (GameObject.Find("UIRoot/StartLoadingDlg/Bg").GetComponent("XUISprite") as IXUISprite); + this.ClickBox.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnBoxClick)); + this.mTextureTransform = GameObject.Find("UIRoot/StartLoadingDlg/Bg/Texture").transform; + this.mDialogTransform = GameObject.Find("UIRoot/StartLoadingDlg/Bg/Dialog").transform; + this.mDialogSureBtn = (this.mDialogTransform.Find("OK").GetComponent("XUIButton") as IXUIButton); + this.mDialogCancelBtn = (this.mDialogTransform.Find("Cancel").GetComponent("XUIButton") as IXUIButton); + this.mDialogCapacityLabel = (this.mDialogTransform.Find("CapacityValue").GetComponent("XUILabel") as IXUILabel); + this.mDialogSureBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnDialogSureClick)); + this.mDialogCancelBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnDialogCancelClick)); + this.mTextureTransform.gameObject.SetActive(false); + this.mDialogTransform.gameObject.SetActive(false); + this.mDownLoadTransform = GameObject.Find("UIRoot/StartLoadingDlg/Bg/DownNew").transform; + this.mDownLoadTexture = (this.mDownLoadTransform.Find("Pic").GetComponent("XUITexture") as IXUITexture); + this.mDownLoadNewBtn = (this.mDownLoadTransform.Find("OK").GetComponent("XUIButton") as IXUIButton); + this.mDownLoadTransform.gameObject.SetActive(false); + this.mDownLoadNewBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnDownLoadCallback)); + return true; + } + + public bool OnDialogSureClick(IXUIButton btn) + { + this.mDialogTransform.gameObject.SetActive(false); + bool flag = this.mDialogCallBack != null; + if (flag) + { + this.mDialogCallBack(); + } + return true; + } + + public bool OnDialogCancelClick(IXUIButton btn) + { + this.mDialogTransform.gameObject.SetActive(false); + bool flag = this.mDialogCancelCallBack != null; + if (flag) + { + this.mDialogCancelCallBack(); + } + return true; + } + + public bool OnDownLoadCallback(IXUIButton btn) + { + this.mDownLoadTransform.gameObject.SetActive(false); + bool flag = this.mDownCallBack != null; + if (flag) + { + this.mDownCallBack(); + } + return true; + } + + public void OnBoxClick(IXUISprite sp) + { + XSingleton.singleton.OnRetry(); + } + + private void OnBlackPlayTweenFinish(IXUITweenTool iPlayTween) + { + XSingleton.singleton.Phase = eUPdatePhase.xUP_Finish; + } + + private void OnAilinPlayTweenFinish(IXUITweenTool iPlayTween) + { + this.TweenOK = true; + } + + private void OnJYPlayTweenFinish(IXUITweenTool iPlayTween) + { + this.JY.SetVisible(false); + this.mTextureTransform.gameObject.SetActive(true); + this.TweenOK = true; + XSingleton.singleton.Begin(); + } + + private void LoadFinishClean() + { + this.JY = null; + this.Black = null; + this.JYPlayTween = null; + this.BlackPlayTween = null; + this.StatusText = null; + this.VersionText = null; + this.ClickBox = null; + this.mDialogCallBack = null; + this.mDialogCancelCallBack = null; + this.mDialogCancelBtn = null; + this.mDialogSureBtn = null; + this.mDialogCapacityLabel = null; + this.mDialogTransform = null; + this.mDownLoadNewBtn = null; + this.mDownLoadTransform = null; + } + + public void SetDialog(ulong capacity, XLoadingUI.OnSureCallBack sureCallBack, XLoadingUI.OnSureCallBack cancelCallBack) + { + this.mDialogCallBack = sureCallBack; + this.mDialogCancelCallBack = cancelCallBack; + this.mDialogTransform.gameObject.SetActive(true); + this.mDialogCapacityLabel.SetText(this.GetCapacityValue(capacity)); + } + + public void SetDownLoad(XLoadingUI.OnSureCallBack sureCallBack, Texture tex) + { + this.mDownCallBack = sureCallBack; + this.mDownLoadTransform.gameObject.SetActive(true); + bool flag = tex != null; + if (flag) + { + this.mDownLoadTexture.SetRuntimeTex(tex, true); + } + } + + private string GetCapacityValue(ulong capacity) + { + bool flag = capacity < 1048576UL; + string result; + if (flag) + { + result = string.Format("{0}K", (capacity / 1024UL).ToString("F2")); + } + else + { + result = string.Format("{0}M", (capacity / 1024UL / 1024UL).ToString("F2")); + } + return result; + } + + public void SetStatus(string text, byte r = 255, byte g = 255, byte b = 255) + { + bool flag = !this.StatusText.IsVisible(); + if (flag) + { + this.StatusText.SetVisible(true); + } + this.StatusText.SetColor(new Color32(r, g, b, byte.MaxValue)); + this.StatusText.SetText(text); + } + + public void SetVersion(string text) + { + bool flag = !this.VersionText.IsVisible(); + if (flag) + { + this.VersionText.SetVisible(true); + } + this.VersionText.SetText(text); + } + + public void OnUpdate() + { + bool flag = this.TweenOK && this.LoadingOK; + if (flag) + { + this.TweenOK = (this.LoadingOK = false); + XSingleton.singleton.Phase = eUPdatePhase.xUP_Finish; + this.LoadFinishClean(); + } + } + + public override void Uninit() + { + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs.meta new file mode 100644 index 00000000..622cc014 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XLoadingUI.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3a2909fecca65674ead27371201b0a69 +timeCreated: 1611465631 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs new file mode 100644 index 00000000..61145a31 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs @@ -0,0 +1,16 @@ +using System; + +namespace XUpdater +{ + [Serializable] + public class XMetaResPackage + { + public string download; + + public string buildinpath; + + public string bundle; + + public uint Size; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs.meta new file mode 100644 index 00000000..f88076a3 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XMetaResPackage.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 40e229542a04c8b4e963b01fdd9911d4 +timeCreated: 1611465635 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs new file mode 100644 index 00000000..55d3277e --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs @@ -0,0 +1,16 @@ +using System; + +namespace XUpdater +{ + [Serializable] + public class XResPackage + { + public string location; + + public string type; + + public string bundle; + + public ResourceType rtype = ResourceType.Assets; + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs.meta new file mode 100644 index 00000000..05281744 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XResPackage.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: de0d4b26a3f172d4bb888f7450d92e37 +timeCreated: 1611465797 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs new file mode 100644 index 00000000..81f4ee45 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs @@ -0,0 +1,229 @@ +using System; +using System.Reflection; +using UnityEngine; +using UnityEngine.SceneManagement; +using XUtliPoolLib; + +namespace XUpdater +{ + public sealed class XShell : XSingleton + { + public bool Pause + { + get + { + return this._bPause; + } + set + { + bool isDone = XSingleton.singleton.IsDone; + if (isDone) + { + this._bPauseTrigger = value; + } + } + } + + public float CurrentTimeMagic + { + get + { + return Time.timeScale; + } + } + + public static readonly int TargetFrame = 30; + + private float _time_scale = 1f; + + private bool _bPause = false; + + private bool _bPauseTrigger = false; + + private IEntrance _entrance = null; + + public void PreLaunch() + { + this._entrance.Awake(); + bool flag = this._entrance != null; + if (flag) + { + IPlatform xplatform = XSingleton.singleton.XPlatform; + bool flag2 = xplatform != null; + if (flag2) + { + this._entrance.SetQualityLevel(xplatform.GetQualityLevel()); + } + } + } + + public void Launch() + { + this._entrance.Awake(); + } + + public bool Launched() + { + return this._entrance.Awaked; + } + + public void StartGame() + { + this._entrance.Start(); + } + + public void Awake() + { + bool flag = !XSingleton.singleton.IsDone; + if (flag) + { + XSingleton.singleton.Init(); + } + } + + public void Start() + { + Screen.sleepTimeout = -1; + Application.targetFrameRate = -1; + } + + private void NetUpdate() + { + this._entrance.NetUpdate(); + } + + public void PreUpdate() + { + this.NetUpdate(); + bool pause = this.Pause; + if (!pause) + { + this._entrance.PreUpdate(); + } + } + + public void Update() + { + bool isDone = XSingleton.singleton.IsDone; + if (isDone) + { + XSingleton.singleton.updateStartTime = Time.time; + this.PreUpdate(); + bool pause = this.Pause; + if (!pause) + { + bool update = XSingleton.singleton.update; + if (update) + { + XSingleton.singleton.Update(Time.deltaTime); + } + bool needFixedUpdate = XSingleton.singleton.NeedFixedUpdate; + if (needFixedUpdate) + { + XSingleton.singleton.Update(Time.deltaTime); + } + XSingleton.singleton.Update(); + this._entrance.Update(); + } + } + else + { + XSingleton.singleton.Update(Time.deltaTime); + XSingleton.singleton.Update(); + } + } + + public void PostUpdate() + { + bool isDone = XSingleton.singleton.IsDone; + if (isDone) + { + this.PauseChecker(); + this._entrance.FadeUpdate(); + bool pause = this.Pause; + if (pause) + { + return; + } + this._entrance.PostUpdate(); + XSingleton.singleton.PostUpdate(); + } + bool reboot = XSingleton.singleton.Reboot; + if (reboot) + { + this.Quit(); + SceneManager.LoadScene(0); + } + } + + public void Quit() + { + bool isDone = XSingleton.singleton.IsDone; + if (isDone) + { + this._entrance.Quit(); + } + XSingleton.singleton.Uninit(); + } + + public void MakeEntrance(Assembly main) + { + Type type = main.GetType("XMainClient.XGameEntrance"); + MethodInfo method = type.GetMethod("Fire"); + method.Invoke(null, null); + this._entrance = XSingleton.singleton.GetInterface(0u); + } + + //! + public void _MakeEntrance() + { + XMainClient.XGameEntrance.Fire(); + this._entrance = XSingleton.singleton.GetInterface(0u); + } + + public float TimeMagic(float value) + { + bool flag = Time.timeScale == 1f && !this._bPause; + if (flag) + { + Time.timeScale = value; + this._time_scale = value; + } + return Time.timeScale; + } + + public void TimeMagicBack() + { + Time.timeScale = 1f; + this._time_scale = 1f; + } + + private void PauseChecker() + { + bool flag = this._bPause == this._bPauseTrigger; + if (!flag) + { + this._bPause = this._bPauseTrigger; + Time.timeScale = (this._bPause ? 0f : this._time_scale); + } + } + + public override bool Init() + { + return true; + } + + public override void Uninit() + { + } + + public void MonoObjectRegister(string key, MonoBehaviour behavior) + { + bool flag = this._entrance != null; + if (flag) + { + this._entrance.MonoObjectRegister(key, behavior); + } + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs.meta new file mode 100644 index 00000000..d224cbd8 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 28fb5d2f5ca05b943a403b7e467f69b8 +timeCreated: 1611465302 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs new file mode 100644 index 00000000..dba75741 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs @@ -0,0 +1,1644 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Xml.Serialization; +using UnityEngine; +using XUtliPoolLib; + +namespace XUpdater +{ + public sealed class XUpdater : XSingleton + { + public static XLaunchMode LaunchMode + { + get + { + return XUpdater._launch_mode; + } + } + + public bool EditorMode + { + get + { + return this._bEditorMode; + } + } + + public string Version + { + get + { + return this._version; + } + } + + public string TargetVersion + { + get + { + return this._target_version; + } + } + + public bool NeedCheckFile + { + get + { + return this._need_check_file; + } + } + + public BuildTarget RunTimePlatform + { + get + { + return this._runtime_platform; + } + } + + public string Platform + { + get + { + return this._platform_name; + } + } + + public IPlatform XPlatform + { + get + { + return this._platform; + } + } + + public ILuaEngine XLuaEngine + { + get + { + return this._lua_engine; + } + } + + public IApolloManager XApolloManager + { + get + { + return this._apolloManager; + } + } + + public IBroardcast XBroadCast + { + get + { + return this._broadcast; + } + } + + public ITssSdk XTssSdk + { + get + { + return this._tssSdk; + } + } + + public IXPandoraMgr XPandoraManager + { + get + { + return this._pandoraManager; + } + } + + public IXGameSirControl GameSirControl + { + get + { + return this._SirControl; + } + } + + public IResourceHelp XResourceHelp + { + get + { + return this._resourcehelp; + } + } + + public bool IsDone + { + get + { + return this._update_done; + } + } + + internal eUPdatePhase Phase + { + set + { + this._phase = value; + } + } + + public int ManagedThreadId + { + get + { + return this._main_threadId; + } + } + + public bool Reboot { get; set; } + + public static readonly uint Major_Version = 1u; + + private static XLaunchMode _launch_mode = XLaunchMode.Live; + + public static GameObject XGameRoot = null; + + public static Assembly Ass = Assembly.GetAssembly(typeof(GameObject)); + + public static int Md5Length = 16; + + private int _main_threadId = 0; + + private bool _bEditorMode = false; + + private bool _bFetchVersion = false; + + private bool _bFetchServer = false; + + private StringBuilder _log = new StringBuilder(); + + private IEnumerator _downloader = null; + + private IEnumerator _download_prepare = null; + + private IEnumerator _comparer = null; + + private IEnumerator _launcher = null; + + private IEnumerator _finish = null; + + private byte[] _script = null; + + private bool _on_file_download_retry = false; + + private bool _on_file_download_need_retry = false; + + private bool _update_done = false; + + private bool _bundle_fetching = false; + + private bool _asset_loading = false; + + private XVersion _version_getter = null; + + private XBundle _bundle_getter = null; + + private XFileLog _filelog_getter = null; + + private IFMOD_Listener _fmod_listenter = null; + + private ITssSdk _tssSdk = null; + + private IApolloManager _apolloManager = null; + + private IBroardcast _broadcast = null; + + private ILuaEngine _lua_engine = null; + + private IXPandoraMgr _pandoraManager = null; + + private IXGameSirControl _SirControl = null; + + private IXVideo _video = null; + + private IPlatform _platform = null; + + private BuildTarget _runtime_platform = BuildTarget.Unknown; + + private string _platform_name = ""; + + private string _version = "0.0.0"; + + private string _target_version = "0.0.0"; + + private bool _need_check_file = false; + + private bool _need_play_cg = true; + + private XFetchVersionNetwork _fetch_version_network = null; + + private float _fetch_version_time = 0f; + + private ulong _update_pakcage_size = 0UL; + + private XVersionData _server = null; + + private XVersionData _client = null; + + private XVersionData _buildin = null; + + private IResourceHelp _resourcehelp = null; + + private XBundleData _bundle_data = null; + + private eUPdatePhase _phase = eUPdatePhase.xUP_None; + + private List _download_bundle = new List(); + + private List _cacheload_bundle = new List(); + + private List _meta_bundle = new List(); + + private Dictionary _persist_assets = new Dictionary(); + + private Dictionary _persist_image = new Dictionary(); + + private Dictionary _assets = new Dictionary(); + + private Dictionary _res_list = new Dictionary(); + + private Dictionary _bundles = new Dictionary(); + + public AssetBundleManager ABManager; + + private bool _is_download_update_pic = false; + + public override bool Init() + { + this._main_threadId = Thread.CurrentThread.ManagedThreadId; + this._bEditorMode = ((int)Application.platform == 7 || (int)Application.platform == 0 || (int)Application.platform == 2); + this.Reboot = false; + XUpdater.XGameRoot = GameObject.Find("XGamePoint"); + this.GetLaunchMode(); + RuntimePlatform platform = Application.platform; + if ((int)platform != 8) + { + if ((int)platform != 11) + { + this._runtime_platform = BuildTarget.Standalone; + this._platform_name = (this.PatchPrefix() ?? ""); + } + else + { + this._runtime_platform = BuildTarget.Android; + this._platform_name = this.PatchPrefix() + "Android/"; + } + } + else + { + this._runtime_platform = BuildTarget.IOS; + this._platform_name = this.PatchPrefix() + "IOS/"; + } + this._version_getter = XUpdater.XGameRoot.AddComponent(); + this._bundle_getter = XUpdater.XGameRoot.AddComponent(); + this._filelog_getter = XUpdater.XGameRoot.AddComponent(); + this._fmod_listenter = (GameObject.Find("Main Camera").GetComponent("FMOD_Listener") as IFMOD_Listener); + this._tssSdk = (XUpdater.XGameRoot.GetComponent("TssSDKManager") as ITssSdk); + this._apolloManager = (XUpdater.XGameRoot.GetComponent("ApolloManager") as IApolloManager); + this._broadcast = (XUpdater.XGameRoot.GetComponent("BroadcastManager") as IBroardcast); + this._platform = (XUpdater.XGameRoot.GetComponent("XPlatform") as IPlatform); + this._video = (XUpdater.XGameRoot.GetComponent("XVideoMgr") as IXVideo); + this._lua_engine = (XUpdater.XGameRoot.GetComponent("LuaEngine") as ILuaEngine); + this._pandoraManager = (XUpdater.XGameRoot.GetComponent("XPandoraMgr") as IXPandoraMgr); + this._SirControl = (XUpdater.XGameRoot.GetComponent("XGameSirControl") as IXGameSirControl); + bool flag = this._SirControl != null; + if (flag) + { + this._SirControl.Init(); + } + this.ABManager = XUpdater.XGameRoot.AddComponent(); + this.ABManager.Init(); + XSingleton.singleton.Init(this._platform, this._filelog_getter); + XSingleton.singleton.Init(); + XSingleton.singleton.Init(); + XBinaryReader.Init(); + UnityEngine.Object.DontDestroyOnLoad(XUpdater.XGameRoot); + return true; + } + + public override void Uninit() + { + foreach (AssetBundle assetBundle in this._bundles.Values) + { + assetBundle.Unload(false); + } + this._assets.Clear(); + this._persist_assets.Clear(); + this._bundles.Clear(); + this._res_list.Clear(); + bool flag = this._video != null && this._video.isPlaying; + if (flag) + { + this._video.Stop(); + } + this._phase = eUPdatePhase.xUP_Prepare; + this._update_done = false; + bool flag2 = this._fetch_version_network != null; + if (flag2) + { + this._fetch_version_network.Close(); + } + UnityEngine.Object.Destroy(XUpdater.XGameRoot); + } + + public void Clear() + { + foreach (KeyValuePair keyValuePair in this._bundles) + { + AssetBundle value = keyValuePair.Value; + value.Unload(false); + } + this._bundles.Clear(); + } + + public void Update() + { + switch (this._phase) + { + case eUPdatePhase.xUP_Prepare: + { + bool flag = this.Preparing(); + if (flag) + { + this._phase = eUPdatePhase.xUP_FetchVersion; + } + else + { + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_FETCHLOCALVERSIONERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + this.OnError(); + } + break; + } + case eUPdatePhase.xUP_FetchVersion: + { + bool flag2 = !this._bFetchVersion; + if (flag2) + { + bool flag3 = this._fetch_version_network == null; + if (flag3) + { + this._fetch_version_network = new XFetchVersionNetwork(); + } + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_INFO_FETCHVERSION"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + this._fetch_version_network.Init(); + string host = XSingleton.singleton.VersionServer.Substring(0, XSingleton.singleton.VersionServer.LastIndexOf(':')); + string s = XSingleton.singleton.VersionServer.Substring(XSingleton.singleton.VersionServer.LastIndexOf(':') + 1); + bool flag4 = this._fetch_version_network.Connect(host, int.Parse(s)); + if (flag4) + { + this._bFetchVersion = true; + this._fetch_version_time = Time.time; + } + else + { + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_FETCHVERSIONERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + this._fetch_version_network.Close(); + } + } + else + { + bool flag5 = Time.time - this._fetch_version_time > 5f; + if (flag5) + { + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_FETCHVERSIONERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + this._fetch_version_network.Close(); + } + } + break; + } + case eUPdatePhase.xUP_LoadVersion: + { + bool flag6 = !this._bFetchServer; + if (flag6) + { + this._cacheload_bundle.Clear(); + this._download_bundle.Clear(); + this._meta_bundle.Clear(); + this._version_getter.ServerDownload(new HandleVersionDownload(this.OnVersionDownloaded), new HandleVersionLoaded(this.OnVersionLoaded)); + } + this._bFetchServer = true; + break; + } + case eUPdatePhase.xUP_CompareVersion: + { + bool flag7 = this._comparer == null; + if (flag7) + { + this._comparer = this.VersionComparer(); + } + else + { + bool flag8 = !this._comparer.MoveNext(); + if (flag8) + { + this._comparer = null; + } + } + break; + } + case eUPdatePhase.xUP_DownLoadBundle: + { + bool flag9 = this._downloader == null; + if (flag9) + { + this._downloader = this.DownLoadBundles(); + } + else + { + bool flag10 = !this._downloader.MoveNext(); + if (flag10) + { + this._downloader = null; + this._phase = eUPdatePhase.xUP_ShowVersion; + } + } + break; + } + case eUPdatePhase.xUP_ShowVersion: + this.ShowVersionInfo(this._server, true); + break; + case eUPdatePhase.xUP_LaunchGame: + { + bool flag11 = this._launcher == null; + if (flag11) + { + this._launcher = this.LaunchGame(); + } + else + { + bool flag12 = !this._launcher.MoveNext(); + if (flag12) + { + this._launcher = null; + this.OnEnding(); + } + } + break; + } + case eUPdatePhase.xUP_Finish: + { + bool flag13 = this._finish == null; + if (flag13) + { + this._finish = this.Finish(); + } + else + { + bool flag14 = !this._finish.MoveNext(); + if (flag14) + { + this._finish = null; + this._update_done = true; + XSingleton.singleton.StartGame(); + } + } + break; + } + } + XSingleton.singleton.OnUpdate(); + } + + public void Begin() + { + this._update_done = false; + this._bFetchVersion = false; + this._bFetchServer = false; + bool flag = !XSingleton.singleton.SyncInit(); + if (flag) + { + this._log.Remove(0, this._log.Length); + this._log.Append("Error occurred when loading string table."); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + else + { + bool flag2 = !this.CheckMemory(); + if (flag2) + { + this._log.Remove(0, this._log.Length); + this._log.Append(XSingleton.singleton.GetString("XUPDATE_INFO_EXCLUDE1GPHONE")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + else + { + bool flag3 = XSingleton.singleton.EnableCache(); + if (flag3) + { + this._phase = eUPdatePhase.xUP_Prepare; + } + else + { + this._log.Remove(0, this._log.Length); + this._log.Append(XSingleton.singleton.GetString("XUPDATE_ERROR_ACCESSDENIED")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + } + } + } + + private IEnumerator Finish() + { + bool flag = this._server != null; + if (flag) + { + this._server.Bundles.Clear(); + this._version = this._server.ToString(); + } + this._server = null; + this._client = null; + this._buildin = null; + bool flag2 = this._need_play_cg && this._video != null; + if (flag2) + { + this._video.Play(false); + yield return null; + while (this._video.isPlaying) + { + yield return null; + } + } + UnityEngine.Object.DestroyObject(this._version_getter); + UnityEngine.Object.DestroyObject(this._bundle_getter); + yield break; + } + + public void OnError() + { + this._phase = eUPdatePhase.xUP_Error; + } + + public void DevStart() + { + this._phase = eUPdatePhase.xUP_ShowVersion; + } + + public void OnRetry() + { + eUPdatePhase phase = this._phase; + if (phase != eUPdatePhase.xUP_DownLoadBundle) + { + if (phase != eUPdatePhase.xUP_Finish) + { + if (phase == eUPdatePhase.xUP_Error) + { + bool flag = this._server == null; + if (flag) + { + this.Begin(); + } + } + } + else + { + bool isPlaying = this._video.isPlaying; + if (isPlaying) + { + this._video.Stop(); + } + } + } + else + { + bool on_file_download_need_retry = this._on_file_download_need_retry; + if (on_file_download_need_retry) + { + this._on_file_download_retry = true; + } + } + } + + private void OnEnding() + { + XSingleton.singleton.LoadingOK = true; + this._download_bundle.Clear(); + this._cacheload_bundle.Clear(); + this._meta_bundle.Clear(); + this._phase = eUPdatePhase.xUP_Ending; + } + + public bool ContainRes(uint hash) + { + return this._res_list.ContainsKey(hash); + } + + public UnityEngine.Object ResourceLoad(uint hash) + { + UnityEngine.Object result = null; + XResPackage xresPackage = null; + bool flag = this._res_list != null && this._res_list.TryGetValue(hash, out xresPackage); + if (flag) + { + bool flag2 = !this._persist_assets.TryGetValue(hash, out result); + if (flag2) + { + AssetBundle assetBundle = null; + uint key = XSingleton.singleton.XHash(xresPackage.bundle); + bool flag3 = !this._bundles.TryGetValue(key, out assetBundle); + if (flag3) + { + byte[] array = null; + bool flag4 = !this._persist_image.TryGetValue(key, out array); + if (flag4) + { + XBundleData data = null; + bool flag5 = this._assets.TryGetValue(key, out data); + if (!flag5) + { + return null; + } + array = XSingleton.singleton.LoadFile(XSingleton.singleton.GetLocalPath(data)); + } + assetBundle = AssetBundle.LoadFromMemory(array); + this._bundles.Add(key, assetBundle); + } + string text = xresPackage.location.Substring(xresPackage.location.LastIndexOf('/') + 1); + result = assetBundle.LoadAsset(text, XUpdater.Ass.GetType(xresPackage.type)); + } + } + return result; + } + + private AsyncVersionProcessRequest OnVersionDownloaded(TextAsset text) + { + AsyncVersionProcessRequest avpr = new AsyncVersionProcessRequest(); + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_INFO_FETCHMANIFEST"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + bool flag = text != null; + if (flag) + { + byte[] contents = text.bytes; + //! + new Thread((ThreadStart)delegate + { + avpr.IsCorrect = this.LoadVersion(contents); + avpr.IsDone = true; + }).Start(); + } + else + { + avpr.IsDone = true; + avpr.IsCorrect = false; + } + return avpr; + } + + private void OnVersionLoaded(bool correct) + { + if (correct) + { + this._phase = eUPdatePhase.xUP_CompareVersion; + } + else + { + this._log.Remove(0, this._log.Length); + this._log.Append(XSingleton.singleton.GetString("XUPDATE_ERROR_MANIFESTERROR")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + } + + private void OnBundleFetched(WWW www, byte[] bytes, XBundleData data, bool newdownload) + { + if (newdownload) + { + XSingleton.singleton.AddLog("Finished Download ", data.Name, null, null, null, null, XDebugColor.XDebug_None); + this._log.Remove(0, this._log.Length); + this._log.AppendFormat(XSingleton.singleton.GetString("XUPDATE_INFO_DOWNLOAD_FILE_COMPLETE"), data.Name); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + } + else + { + XSingleton.singleton.AddLog("Finished Extract ", data.Name, null, null, null, null, XDebugColor.XDebug_None); + this._log.Remove(0, this._log.Length); + this._log.AppendFormat(XSingleton.singleton.GetString("XUPDATE_INFO_EXTRACTING_COMPLETE"), data.Name); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + } + uint key = XSingleton.singleton.XHash(data.Name); + bool load = false; + this._bundle_data = data; + switch (this._bundle_data.Level) + { + case AssetLevel.Memory: + load = true; + break; + case AssetLevel.Image: + { + byte[] array = new byte[bytes.Length]; + bytes.CopyTo(array, 0); + this._persist_image.Add(key, array); + break; + } + } + this._assets.Add(key, this._bundle_data); + this._bundle_getter.GetBundle(www, bytes, new HandleLoadBundle(this.OnBundleLoaded), load); + } + + private void OnBundleLoaded(AssetBundle bundle) + { + bool flag = bundle != null; + if (flag) + { + this._bundles.Add(XSingleton.singleton.XHash(this._bundle_data.Name), bundle); + } + this._bundle_fetching = false; + } + + private void OnAssetLoaded(XResPackage package, UnityEngine.Object asset) + { + uint key = XSingleton.singleton.XHash(package.location); + bool flag = asset != null; + if (flag) + { + bool flag2 = !this._persist_assets.ContainsKey(key); + if (flag2) + { + this._persist_assets.Add(key, asset); + } + else + { + this._persist_assets[key] = asset; + } + } + this._asset_loading = false; + } + + private void UpdateLocalVersion(Stream s) + { + this._buildin = this.FetchBuildIn(s); + this._client = this.FetchBuildOut(); + bool flag = this._buildin != null; + if (flag) + { + XSingleton.singleton.AddLog("BuildIn version: ", this._buildin.ToString(), null, null, null, null, XDebugColor.XDebug_None); + } + bool flag2 = this._client != null; + if (flag2) + { + XSingleton.singleton.AddLog("BuildOut version: ", this._client.ToString(), null, null, null, null, XDebugColor.XDebug_None); + } + this._need_play_cg = (this._client == null); + bool flag3 = this._client == null; + if (flag3) + { + this._client = new XVersionData(this._buildin); + bool flag4 = !XSingleton.singleton.CleanCache(); + if (flag4) + { + this._log.Remove(0, this._log.Length); + this._log.Append(XSingleton.singleton.GetString("XUPDATE_ERROR_DELETEDENIED")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + } + else + { + int num = this._client.CompareTo(this._buildin); + bool flag5 = num < 0 || this._buildin.Build_Version != this._client.Build_Version; + if (flag5) + { + this._need_play_cg = true; + this._client.VersionCopy(this._buildin); + bool flag6 = !XSingleton.singleton.CleanCache(); + if (flag6) + { + this._log.Remove(0, this._log.Length); + this._log.Append(XSingleton.singleton.GetString("XUPDATE_ERROR_DELETEDENIED")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + } + } + XSingleton.singleton.AddLog("Client version: ", this._client.ToString(), null, null, null, null, XDebugColor.XDebug_None); + } + + private XVersionData FetchBuildIn(Stream s) + { + bool flag = s == null; + XVersionData result; + if (flag) + { + result = null; + } + else + { + StreamReader streamReader = new StreamReader(s); + string version = streamReader.ReadToEnd(); + result = XVersionData.Convert2Version(version); + } + return result; + } + + private XVersionData FetchBuildOut() + { + string localVersion = XVersion.GetLocalVersion(); + XSingleton.singleton.AddLog("Local Version Path " + localVersion, null, null, null, null, null, XDebugColor.XDebug_None); + XVersionData result = null; + bool flag = File.Exists(localVersion); + if (flag) + { + byte[] buffer = this.XCryptography(File.ReadAllBytes(localVersion)); + using (MemoryStream memoryStream = new MemoryStream(buffer)) + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(XVersionData)); + try + { + result = (xmlSerializer.Deserialize(memoryStream) as XVersionData); + } + catch (Exception ex) + { + result = null; + XSingleton.singleton.AddLog("Build Out Version Fetching FAILED! " + ex.Message, null, null, null, null, null, XDebugColor.XDebug_None); + } + finally + { + memoryStream.Close(); + } + } + } + else + { + XSingleton.singleton.AddLog("Local Version Path " + localVersion + " not exists.", null, null, null, null, null, XDebugColor.XDebug_None); + } + return result; + } + + private bool LoadVersion(byte[] text) + { + string a = BitConverter.ToString(text, 0, XUpdater.Md5Length); + string b = XSingleton.singleton.CalculateMD5(text, XUpdater.Md5Length, text.Length - XUpdater.Md5Length); + bool flag = a == b; + if (flag) + { + using (MemoryStream memoryStream = new MemoryStream(text, XUpdater.Md5Length, text.Length - XUpdater.Md5Length)) + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(XVersionData)); + this._server = (xmlSerializer.Deserialize(memoryStream) as XVersionData); + bool flag2 = this._server != null && this._server.Target_Platform == this._runtime_platform; + if (flag2) + { + XSingleton.singleton.AddLog("Server version: ", this._server.ToString(), null, null, null, null, XDebugColor.XDebug_None); + return true; + } + } + } + XSingleton.singleton.AddLog("Analysis Server version error!", null, null, null, null, null, XDebugColor.XDebug_None); + this._server = null; + return false; + } + + private bool CheckMemory() + { + return true; + } + + private bool Preparing() + { + Stream stream = null; + XSingleton.singleton.AddLog("Fetch local version...", null, null, null, null, null, XDebugColor.XDebug_None); + bool flag = (int)Application.platform == 8; + if (flag) + { + stream = XSingleton.singleton.ReadText("ios-version", ".bytes", false); + } + else + { + bool flag2 = (int)Application.platform == 11; + if (flag2) + { + stream = XSingleton.singleton.ReadText("android-version", ".bytes", false); + } + } + bool flag3 = stream != null; + bool result; + if (flag3) + { + this.UpdateLocalVersion(stream); + XSingleton.singleton.ClearStream(stream); + result = true; + } + else + { + result = (XUpdater.LaunchMode == XLaunchMode.Dev); + } + return result; + } + + private IEnumerator VersionComparer() + { + int compare = this._client.CompareTo(this._server); + this._update_pakcage_size = 0UL; + bool flag = compare > 0; + if (flag) + { + this._server = this._client; + this._download_prepare = null; + this.DownLoadConfirmed(false); + } + else + { + bool flag2 = compare == 0 || (compare < 0 && this._client.CanUpdated(this._server)); + if (flag2) + { + bool flag3 = this._download_prepare == null; + if (flag3) + { + this._download_prepare = this.DownLoadPrepare(); + } + while (this._download_prepare.MoveNext()) + { + yield return null; + } + this._download_prepare = null; + this.DownLoadConfirmed(compare != 0); + } + else + { + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_VERSIONNOTMATCH"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + this.ShowVersionInfo(this._client, false); + Texture tex = null; + bool flag4 = !this._is_download_update_pic; + if (flag4) + { + WWW www = new WWW("https://image.lzgjx.qq.com/sharingicon/updateimg.jpg"); + while (!www.isDone) + { + yield return null; + } + bool flag5 = string.IsNullOrEmpty(www.error); + if (flag5) + { + tex = www.texture; + } + www.Dispose(); + this._is_download_update_pic = true; + www = null; + } + this._phase = eUPdatePhase.xUP_Error; + XSingleton.singleton.SetDownLoad(new XLoadingUI.OnSureCallBack(this.ToAppStore), tex); + tex = null; + } + } + yield break; + } + + private void ToAppStore() + { + RuntimePlatform platform = Application.platform; + if ((int)platform != 8) + { + if ((int)platform == 11) + { + for (int i = 0; i < this._client.Res.Count; i++) + { + bool flag = this._client.Res[i].location == "Table/StringTable"; + if (flag) + { + XBundleData specificBundle = this._client.GetSpecificBundle(this._client.Res[i].bundle); + string localPath = XSingleton.singleton.GetLocalPath(specificBundle); + try + { + byte[] array = File.ReadAllBytes(localPath); + bool flag2 = array != null; + if (flag2) + { + AssetBundle assetBundle = AssetBundle.LoadFromMemory(array); + bool flag3 = assetBundle != null; + if (flag3) + { + TextAsset textAsset = assetBundle.LoadAsset("StringTable", typeof(TextAsset)) as TextAsset; + bool flag4 = textAsset != null; + if (flag4) + { + bool flag5 = !XSingleton.singleton.ReInit(textAsset); + if (flag5) + { + XSingleton.singleton.SyncInit(); + } + } + } + } + } + catch (Exception ex) + { + XSingleton.singleton.AddErrorLog("ToAndroidAppStore: ", ex.Message, null, null, null, null); + } + break; + } + } + string @string = XSingleton.singleton.GetString("XUPDATE_ERROR_VERSIONNOTMATCH_ANDROID_URL"); + XSingleton.singleton.AddLog("AndroidAppStore Url: ", @string, null, null, null, null, XDebugColor.XDebug_None); + Application.OpenURL(@string); + } + } + else + { + for (int j = 0; j < this._client.Res.Count; j++) + { + bool flag6 = this._client.Res[j].location == "Table/StringTable"; + if (flag6) + { + XBundleData specificBundle2 = this._client.GetSpecificBundle(this._client.Res[j].bundle); + string localPath2 = XSingleton.singleton.GetLocalPath(specificBundle2); + try + { + byte[] array2 = File.ReadAllBytes(localPath2); + bool flag7 = array2 != null; + if (flag7) + { + AssetBundle assetBundle2 = AssetBundle.LoadFromMemory(array2); + bool flag8 = assetBundle2 != null; + if (flag8) + { + TextAsset textAsset2 = assetBundle2.LoadAsset("StringTable", typeof(TextAsset)) as TextAsset; + bool flag9 = textAsset2 != null; + if (flag9) + { + bool flag10 = !XSingleton.singleton.ReInit(textAsset2); + if (flag10) + { + XSingleton.singleton.SyncInit(); + } + } + } + } + } + catch (Exception ex2) + { + XSingleton.singleton.AddErrorLog("ToAppStore: ", ex2.Message, null, null, null, null); + } + break; + } + } + string string2 = XSingleton.singleton.GetString("XUPDATE_ERROR_VERSIONNOTMATCH_URL"); + XSingleton.singleton.AddLog("AppStore Url: ", string2, null, null, null, null, XDebugColor.XDebug_None); + Application.OpenURL(string2); + } + } + + private void DownLoadConfirmedCallBack() + { + this._phase = eUPdatePhase.xUP_DownLoadBundle; + } + + private void DownLoadCancelledCallBack() + { + this._phase = eUPdatePhase.xUP_Error; + XSingleton.singleton.SetStatus("", byte.MaxValue, byte.MaxValue, byte.MaxValue); + this.ShowVersionInfo(this._client, false); + } + + private void DownLoadConfirmed(bool updated) + { + if (updated) + { + bool flag = this._update_pakcage_size < 1048576UL; + if (flag) + { + this.DownLoadConfirmedCallBack(); + } + else + { + XSingleton.singleton.SetDialog(this._update_pakcage_size, new XLoadingUI.OnSureCallBack(this.DownLoadConfirmedCallBack), new XLoadingUI.OnSureCallBack(this.DownLoadCancelledCallBack)); + this._phase = eUPdatePhase.xUP_DownLoadConfirm; + } + } + else + { + this._phase = eUPdatePhase.xUP_DownLoadBundle; + } + } + + private IEnumerator DownLoadPrepare() + { + int num; + for (int i = 0; i < this._server.Res.Count; i = num + 1) + { + bool flag = !this._buildin.NeedDownload(this._server.Res[i].bundle); + if (!flag) + { + XBundleData bundle = this._server.GetSpecificBundle(this._server.Res[i].bundle); + bool flag2 = bundle == null; + if (flag2) + { + XSingleton.singleton.AddLog("Bundle ", this._server.Res[i].bundle, " is missing in sever bundle set.", null, null, null, XDebugColor.XDebug_None); + } + else + { + bool flag3 = this._cacheload_bundle.Contains(bundle); + if (!flag3) + { + bool flag4 = this._download_bundle.Contains(bundle); + if (!flag4) + { + AsyncCachedRequest acr = XSingleton.singleton.IsBundleCached(bundle, this._server.MD5_Size); + while (!acr.IsDone) + { + yield return null; + } + bool flag5 = !acr.Cached && acr.MaybeCached; + if (flag5) + { + XBundleData clientData = null; + foreach (XBundleData data in this._client.Bundles) + { + bool flag6 = data.Name == bundle.Name; + if (flag6) + { + clientData = data; + break; + } + //data = null; + } + List.Enumerator enumerator = default(List.Enumerator); + acr.Cached = (clientData != null && clientData.MD5 == bundle.MD5); + clientData = null; + } + XSingleton.singleton.AddLog("Bundle ", bundle.Name, " cached is ", acr.Cached.ToString(), null, null, XDebugColor.XDebug_None); + bool cached = acr.Cached; + if (cached) + { + this._cacheload_bundle.Add(bundle); + } + else + { + this._download_bundle.Add(bundle); + this._update_pakcage_size += (ulong)bundle.Size; + } + bundle = null; + acr = null; + } + } + } + } + num = i; + } + this.MetaPrepare(this._server.AB); + this.MetaPrepare(this._server.Scene); + this.MetaPrepare(this._server.FMOD); + yield break; + } + + private void MetaPrepare(List meta) + { + bool flag = this._platform != null && !this._platform.IsPublish(); + for (int i = 0; i < meta.Count; i++) + { + bool flag2 = !this._buildin.NeedDownload(meta[i].bundle) || !this._client.NeedDownload(meta[i].bundle); + if (!flag2) + { + bool flag3 = !this._meta_bundle.Contains(meta[i]); + if (flag3) + { + this._meta_bundle.Add(meta[i]); + } + bool flag4 = flag; + if (flag4) + { + XSingleton.singleton.AddLog("Meta ", meta[i].download, " is prepared to downloading...", null, null, null, XDebugColor.XDebug_None); + } + this._update_pakcage_size += (ulong)meta[i].Size; + } + } + } + + private IEnumerator DownLoadBundles() + { + bool log = this._platform != null && !this._platform.IsPublish(); + int total = this._download_bundle.Count + this._cacheload_bundle.Count + this._meta_bundle.Count; + int processed = 0; + int num; + for (int i = 0; i < this._download_bundle.Count; i = num + 1) + { + while (this._bundle_fetching) + { + yield return null; + } + bool flag = log; + if (flag) + { + XSingleton.singleton.AddLog("Updating ", this._download_bundle[i].Name, " ... ", processed.ToString(), "/", total.ToString(), XDebugColor.XDebug_None); + } + this._bundle_fetching = true; + num = processed + 1; + processed = num; + XSingleton.singleton.Download(this._download_bundle[i], new HandleFetchBundle(this.OnBundleFetched), (float)processed / (float)total); + num = i; + } + for (int j = 0; j < this._cacheload_bundle.Count; j = num + 1) + { + while (this._bundle_fetching) + { + yield return null; + } + bool flag2 = log; + if (flag2) + { + XSingleton.singleton.AddLog("Extracting ", this._cacheload_bundle[j].Name, " ... ", processed.ToString(), "/", total.ToString(), XDebugColor.XDebug_None); + } + this._bundle_fetching = true; + num = processed + 1; + processed = num; + bool flag3 = (int)Application.platform == 8; + if (flag3) + { + while (!XSingleton.singleton.Extract(this._cacheload_bundle[j], new HandleFetchBundle(this.OnBundleFetched), (float)processed / (float)total)) + { + yield return null; + } + } + else + { + XSingleton.singleton.Extract(this._cacheload_bundle[j], new HandleFetchBundle(this.OnBundleFetched), (float)processed / (float)total); + } + num = j; + } + while (this._bundle_fetching) + { + yield return null; + } + for (int k = 0; k < this._meta_bundle.Count; k = num + 1) + { + num = processed + 1; + processed = num; + AsyncWriteRequest awr = XSingleton.singleton.Download(this._meta_bundle[k].download, this._meta_bundle[k].Size, (float)processed / (float)total); + bool flag4 = log; + if (flag4) + { + XSingleton.singleton.AddLog("Download meta ", this._meta_bundle[k].download, " ... ", processed.ToString(), "/", total.ToString(), XDebugColor.XDebug_None); + } + while (!awr.IsDone) + { + bool hasError = awr.HasError; + if (hasError) + { + bool on_file_download_retry = this._on_file_download_retry; + if (on_file_download_retry) + { + this._on_file_download_retry = false; + this._on_file_download_need_retry = false; + num = k; + k = num - 1; + num = processed; + processed = num - 1; + this._log.Length = 0; + this._log.Append(XSingleton.singleton.GetString("XUPDATE_INFO_RETRY")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + yield return null; + break; + } + this._on_file_download_need_retry = true; + this._log.Length = 0; + this._log.AppendFormat(XSingleton.singleton.GetString("XUPDATE_ERROR_DOWNLOADRESFAILED_AND_RETRY"), awr.Name); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + yield return null; + } + else + { + yield return null; + } + } + awr = null; + num = k; + } + for (int l = 0; l < this._server.Res.Count; l = num + 1) + { + bool flag5 = this.ProcessAssets(this._server.Res[l]); + if (flag5) + { + bool flag6 = this._server.Res[l].rtype != ResourceType.Script; + if (flag6) + { + uint hash = XSingleton.singleton.XHash(this._server.Res[l].location); + this._res_list.Add(hash, this._server.Res[l]); + } + this._log.Remove(0, this._log.Length); + this._log.AppendFormat(XSingleton.singleton.GetString("XUPDATE_INFO_PRELOADING"), ((float)l / (float)this._server.Res.Count * 100f).ToString("F0")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + bool flag7 = l << 30 == 0; + if (flag7) + { + yield return null; + } + } + num = l; + } + AsyncLogRequest alr = this.LogNewVersion(); + while (!alr.IsDone) + { + Thread.Sleep(1); + } + this.XPlatform.SetNoBackupFlag(XVersion.GetLocalVersion()); + yield break; + } + + private AsyncLogRequest LogNewVersion() + { + AsyncLogRequest alr = new AsyncLogRequest(); + bool flag = this._server != this._client; + if (flag) + { + new Thread((ThreadStart)delegate + { + using (MemoryStream memoryStream = new MemoryStream()) + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(XVersionData)); + XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); + xmlSerializerNamespaces.Add(string.Empty, string.Empty); + xmlSerializer.Serialize(memoryStream, this._server, xmlSerializerNamespaces); + File.WriteAllBytes(XVersion.GetLocalVersion(), this.XCryptography(memoryStream.ToArray())); + } + alr.IsDone = true; + }).Start(); + } + else + { + alr.IsDone = true; + } + return alr; + } + + private void ShowVersionInfo(XVersionData data, bool launch = true) + { + bool flag = data != null; + if (flag) + { + this._log.Remove(0, this._log.Length); + this._log.Append("v").Append(data.ToString()); + XSingleton.singleton.SetVersion(this._log.ToString()); + } + else + { + XSingleton.singleton.SetVersion("Dev 0.0.0"); + } + if (launch) + { + this._phase = eUPdatePhase.xUP_LaunchGame; + } + } + + private bool ProcessAssets(XResPackage res) + { + AssetBundle assetBundle = null; + bool flag = this._bundles.TryGetValue(XSingleton.singleton.XHash(res.bundle), out assetBundle); + bool result; + if (flag) + { + string text = res.location.Substring(res.location.LastIndexOf('/') + 1); + ResourceType rtype = res.rtype; + if (rtype != ResourceType.Assets) + { + if (rtype == ResourceType.Script) + { + TextAsset textAsset = assetBundle.LoadAsset(text, XUpdater.Ass.GetType(res.type)) as TextAsset; + this._script = textAsset.bytes; + assetBundle.Unload(false); + this._bundles.Remove(XSingleton.singleton.XHash(res.bundle)); + } + } + else + { + this.OnAssetLoaded(res, assetBundle.LoadAsset(text, XUpdater.Ass.GetType(res.type))); + } + result = true; + } + else + { + result = false; + } + return result; + } + + private IEnumerator AsyncProcessAssets(XResPackage package, AssetBundle bundle) + { + string name = package.location.Substring(package.location.LastIndexOf('/') + 1); + this._asset_loading = true; + this._bundle_getter.GetAsset(bundle, package, new HandleLoadAsset(this.OnAssetLoaded)); + while (this._asset_loading) + { + yield return null; + } + yield break; + } + + private IEnumerator LaunchGame() + { + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_INFO_LOADING"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + yield return null; + this.ABManager.Init(); + this.XPlatform.ReloadFMOD(); + AsyncAssemblyRequest aar = new AsyncAssemblyRequest(); + ResourceRequest rrq = null; + bool flag = (int) Application.platform == 11; + if (flag) + { + string path = Application.persistentDataPath + "/XMainClient.bytes"; + bool flag2 = File.Exists(path); + if (flag2) + { + this._script = File.ReadAllBytes(path); + } + bool flag3 = this._script == null && (int)Application.platform == 11; + if (flag3) + { + rrq = Resources.LoadAsync("XMainClient", typeof(TextAsset)); + yield return rrq; + this._script = (rrq.asset as TextAsset).bytes; + } + path = null; + } + RuntimePlatform platform = Application.platform; + if ((int)platform != 8) + { + if ((int)platform != 11) + { + } + //! + // aar.Main = ((this._script == null) ? Assembly.Load("XMainClient") : Assembly.Load(this._script)); + } + else + { +// aar.Main = Assembly.Load("XMainClient"); + } + // XSingleton.singleton.MakeEntrance(aar.Main); + XSingleton.singleton._MakeEntrance(); + + bool flag4 = rrq != null && rrq.asset != null; + if (flag4) + { + Resources.UnloadAsset(rrq.asset); + } + this._script = null; + this._log.Remove(0, this._log.Length); + this._log.Append(XSingleton.singleton.GetString("XUPDATE_INFO_LAUNCHING")); + XSingleton.singleton.SetStatus(this._log.ToString(), byte.MaxValue, byte.MaxValue, byte.MaxValue); + yield return null; + XSingleton.singleton.PreLaunch(); + while (!XSingleton.singleton.Launched()) + { + yield return null; + XSingleton.singleton.Launch(); + } + this.XLuaEngine.InitLua(); + yield break; + } + + private byte[] XCryptography(byte[] bs) + { + for (int i = 0; i < bs.Length; i++) + { + bs[i] ^= 154; + } + return bs; + } + + private string PatchPrefix() + { + XLaunchMode launchMode = XUpdater.LaunchMode; + string result; + if (launchMode != XLaunchMode.Live) + { + if (launchMode != XLaunchMode.PreProduct) + { + if (launchMode != XLaunchMode.Dev) + { + result = "Patch/Live/"; + } + else + { + result = "Patch/Dev/"; + } + } + else + { + result = "Patch/PreProduct/"; + } + } + else + { + result = "Patch/Live/"; + } + return result; + } + + private void GetLaunchMode() + { + XUpdater._launch_mode = XLaunchMode.Dev; + } + + public void PlayCG(object o = null) + { + this._video.Play(false); + } + + public void SetServerVersion(string data) + { + string b = ""; + bool flag = this._buildin != null; + if (flag) + { + b = this._buildin.Build_Version.ToString(); + } + string[] array = data.Split(new char[] + { + '|' + }); + RuntimePlatform platform = Application.platform; + if ((int)platform != 8) + { + if ((int)platform == 11) + { + this._target_version = array[1]; + try + { + bool flag2 = array.Length > 4; + if (flag2) + { + string[] array2 = array[4].Split(new char[] + { + ':' + }); + for (int i = 0; i < array2.Length; i++) + { + string[] array3 = array2[i].Split(new char[] + { + '.' + }); + bool flag3 = array3.Length > 1 && array3[1] == b; + if (flag3) + { + this._target_version = array2[i]; + } + } + } + } + catch (Exception ex) + { + XSingleton.singleton.AddErrorLog("GetServer ExData Error!!! " + ex.Message, null, null, null, null, null); + } + } + } + else + { + this._target_version = array[0]; + try + { + bool flag4 = array.Length > 3; + if (flag4) + { + string[] array4 = array[3].Split(new char[] + { + ':' + }); + for (int j = 0; j < array4.Length; j++) + { + string[] array5 = array4[j].Split(new char[] + { + '.' + }); + bool flag5 = array5.Length > 1 && array5[1] == b; + if (flag5) + { + this._target_version = array4[j]; + } + } + } + } + catch (Exception ex2) + { + XSingleton.singleton.AddErrorLog("GetServer ExData Error!!! " + ex2.Message, null, null, null, null, null); + } + } + try + { + bool flag6 = array.Length > 2; + if (flag6) + { + this._need_check_file = (array[2] == "1"); + } + } + catch (Exception ex3) + { + XSingleton.singleton.AddErrorLog("GetServer CheckFile Flag Error!!! " + ex3.Message, null, null, null, null, null); + } + XSingleton.singleton.AddGreenLog(data, null, null, null, null, null); + this._fetch_version_network.Close(); + this._phase = eUPdatePhase.xUP_LoadVersion; + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs.meta new file mode 100644 index 00000000..5c15329c --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XUpdater.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f2420f6e29a73574bb6c20d4c46e16fa +timeCreated: 1611465807 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs new file mode 100644 index 00000000..6c9759de --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs @@ -0,0 +1,174 @@ +using System; +using System.Collections; +using System.IO; +using System.Threading; +using UnityEngine; +using XUtliPoolLib; + +namespace XUpdater +{ + internal sealed class XVersion : MonoBehaviour + { + public static string VERSION_FILE + { + get + { + return string.Format("manifest.{0}.assetbundle", XSingleton.singleton.TargetVersion.ToString()); + } + } + + public static readonly string LOCAL_VERSION_FILE = "manifest.asset"; + + private WWW _server_Version = null; + + private uint _time_out_token = 0u; + + private delegate void HandleFinishDownload(WWW www, string error); + + public static string GetLocalVersion() + { + return XSingleton.singleton.UpdatePath + XVersion.LOCAL_VERSION_FILE; + } + + public void ServerDownload(HandleVersionDownload callback1, HandleVersionLoaded callback2) + { + base.StopAllCoroutines(); + string text = XSingleton.singleton.HostUrl + XSingleton.singleton.Platform; + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_INFO_CONNECTING"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.AddLog("connecting to update server: ", text, null, null, null, null, XDebugColor.XDebug_None); + this._time_out_token = XSingleton.singleton.SetTimer(5f, new XTimerMgr.ElapsedEventHandler(this.OnTimeOut), null); + base.StartCoroutine(this.DownloadVersion(XSingleton.singleton.MakeToken(text + XVersion.VERSION_FILE), callback1, callback2)); + } + + private IEnumerator DownloadVersion(string url, HandleVersionDownload callback1, HandleVersionLoaded callback2) + { + this._server_Version = new WWW(url); + yield return this._server_Version; + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_INFO_CHECKUPDATING"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.KillTimer(this._time_out_token); + bool flag = this._server_Version != null; + if (flag) + { + bool flag2 = string.IsNullOrEmpty(this._server_Version.error); + if (flag2) + { + bool flag3 = callback1 != null; + if (flag3) + { + AssetBundle ab = this._server_Version.assetBundle; + bool flag4 = ab == null; + if (flag4) + { + XSingleton.singleton.AddErrorLog("load server manifest bundle error.", null, null, null, null, null); + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + else + { + UnityEngine.Object asset = ab.LoadAsset("manifest", typeof(TextAsset)); + bool flag5 = asset == null; + if (flag5) + { + XSingleton.singleton.AddErrorLog("load server manifest bundle error.", null, null, null, null, null); + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + else + { + AsyncVersionProcessRequest avpr = callback1(asset as TextAsset); + while (!avpr.IsDone) + { + Thread.Sleep(1); + } + bool flag6 = callback2 != null; + if (flag6) + { + callback2(avpr.IsCorrect); + } + ab.Unload(false); + avpr = null; + } + asset = null; + } + ab = null; + } + } + else + { + bool flag7 = XUpdater.LaunchMode == XLaunchMode.Dev; + if (flag7) + { + XSingleton.singleton.DevStart(); + } + else + { + XSingleton.singleton.AddErrorLog(this._server_Version.error, null, null, null, null, null); + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + } + this._server_Version.Dispose(); + this._server_Version = null; + } + else + { + XSingleton.singleton.AddErrorLog("ERROR: _server_Version is NULL!", null, null, null, null, null); + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + yield break; + } + + private IEnumerator LocalDownload(XVersion.HandleFinishDownload callback) + { + string path = Application.persistentDataPath + XVersion.VERSION_FILE; + bool flag = !File.Exists(path); + if (flag) + { + bool flag2 = callback != null; + if (flag2) + { + callback(null, null); + } + } + else + { + string local_location = "file://" + path; + WWW localVersion = new WWW(local_location); + yield return localVersion; + bool flag3 = callback != null; + if (flag3) + { + callback(localVersion, localVersion.error); + } + localVersion.Dispose(); + localVersion = null; + local_location = null; + localVersion = null; + } + yield break; + } + + private void OnTimeOut(object o) + { + bool flag = XUpdater.LaunchMode == XLaunchMode.Dev; + if (flag) + { + XSingleton.singleton.DevStart(); + bool flag2 = (int)Application.platform == 7 || Application.platform == 0; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Connect to update server timeout...", null, null, null, null, null); + } + } + else + { + XSingleton.singleton.SetStatus(XSingleton.singleton.GetString("XUPDATE_ERROR_CANNOTCONNECTTOSERVER"), byte.MaxValue, byte.MaxValue, byte.MaxValue); + XSingleton.singleton.OnError(); + } + base.StopAllCoroutines(); + this._server_Version.Dispose(); + this._server_Version = null; + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs.meta new file mode 100644 index 00000000..4c400128 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersion.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dc1c1d77f6956704f90eda9af3c6ef9b +timeCreated: 1611465795 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs new file mode 100644 index 00000000..714d2189 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs @@ -0,0 +1,287 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using XUtliPoolLib; + +namespace XUpdater +{ + [Serializable] + public class XVersionData : IComparable + { + public bool HasRCVersion + { + get + { + return this.rc_Build_Version > 0u || this.rc_Minor_Version > 0u; + } + } + + public bool IsNewly + { + get + { + return this.Build_Version == 0u && this.Minor_Version == 0u; + } + } + + public uint Major_Version + { + get + { + return this._major_version; + } + } + + private static readonly string pattern = "^(\\d+).(\\d+).(\\d+)(.(\\d+)p(\\d+))?\\b"; + + private static Regex r = new Regex(XVersionData.pattern); + + private uint _major_version; + + public uint Build_Version = 0u; + + public uint Minor_Version = 0u; + + public uint rc_Build_Version = 0u; + + public uint rc_Minor_Version = 0u; + + public uint MD5_Size = 1048576u; + + public BuildTarget Target_Platform = BuildTarget.Unknown; + + public List Bundles = new List(); + + public List Res = new List(); + + public List AB = new List(); + + public List Scene = new List(); + + public List FMOD = new List(); + + public XVersionData() + { + this._major_version = XUpdater.Major_Version; + } + + public XVersionData(uint major) + { + this._major_version = major; + } + + public XVersionData(XVersionData rhs) : this() + { + this.VersionCopy(rhs); + } + + public void VersionCopy(XVersionData rhs) + { + bool flag = rhs == null; + if (flag) + { + this.Build_Version = 0u; + this.Minor_Version = 0u; + this.rc_Build_Version = 0u; + this.rc_Minor_Version = 0u; + } + else + { + this.Build_Version = rhs.Build_Version; + this.Minor_Version = rhs.Minor_Version; + this.rc_Build_Version = rhs.rc_Build_Version; + this.rc_Minor_Version = rhs.rc_Minor_Version; + } + } + + public void RC() + { + bool hasRCVersion = this.HasRCVersion; + if (!hasRCVersion) + { + this.rc_Build_Version = 1u; + } + } + + public XVersionData Increment(bool rebuild) + { + XVersionData xversionData = new XVersionData(this); + if (rebuild) + { + bool hasRCVersion = this.HasRCVersion; + if (hasRCVersion) + { + xversionData.rc_Build_Version += 1u; + xversionData.rc_Minor_Version = 0u; + } + else + { + xversionData.Build_Version += 1u; + xversionData.Minor_Version = 0u; + xversionData.rc_Build_Version = 0u; + xversionData.rc_Minor_Version = 0u; + } + } + else + { + bool hasRCVersion2 = this.HasRCVersion; + if (hasRCVersion2) + { + xversionData.rc_Minor_Version += 1u; + } + else + { + xversionData.Minor_Version += 1u; + xversionData.rc_Build_Version = 0u; + xversionData.rc_Minor_Version = 0u; + } + } + return xversionData; + } + + public override string ToString() + { + return this.HasRCVersion ? string.Format("{0}.{1}.{2}.{3}p{4}", new object[] + { + this._major_version, + this.Build_Version, + this.Minor_Version, + this.rc_Build_Version, + this.rc_Minor_Version + }) : string.Format("{0}.{1}.{2}", this._major_version, this.Build_Version, this.Minor_Version); + } + + public static XVersionData Convert2Version(string version) + { + Match match = XVersionData.r.Match(version); + bool success = match.Success; + XVersionData result; + if (success) + { + XVersionData xversionData = new XVersionData(uint.Parse(match.Groups[1].Value)); + xversionData.Build_Version = uint.Parse(match.Groups[2].Value); + xversionData.Minor_Version = uint.Parse(match.Groups[3].Value); + bool flag = !string.IsNullOrEmpty(match.Groups[4].Value); + if (flag) + { + xversionData.rc_Build_Version = uint.Parse(match.Groups[5].Value); + xversionData.rc_Minor_Version = uint.Parse(match.Groups[6].Value); + } + result = xversionData; + } + else + { + result = null; + } + return result; + } + + public int CompareTo(XVersionData other) + { + bool flag = other == null; + int result; + if (flag) + { + result = 1; + } + else + { + bool flag2 = this._major_version == other.Major_Version; + if (flag2) + { + bool flag3 = this.Build_Version == other.Build_Version; + if (flag3) + { + bool flag4 = this.Minor_Version == other.Minor_Version; + if (flag4) + { + bool flag5 = this.rc_Build_Version == other.rc_Build_Version; + if (flag5) + { + bool flag6 = this.rc_Minor_Version == other.rc_Minor_Version; + if (flag6) + { + result = 0; + } + else + { + result = (int)(this.rc_Minor_Version - other.rc_Minor_Version); + } + } + else + { + result = (int)(this.rc_Build_Version - other.rc_Build_Version); + } + } + else + { + result = (int)(this.Minor_Version - other.Minor_Version); + } + } + else + { + result = (int)(this.Build_Version - other.Build_Version); + } + } + else + { + result = (int)(this._major_version - other.Major_Version); + } + } + return result; + } + + public bool CanUpdated(XVersionData other) + { + bool flag = this._major_version == other.Major_Version; + if (flag) + { + bool flag2 = this.Build_Version == other.Build_Version; + if (flag2) + { + bool flag3 = this.Minor_Version == other.Minor_Version; + if (!flag3) + { + return !this.HasRCVersion && !other.HasRCVersion; + } + bool flag4 = this.rc_Build_Version == other.rc_Build_Version; + if (flag4) + { + return true; + } + } + } + return false; + } + + public bool NeedDownload(string version) + { + XVersionData xversionData = XVersionData.Convert2Version(version); + bool flag = xversionData == null; + bool result; + if (flag) + { + XSingleton.singleton.AddErrorLog("Error bundle with name ", version, null, null, null, null); + result = false; + } + else + { + result = (this.CompareTo(xversionData) < 0); + } + return result; + } + + public XBundleData GetSpecificBundle(string name) + { + for (int i = 0; i < this.Bundles.Count; i++) + { + bool flag = name == this.Bundles[i].Name; + if (flag) + { + return this.Bundles[i]; + } + } + return null; + } + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs.meta new file mode 100644 index 00000000..d316b132 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XVersionData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 167c1ce87a560024da3c8f9f142f83da +timeCreated: 1611465295 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs new file mode 100644 index 00000000..560b15cd --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs @@ -0,0 +1,20 @@ +using System; + +namespace XUpdater +{ + internal enum eUPdatePhase + { + xUP_None, + xUP_Prepare, + xUP_FetchVersion, + xUP_LoadVersion, + xUP_CompareVersion, + xUP_DownLoadConfirm, + xUP_DownLoadBundle, + xUP_ShowVersion, + xUP_LaunchGame, + xUP_Ending, + xUP_Finish, + xUP_Error + } +} diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs.meta b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs.meta new file mode 100644 index 00000000..a4dd6f19 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/eUPdatePhase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b8a4179b6e8aefe4aadb7ec6af562313 +timeCreated: 1611465748 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.1-26-g67d0