diff options
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/PartLoadTask.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/PartLoadTask.cs | 297 |
1 files changed, 297 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/PartLoadTask.cs b/Client/Assets/Scripts/XMainClient/PartLoadTask.cs new file mode 100644 index 00000000..8270b6de --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/PartLoadTask.cs @@ -0,0 +1,297 @@ +using System;
+using System.Collections.Generic;
+using KKSG;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class PartLoadTask : EquipLoadTask
+ {
+ private string replaceMeshLocation = null;
+
+ private string replaceTexLocation = null;
+
+ public byte partType = 0;
+
+ public Mesh mesh = null;
+
+ private Texture2D tex = null;
+
+ private Texture2D aplhaTex = null;
+
+ private byte loadState = 0;
+
+ private static PartLoadTask.MeshPart fakeMeshPart = new PartLoadTask.MeshPart();
+
+ private static PartLoadTask.TexPart fakeTexPart = new PartLoadTask.TexPart();
+
+ private static PartLoadTask.AlphaTexPart fakeAlphaTexPart = new PartLoadTask.AlphaTexPart();
+
+ private LoadAsyncTask meshLoadTask = null;
+
+ private LoadAsyncTask texLoadTask = null;
+
+ private LoadAsyncTask alphaLoadTask = null;
+
+ private LoadCallBack loadCb = null;
+
+ private PartLoadCallback m_PartLoadCb = null;
+
+ private class MeshPart
+ {
+ }
+
+ private class TexPart
+ {
+ }
+
+ private class AlphaTexPart
+ {
+ }
+
+ public PartLoadTask(EPartType p, PartLoadCallback partLoadCb) : base(p)
+ {
+ this.loadCb = new LoadCallBack(this.LoadFinish);
+ this.m_PartLoadCb = partLoadCb;
+ }
+
+ public override void Load(XEntity e, int prefessionID, ref FashionPositionInfo newFpi, bool async, HashSet<string> loadedPath)
+ {
+ bool flag = base.IsSamePart(ref newFpi);
+ if (flag)
+ {
+ bool flag2 = this.m_PartLoadCb != null;
+ if (flag2)
+ {
+ this.m_PartLoadCb(this, false);
+ }
+ }
+ else
+ {
+ this.Reset(e);
+ bool flag3 = base.MakePath(ref newFpi, loadedPath);
+ if (flag3)
+ {
+ this.replaceMeshLocation = null;
+ this.replaceTexLocation = null;
+ bool meshInfo = XEquipDocument._MeshPartList.GetMeshInfo(this.location, prefessionID, (int)this.part, newFpi.fashionDir, out this.partType, ref this.replaceMeshLocation, ref this.replaceTexLocation);
+ if (meshInfo)
+ {
+ if (async)
+ {
+ bool flag4 = this.replaceMeshLocation != null;
+ if (flag4)
+ {
+ this.meshLoadTask = XSingleton<XResourceLoaderMgr>.singleton.GetShareResourceAsync<Mesh>(this.replaceMeshLocation, ".asset", this.loadCb, PartLoadTask.fakeMeshPart);
+ }
+ else
+ {
+ this.meshLoadTask = XSingleton<XResourceLoaderMgr>.singleton.GetShareResourceAsync<Mesh>(this.location, ".asset", this.loadCb, PartLoadTask.fakeMeshPart);
+ }
+ bool flag5 = this.replaceTexLocation != null;
+ if (flag5)
+ {
+ this.texLoadTask = XSingleton<XResourceLoaderMgr>.singleton.GetShareResourceAsync<Texture2D>(this.replaceTexLocation, ".tga", this.loadCb, PartLoadTask.fakeTexPart);
+ bool flag6 = this.partType == XMeshPartList.CutoutPart;
+ if (flag6)
+ {
+ this.alphaLoadTask = XSingleton<XResourceLoaderMgr>.singleton.GetShareResourceAsync<Texture2D>(this.replaceTexLocation + "_A", ".png", this.loadCb, PartLoadTask.fakeAlphaTexPart);
+ }
+ }
+ else
+ {
+ this.texLoadTask = XSingleton<XResourceLoaderMgr>.singleton.GetShareResourceAsync<Texture2D>(this.location, ".tga", this.loadCb, PartLoadTask.fakeTexPart);
+ bool flag7 = this.partType == XMeshPartList.CutoutPart;
+ if (flag7)
+ {
+ this.alphaLoadTask = XSingleton<XResourceLoaderMgr>.singleton.GetShareResourceAsync<Texture2D>(this.location + "_A", ".png", this.loadCb, PartLoadTask.fakeAlphaTexPart);
+ }
+ }
+ }
+ else
+ {
+ bool flag8 = this.replaceMeshLocation != null;
+ Mesh sharedResource;
+ if (flag8)
+ {
+ sharedResource = XSingleton<XResourceLoaderMgr>.singleton.GetSharedResource<Mesh>(this.replaceMeshLocation, ".asset", true, false);
+ }
+ else
+ {
+ sharedResource = XSingleton<XResourceLoaderMgr>.singleton.GetSharedResource<Mesh>(this.location, ".asset", true, false);
+ }
+ this.LoadFinish(sharedResource, PartLoadTask.fakeMeshPart);
+ bool flag9 = this.replaceTexLocation != null;
+ if (flag9)
+ {
+ Texture2D sharedResource2 = XSingleton<XResourceLoaderMgr>.singleton.GetSharedResource<Texture2D>(this.replaceTexLocation, ".tga", true, false);
+ this.LoadFinish(sharedResource2, PartLoadTask.fakeTexPart);
+ bool flag10 = this.partType == XMeshPartList.CutoutPart;
+ if (flag10)
+ {
+ Texture2D sharedResource3 = XSingleton<XResourceLoaderMgr>.singleton.GetSharedResource<Texture2D>(this.replaceTexLocation + "_A", ".png", true, false);
+ this.LoadFinish(sharedResource3, PartLoadTask.fakeAlphaTexPart);
+ }
+ }
+ else
+ {
+ Texture2D sharedResource4 = XSingleton<XResourceLoaderMgr>.singleton.GetSharedResource<Texture2D>(this.location, ".tga", true, false);
+ this.LoadFinish(sharedResource4, PartLoadTask.fakeTexPart);
+ bool flag11 = this.partType == XMeshPartList.CutoutPart;
+ if (flag11)
+ {
+ Texture2D sharedResource5 = XSingleton<XResourceLoaderMgr>.singleton.GetSharedResource<Texture2D>(this.location + "_A", ".png", true, false);
+ this.LoadFinish(sharedResource5, PartLoadTask.fakeAlphaTexPart);
+ }
+ }
+ }
+ }
+ else
+ {
+ this.processStatus = EProcessStatus.EPreProcess;
+ bool flag12 = this.m_PartLoadCb != null;
+ if (flag12)
+ {
+ this.m_PartLoadCb(this, true);
+ }
+ }
+ }
+ else
+ {
+ bool flag13 = this.m_PartLoadCb != null;
+ if (flag13)
+ {
+ this.m_PartLoadCb(this, true);
+ }
+ }
+ }
+ }
+
+ private void LoadFinish(UnityEngine.Object obj, object cbOjb)
+ {
+ bool flag = this.processStatus == EProcessStatus.EProcessing;
+ if (flag)
+ {
+ bool flag2 = cbOjb is PartLoadTask.MeshPart;
+ if (flag2)
+ {
+ this.mesh = (obj as Mesh);
+ this.loadState |= 1;
+ this.meshLoadTask = null;
+ }
+ else
+ {
+ bool flag3 = cbOjb is PartLoadTask.TexPart;
+ if (flag3)
+ {
+ Texture2D texture2D = obj as Texture2D;
+ this.tex = texture2D;
+ this.texLoadTask = null;
+ this.loadState |= 2;
+ }
+ else
+ {
+ bool flag4 = cbOjb is PartLoadTask.AlphaTexPart;
+ if (flag4)
+ {
+ Texture2D texture2D2 = obj as Texture2D;
+ this.aplhaTex = texture2D2;
+ this.alphaLoadTask = null;
+ this.loadState |= 4;
+ }
+ else
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("assert error equip type", null, null, null, null, null);
+ }
+ }
+ }
+ bool flag5 = XMeshPartList.ConvertType(this.partType) == this.loadState;
+ if (flag5)
+ {
+ this.processStatus = EProcessStatus.EPreProcess;
+ bool flag6 = this.m_PartLoadCb != null;
+ if (flag6)
+ {
+ this.m_PartLoadCb(this, true);
+ }
+ }
+ }
+ }
+
+ public override void Reset(XEntity e)
+ {
+ bool flag = this.mesh != null;
+ if (flag)
+ {
+ bool flag2 = !string.IsNullOrEmpty(this.replaceMeshLocation);
+ if (flag2)
+ {
+ XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroyShareResource(this.replaceMeshLocation, ".asset", this.mesh, XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL);
+ }
+ else
+ {
+ XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroyShareResource(this.location, ".asset", this.mesh, XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL);
+ }
+ this.mesh = null;
+ }
+ this.replaceMeshLocation = null;
+ bool flag3 = this.tex != null;
+ if (flag3)
+ {
+ bool flag4 = !string.IsNullOrEmpty(this.replaceTexLocation);
+ if (flag4)
+ {
+ XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroyShareResource(this.replaceTexLocation, ".tga", this.tex, XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL);
+ }
+ else
+ {
+ XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroyShareResource(this.location, ".tga", this.tex, XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL);
+ }
+ this.tex = null;
+ }
+ bool flag5 = this.aplhaTex != null;
+ if (flag5)
+ {
+ XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroyShareResource(this.location + "_A", ".png", this.aplhaTex, XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL);
+ this.aplhaTex = null;
+ }
+ this.replaceTexLocation = null;
+ this.loadState = 0;
+ bool flag6 = this.meshLoadTask != null;
+ if (flag6)
+ {
+ this.meshLoadTask.CancelLoad(this.loadCb);
+ this.meshLoadTask = null;
+ }
+ bool flag7 = this.texLoadTask != null;
+ if (flag7)
+ {
+ this.texLoadTask.CancelLoad(this.loadCb);
+ this.texLoadTask = null;
+ }
+ bool flag8 = this.alphaLoadTask != null;
+ if (flag8)
+ {
+ this.alphaLoadTask.CancelLoad(this.loadCb);
+ this.alphaLoadTask = null;
+ }
+ base.Reset(e);
+ }
+
+ public bool HasMesh()
+ {
+ return this.mesh != null;
+ }
+
+ public Texture2D GetTexture()
+ {
+ return this.tex;
+ }
+
+ public Texture2D GetAlpha()
+ {
+ return this.aplhaTex;
+ }
+ }
+}
|