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 meshPartsInfo = null; public Dictionary replaceMeshPartsInfo = null; public Dictionary 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.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.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.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(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(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(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.singleton.AddErrorLog(ex.Message, null, null, null, null, null); } } XSingleton.singleton.ClearBinary(xbinaryReader, true); } } }