From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/DecalLoadTask.cs | 125 +++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/DecalLoadTask.cs (limited to 'Client/Assets/Scripts/XMainClient/DecalLoadTask.cs') diff --git a/Client/Assets/Scripts/XMainClient/DecalLoadTask.cs b/Client/Assets/Scripts/XMainClient/DecalLoadTask.cs new file mode 100644 index 00000000..a2b7a206 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/DecalLoadTask.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class DecalLoadTask : EquipLoadTask + { + public Texture2D decalTex = null; + + protected LoadAsyncTask loadTask = null; + + protected LoadCallBack loadCb = null; + + private PartLoadTask faceTask = null; + + private PartLoadCallback m_PartLoadCb = null; + + public DecalLoadTask(EPartType p, PartLoadCallback partLoadCb, PartLoadTask face) : base(p) + { + this.loadCb = new LoadCallBack(this.LoadFinish); + this.faceTask = face; + this.m_PartLoadCb = partLoadCb; + } + + public override void Load(XEntity e, int prefessionID, ref FashionPositionInfo newFpi, bool async, HashSet 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) + { + if (async) + { + this.loadTask = XSingleton.singleton.GetShareResourceAsync(this.location, ".tga", this.loadCb, this); + } + else + { + Texture2D sharedResource = XSingleton.singleton.GetSharedResource(this.location, ".tga", true, false); + this.LoadFinish(sharedResource, this); + } + } + else + { + bool flag4 = this.m_PartLoadCb != null; + if (flag4) + { + this.m_PartLoadCb(this, false); + } + } + } + } + + private void LoadFinish(UnityEngine.Object obj, object cbOjb) + { + bool flag = this.processStatus == EProcessStatus.EProcessing; + if (flag) + { + this.processStatus = EProcessStatus.EPreProcess; + this.decalTex = (obj as Texture2D); + bool flag2 = this.m_PartLoadCb != null; + if (flag2) + { + this.m_PartLoadCb(this, false); + } + } + } + + public override void Reset(XEntity e) + { + base.Reset(e); + bool flag = this.decalTex != null; + if (flag) + { + XSingleton.singleton.UnSafeDestroyShareResource(this.location, ".tga", this.decalTex, false); + this.decalTex = null; + } + bool flag2 = this.loadTask != null; + if (flag2) + { + this.loadTask.CancelLoad(this.loadCb); + this.loadTask = null; + } + } + + public void PostLoad(CombineMeshTask combineMeshTask) + { + bool flag = this.decalTex != null; + Texture texture; + if (flag) + { + texture = this.decalTex; + } + else + { + texture = this.faceTask.GetTexture(); + } + bool flag2 = texture != null; + if (flag2) + { + bool isOnepart = combineMeshTask.isOnepart; + if (isOnepart) + { + ShaderManager.SetTexture(combineMeshTask.mpb, texture, ShaderManager._ShaderKeyIDFace); + } + else + { + ShaderManager.SetTexture(combineMeshTask.mpb, texture, ShaderManager._ShaderKeyIDSkin[0]); + } + } + this.processStatus = EProcessStatus.EProcessed; + } + } +} -- cgit v1.1-26-g67d0