diff options
Diffstat (limited to 'Client/Assets/Scripts/XUtliPoolLib/XMeshPartList.cs')
-rw-r--r-- | Client/Assets/Scripts/XUtliPoolLib/XMeshPartList.cs | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XUtliPoolLib/XMeshPartList.cs b/Client/Assets/Scripts/XUtliPoolLib/XMeshPartList.cs new file mode 100644 index 00000000..3d0ce82c --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XMeshPartList.cs @@ -0,0 +1,229 @@ +using System;
+using System.Collections.Generic;
+
+namespace XUtliPoolLib
+{
+ public class XMeshPartList
+ {
+ public static byte NormalPart = 1;
+
+ public static byte OnePart = 3;
+
+ public static byte CutoutPart = 7;
+
+ public static byte ReplacePart = 8;
+
+ public static byte ReplaceTex = 16;
+
+ public static byte ShareTex = 32;
+
+ public string[] partSuffix = new string[9];
+
+ public string[] proPrefix = null;
+
+ public string sharedPrefix = null;
+
+ public Dictionary<uint, byte> meshPartsInfo = null;
+
+ public Dictionary<uint, string> replaceMeshPartsInfo = null;
+
+ public Dictionary<uint, string> replaceTexPartsInfo = null;
+
+ public static byte ConvertType(byte type)
+ {
+ byte result;
+ if (type != 1)
+ {
+ if (type != 3)
+ {
+ if (type != 7)
+ {
+ result = 3;
+ }
+ else
+ {
+ result = 7;
+ }
+ }
+ else
+ {
+ result = 3;
+ }
+ }
+ else
+ {
+ result = 3;
+ }
+ return result;
+ }
+
+ public bool GetMeshInfo(string location, int professionType, int part, string srcDir, out byte partType, ref string meshLocation, ref string texLocation)
+ {
+ partType = 0;
+ uint key = XSingleton<XCommon>.singleton.XHash(location);
+ bool flag = this.meshPartsInfo.TryGetValue(key, out partType);
+ bool result;
+ if (flag)
+ {
+ bool flag2 = partType > XMeshPartList.CutoutPart;
+ if (flag2)
+ {
+ bool flag3 = (partType & XMeshPartList.ReplacePart) > 0;
+ if (flag3)
+ {
+ partType &= (byte)~XMeshPartList.ReplacePart;
+ bool flag4 = this.replaceMeshPartsInfo.TryGetValue(key, out meshLocation);
+ if (flag4)
+ {
+ string text = this.proPrefix[professionType];
+ string arg = this.partSuffix[part];
+ meshLocation = string.Format("Equipments/{0}/{1}{2}", meshLocation, text, arg);
+ key = XSingleton<XCommon>.singleton.XHash(meshLocation);
+ }
+ }
+ bool flag5 = (partType & XMeshPartList.ReplaceTex) > 0;
+ if (flag5)
+ {
+ partType &= (byte) ~XMeshPartList.ReplaceTex;
+ bool flag6 = this.replaceTexPartsInfo.TryGetValue(key, out texLocation);
+ if (flag6)
+ {
+ bool flag7 = texLocation.StartsWith("/");
+ if (flag7)
+ {
+ bool flag8 = string.IsNullOrEmpty(srcDir);
+ if (flag8)
+ {
+ texLocation = null;
+ }
+ else
+ {
+ bool flag9 = srcDir.StartsWith("/");
+ if (flag9)
+ {
+ texLocation = string.Format("Equipments{0}{1}", srcDir, texLocation);
+ }
+ else
+ {
+ texLocation = string.Format("Equipments/{0}{1}", srcDir, texLocation);
+ }
+ }
+ }
+ else
+ {
+ texLocation = string.Format("Equipments/Player/{0}", texLocation);
+ }
+ }
+ }
+ else
+ {
+ bool flag10 = (partType & XMeshPartList.ShareTex) > 0;
+ if (flag10)
+ {
+ partType &= (byte) ~XMeshPartList.ShareTex;
+ bool flag11 = this.proPrefix != null && professionType < this.proPrefix.Length;
+ if (flag11)
+ {
+ string text = this.proPrefix[professionType];
+ texLocation = location.Replace(text, this.sharedPrefix);
+ }
+ }
+ }
+ }
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+
+ public void Load()
+ {
+ bool flag = this.meshPartsInfo != null;
+ if (flag)
+ {
+ this.meshPartsInfo.Clear();
+ }
+ bool flag2 = this.replaceMeshPartsInfo != null;
+ if (flag2)
+ {
+ this.replaceMeshPartsInfo.Clear();
+ }
+ XBinaryReader xbinaryReader = XSingleton<XResourceLoaderMgr>.singleton.ReadBinary("Equipments/equipmentInfo", ".bytes", true, true);
+ bool flag3 = xbinaryReader != null;
+ if (flag3)
+ {
+ try
+ {
+ int num = xbinaryReader.ReadInt32();
+ this.proPrefix = new string[num];
+ for (int i = 0; i < num; i++)
+ {
+ this.proPrefix[i] = xbinaryReader.ReadString(-1);
+ }
+ int num2 = xbinaryReader.ReadInt32();
+ for (int j = 0; j < num2; j++)
+ {
+ bool flag4 = j < this.partSuffix.Length;
+ if (flag4)
+ {
+ this.partSuffix[j] = xbinaryReader.ReadString(-1);
+ }
+ }
+ this.sharedPrefix = xbinaryReader.ReadString(-1);
+ int num3 = xbinaryReader.ReadInt32();
+ string[] array = new string[num3];
+ for (int k = 0; k < num3; k++)
+ {
+ array[k] = xbinaryReader.ReadString(-1);
+ }
+ int num4 = xbinaryReader.ReadInt32();
+ bool flag5 = this.meshPartsInfo == null;
+ if (flag5)
+ {
+ this.meshPartsInfo = new Dictionary<uint, byte>(num4);
+ }
+ for (int l = 0; l < num4; l++)
+ {
+ uint key = xbinaryReader.ReadUInt32();
+ byte value = xbinaryReader.ReadByte();
+ this.meshPartsInfo[key] = value;
+ }
+ num4 = xbinaryReader.ReadInt32();
+ bool flag6 = this.replaceMeshPartsInfo == null;
+ if (flag6)
+ {
+ this.replaceMeshPartsInfo = new Dictionary<uint, string>(num4);
+ }
+ for (int m = 0; m < num4; m++)
+ {
+ uint key2 = xbinaryReader.ReadUInt32();
+ ushort num5 = xbinaryReader.ReadUInt16();
+ string value2 = array[(int)num5];
+ this.replaceMeshPartsInfo[key2] = value2;
+ }
+ num4 = xbinaryReader.ReadInt32();
+ bool flag7 = this.replaceTexPartsInfo == null;
+ if (flag7)
+ {
+ this.replaceTexPartsInfo = new Dictionary<uint, string>(num4);
+ }
+ for (int n = 0; n < num4; n++)
+ {
+ uint key3 = xbinaryReader.ReadUInt32();
+ ushort num6 = xbinaryReader.ReadUInt16();
+ string value3 = array[(int)num6];
+ this.replaceTexPartsInfo[key3] = value3;
+ }
+ }
+ catch (Exception ex)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog(ex.Message, null, null, null, null, null);
+ }
+ }
+ XSingleton<XResourceLoaderMgr>.singleton.ClearBinary(xbinaryReader, true);
+ }
+ }
+}
|