summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/AssetBundleDataReader.cs
blob: 91c20af25823a6e86c7834a38646a2a425373f3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.IO;

namespace XUtliPoolLib
{
	public class AssetBundleDataReader
	{
		public Dictionary<uint, AssetBundleData> infoMap = new Dictionary<uint, AssetBundleData>();

		protected Dictionary<uint, uint> shortName2FullName = new Dictionary<uint, uint>();

		public virtual void Read(XBinaryReader reader)
		{
			MemoryStream stream = new MemoryStream(reader.GetBuffer());
			StreamReader streamReader = new StreamReader(stream);
			char[] array = new char[6];
			streamReader.Read(array, 0, array.Length);
			bool flag = array[0] != 'A' || array[1] != 'B' || array[2] != 'D' || array[3] != 'T';
			if (!flag)
			{
				for (;;)
				{
					string text = streamReader.ReadLine();
					bool flag2 = string.IsNullOrEmpty(text);
					if (flag2)
					{
						break;
					}
					uint num = uint.Parse(streamReader.ReadLine().Replace(".ab", ""));
					string str = streamReader.ReadLine();
					uint key = XSingleton<XCommon>.singleton.XHash(str);
					string text2 = streamReader.ReadLine();
					int compositeType = Convert.ToInt32(streamReader.ReadLine());
					int num2 = Convert.ToInt32(streamReader.ReadLine());
					uint[] array2 = new uint[num2];
					bool flag3 = !this.shortName2FullName.ContainsKey(key);
					if (flag3)
					{
						this.shortName2FullName.Add(key, num);
					}
					for (int i = 0; i < num2; i++)
					{
						array2[i] = uint.Parse(streamReader.ReadLine().Replace(".ab", ""));
					}
					streamReader.ReadLine();
					AssetBundleData assetBundleData = new AssetBundleData();
					assetBundleData.debugName = text;
					assetBundleData.fullName = num;
					assetBundleData.dependencies = array2;
					assetBundleData.compositeType = (AssetBundleExportType)compositeType;
					this.infoMap[num] = assetBundleData;
				}
				streamReader.Close();
			}
		}

		public void Analyze()
		{
			foreach (KeyValuePair<uint, AssetBundleData> keyValuePair in this.infoMap)
			{
				this.Analyze(keyValuePair.Value);
			}
		}

		private void Analyze(AssetBundleData abd)
		{
			bool flag = !abd.isAnalyzed;
			if (flag)
			{
				abd.isAnalyzed = true;
				bool flag2 = abd.dependencies != null;
				if (flag2)
				{
					abd.dependList = new AssetBundleData[abd.dependencies.Length];
					for (int i = 0; i < abd.dependencies.Length; i++)
					{
						AssetBundleData assetBundleInfo = this.GetAssetBundleInfo(abd.dependencies[i]);
						abd.dependList[i] = assetBundleInfo;
						this.Analyze(assetBundleInfo);
					}
				}
			}
		}

		public uint GetFullName(uint shortName)
		{
			uint result = 0u;
			this.shortName2FullName.TryGetValue(shortName, out result);
			return result;
		}

		public AssetBundleData GetAssetBundleInfoByShortName(uint shortName)
		{
			uint fullName = this.GetFullName(shortName);
			bool flag = fullName != 0u && this.infoMap.ContainsKey(fullName);
			AssetBundleData result;
			if (flag)
			{
				result = this.infoMap[fullName];
			}
			else
			{
				result = null;
			}
			return result;
		}

		public AssetBundleData GetAssetBundleInfo(uint fullName)
		{
			bool flag = fullName > 0u;
			if (flag)
			{
				bool flag2 = this.infoMap.ContainsKey(fullName);
				if (flag2)
				{
					return this.infoMap[fullName];
				}
			}
			return null;
		}
	}
}