addressablestools 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AddressablesTools/AddressablesCatalogFileParser.py +104 -0
- AddressablesTools/Binary/ContentCatalogDataBinaryHeader.py +45 -0
- AddressablesTools/Binary/__init__.py +0 -0
- AddressablesTools/Catalog/ClassJsonObject.py +18 -0
- AddressablesTools/Catalog/ContentCatalogData.py +255 -0
- AddressablesTools/Catalog/ObjectInitializationData.py +39 -0
- AddressablesTools/Catalog/ResourceLocation.py +121 -0
- AddressablesTools/Catalog/SerializedObjectDecoder.py +151 -0
- AddressablesTools/Catalog/SerializedType.py +46 -0
- AddressablesTools/Catalog/WrappedSerializedObject.py +20 -0
- AddressablesTools/Catalog/__init__.py +0 -0
- AddressablesTools/CatalogFileType.py +10 -0
- AddressablesTools/Classes/AssetBundleRequestOptions.py +154 -0
- AddressablesTools/Classes/Hash128.py +16 -0
- AddressablesTools/Classes/TypeReference.py +11 -0
- AddressablesTools/Classes/__init__.py +0 -0
- AddressablesTools/Const.py +5 -0
- AddressablesTools/JSON/ContentCatalogDataJson.py +69 -0
- AddressablesTools/JSON/ObjectInitializationDataJson.py +20 -0
- AddressablesTools/JSON/SerializedTypeJson.py +14 -0
- AddressablesTools/JSON/__init__.py +0 -0
- AddressablesTools/Reader/BinaryReader.py +40 -0
- AddressablesTools/Reader/CatalogBinaryReader.py +86 -0
- AddressablesTools/Reader/__init__.py +0 -0
- AddressablesTools/__init__.py +23 -0
- AddressablesTools/classes.py +23 -0
- addressablestools-0.1.0.dist-info/METADATA +72 -0
- addressablestools-0.1.0.dist-info/RECORD +31 -0
- addressablestools-0.1.0.dist-info/WHEEL +5 -0
- addressablestools-0.1.0.dist-info/licenses/LICENSE +19 -0
- addressablestools-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from io import BytesIO
|
|
3
|
+
|
|
4
|
+
from .CatalogFileType import CatalogFileType
|
|
5
|
+
from .JSON.ContentCatalogDataJson import ContentCatalogDataJson
|
|
6
|
+
from .JSON.ObjectInitializationDataJson import ObjectInitializationDataJson
|
|
7
|
+
from .JSON.SerializedTypeJson import SerializedTypeJson
|
|
8
|
+
from .Catalog.ContentCatalogData import ContentCatalogData
|
|
9
|
+
from .Reader.CatalogBinaryReader import CatalogBinaryReader
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def serializedTypeDecoder(obj: dict):
|
|
13
|
+
return SerializedTypeJson.New(obj["m_AssemblyName"], obj["m_ClassName"])
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def objectInitializationDataDecoder(obj: dict):
|
|
17
|
+
_m_ObjectType = obj["m_ObjectType"]
|
|
18
|
+
m_ObjectType = SerializedTypeJson.New(
|
|
19
|
+
_m_ObjectType["m_AssemblyName"], _m_ObjectType["m_ClassName"]
|
|
20
|
+
)
|
|
21
|
+
return ObjectInitializationDataJson.New(obj["m_Id"], m_ObjectType, obj["m_Data"])
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def contentCatalogDataDecoder(obj: dict):
|
|
25
|
+
_m_InstanceProviderData = obj["m_InstanceProviderData"]
|
|
26
|
+
_m_SceneProviderData = obj["m_SceneProviderData"]
|
|
27
|
+
_m_ResourceProviderData = obj["m_ResourceProviderData"]
|
|
28
|
+
|
|
29
|
+
m_InstanceProviderData = ObjectInitializationDataJson.New(
|
|
30
|
+
_m_InstanceProviderData["m_Id"],
|
|
31
|
+
SerializedTypeJson.New(
|
|
32
|
+
_m_InstanceProviderData["m_ObjectType"]["m_AssemblyName"],
|
|
33
|
+
_m_InstanceProviderData["m_ObjectType"]["m_ClassName"],
|
|
34
|
+
),
|
|
35
|
+
_m_InstanceProviderData["m_Data"],
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
m_SceneProviderData = ObjectInitializationDataJson.New(
|
|
39
|
+
_m_SceneProviderData["m_Id"],
|
|
40
|
+
SerializedTypeJson.New(
|
|
41
|
+
_m_SceneProviderData["m_ObjectType"]["m_AssemblyName"],
|
|
42
|
+
_m_SceneProviderData["m_ObjectType"]["m_ClassName"],
|
|
43
|
+
),
|
|
44
|
+
_m_SceneProviderData["m_Data"],
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
m_ResourceProviderData = [
|
|
48
|
+
ObjectInitializationDataJson.New(
|
|
49
|
+
o["m_Id"],
|
|
50
|
+
SerializedTypeJson.New(
|
|
51
|
+
o["m_ObjectType"]["m_AssemblyName"], o["m_ObjectType"]["m_ClassName"]
|
|
52
|
+
),
|
|
53
|
+
o["m_Data"],
|
|
54
|
+
)
|
|
55
|
+
for o in _m_ResourceProviderData
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
return ContentCatalogDataJson.New(
|
|
59
|
+
obj["m_LocatorId"],
|
|
60
|
+
obj.get("m_BuildResultHash"),
|
|
61
|
+
m_InstanceProviderData,
|
|
62
|
+
m_SceneProviderData,
|
|
63
|
+
m_ResourceProviderData,
|
|
64
|
+
obj["m_ProviderIds"],
|
|
65
|
+
obj["m_InternalIds"],
|
|
66
|
+
obj["m_KeyDataString"],
|
|
67
|
+
obj["m_BucketDataString"],
|
|
68
|
+
obj["m_EntryDataString"],
|
|
69
|
+
obj["m_ExtraDataString"],
|
|
70
|
+
obj.get("m_Keys"),
|
|
71
|
+
[
|
|
72
|
+
SerializedTypeJson.New(o["m_AssemblyName"], o["m_ClassName"])
|
|
73
|
+
for o in obj["m_resourceTypes"]
|
|
74
|
+
],
|
|
75
|
+
obj.get("m_InternalIdPrefixes"),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class AddressablesCatalogFileParser:
|
|
80
|
+
@staticmethod
|
|
81
|
+
def CCDJsonFromString(data: str) -> ContentCatalogDataJson:
|
|
82
|
+
return contentCatalogDataDecoder(json.loads(data))
|
|
83
|
+
|
|
84
|
+
@staticmethod
|
|
85
|
+
def FromBinaryData(data: bytes) -> ContentCatalogData:
|
|
86
|
+
ms = BytesIO(data)
|
|
87
|
+
reader = CatalogBinaryReader(ms)
|
|
88
|
+
catalogData = ContentCatalogData()
|
|
89
|
+
catalogData.ReadBinary(reader)
|
|
90
|
+
return catalogData
|
|
91
|
+
|
|
92
|
+
@staticmethod
|
|
93
|
+
def FromJsonString(data: str) -> ContentCatalogData:
|
|
94
|
+
ccdJson = AddressablesCatalogFileParser.CCDJsonFromString(data)
|
|
95
|
+
catalogData = ContentCatalogData()
|
|
96
|
+
catalogData.ReadJson(ccdJson)
|
|
97
|
+
return catalogData
|
|
98
|
+
|
|
99
|
+
@staticmethod
|
|
100
|
+
def GetCatalogFileType() -> CatalogFileType:
|
|
101
|
+
return CatalogFileType.Null
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
__all__ = ["AddressablesCatalogFileParser"]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from ..Reader import CatalogBinaryReader
|
|
2
|
+
from ..Const import uint
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ContentCatalogDataBinaryHeader:
|
|
6
|
+
Magic: int
|
|
7
|
+
Version: int
|
|
8
|
+
KeysOffset: int
|
|
9
|
+
IdOffset: int
|
|
10
|
+
InstanceProviderOffset: int
|
|
11
|
+
SceneProviderOffset: int
|
|
12
|
+
InitObjectsArrayOffset: int
|
|
13
|
+
BuildResultHashOffset: int
|
|
14
|
+
|
|
15
|
+
def __repr__(self):
|
|
16
|
+
return (
|
|
17
|
+
f"<{self.__class__.__name__}(Magic={self.Magic}, Version={self.Version})>"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
def __init__(self):
|
|
21
|
+
self.Magic = 0
|
|
22
|
+
self.Version = 0
|
|
23
|
+
self.KeysOffset = 0
|
|
24
|
+
self.IdOffset = 0
|
|
25
|
+
self.InstanceProviderOffset = 0
|
|
26
|
+
self.SceneProviderOffset = 0
|
|
27
|
+
self.InitObjectsArrayOffset = 0
|
|
28
|
+
self.BuildResultHashOffset = 0
|
|
29
|
+
|
|
30
|
+
def Read(self, reader: CatalogBinaryReader):
|
|
31
|
+
self.Magic = reader.ReadInt32()
|
|
32
|
+
self.Version = reader.ReadInt32()
|
|
33
|
+
if self.Version not in [1, 2]:
|
|
34
|
+
raise Exception("Only versions 1 and 2 are supported")
|
|
35
|
+
reader.Version = self.Version
|
|
36
|
+
|
|
37
|
+
self.KeysOffset = reader.ReadUInt32()
|
|
38
|
+
self.IdOffset = reader.ReadUInt32()
|
|
39
|
+
self.InstanceProviderOffset = reader.ReadUInt32()
|
|
40
|
+
self.SceneProviderOffset = reader.ReadUInt32()
|
|
41
|
+
self.InitObjectsArrayOffset = reader.ReadUInt32()
|
|
42
|
+
if self.Version == 1 and self.KeysOffset == 0x20:
|
|
43
|
+
self.BuildResultHashOffset = uint.MaxValue
|
|
44
|
+
else:
|
|
45
|
+
self.BuildResultHashOffset = reader.ReadUInt32()
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from .SerializedType import SerializedType
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ClassJsonObject:
|
|
5
|
+
Type: SerializedType
|
|
6
|
+
JsonText: str | None
|
|
7
|
+
|
|
8
|
+
def __repr__(self):
|
|
9
|
+
return f"<{self.__class__.__name__}(Type={self.Type})>"
|
|
10
|
+
|
|
11
|
+
def __init__(self, assemblyName: str, className: str, jsonText: str):
|
|
12
|
+
self.Type = SerializedType()
|
|
13
|
+
self.Type.AssemblyName = assemblyName
|
|
14
|
+
self.Type.ClassName = className
|
|
15
|
+
self.JsonText = className
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = ["ClassJsonObject"]
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
from io import BytesIO
|
|
2
|
+
from base64 import b64decode
|
|
3
|
+
|
|
4
|
+
from .ObjectInitializationData import ObjectInitializationData
|
|
5
|
+
from .ResourceLocation import ResourceLocation
|
|
6
|
+
from .SerializedObjectDecoder import SerializedObjectDecoder
|
|
7
|
+
from .SerializedType import SerializedType
|
|
8
|
+
from ..Binary.ContentCatalogDataBinaryHeader import ContentCatalogDataBinaryHeader
|
|
9
|
+
from ..JSON.ContentCatalogDataJson import ContentCatalogDataJson
|
|
10
|
+
from ..Reader.CatalogBinaryReader import CatalogBinaryReader
|
|
11
|
+
from ..Reader.BinaryReader import BinaryReader
|
|
12
|
+
from ..Catalog.ClassJsonObject import ClassJsonObject
|
|
13
|
+
from ..Classes.TypeReference import TypeReference
|
|
14
|
+
from ..Classes.Hash128 import Hash128
|
|
15
|
+
from ..Catalog.WrappedSerializedObject import WrappedSerializedObject
|
|
16
|
+
from ..Classes.AssetBundleRequestOptions import AssetBundleRequestOptions
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ContentCatalogData:
|
|
20
|
+
Version: int
|
|
21
|
+
|
|
22
|
+
LocatorId: str | None
|
|
23
|
+
BuildResultHash: str | None
|
|
24
|
+
InstanceProviderData: ObjectInitializationData | None
|
|
25
|
+
SceneProviderData: ObjectInitializationData | None
|
|
26
|
+
ResourceProviderData: list[ObjectInitializationData] | None
|
|
27
|
+
ProviderIds: list[str] | None
|
|
28
|
+
InternalIds: list[str] | None
|
|
29
|
+
Keys: list[str] | None
|
|
30
|
+
ResourceTypes: list[SerializedType] | None
|
|
31
|
+
InternalIdPrefixes: list[str] | None
|
|
32
|
+
Resources: dict[object, list[ResourceLocation]] | None
|
|
33
|
+
|
|
34
|
+
Header: ContentCatalogDataBinaryHeader | None
|
|
35
|
+
|
|
36
|
+
class Bucket:
|
|
37
|
+
offset: int
|
|
38
|
+
entries: list[int]
|
|
39
|
+
|
|
40
|
+
def __repr__(self):
|
|
41
|
+
return f"<{self.__class__.__name__}>"
|
|
42
|
+
|
|
43
|
+
def __init__(self, offset: int, entries: list[int]):
|
|
44
|
+
self.offset = offset
|
|
45
|
+
self.entries = entries
|
|
46
|
+
|
|
47
|
+
def __repr__(self):
|
|
48
|
+
return f"<{self.__class__.__name__}(LocatorId={self.LocatorId}, BuildResultHash={self.BuildResultHash})>"
|
|
49
|
+
|
|
50
|
+
def __init__(self):
|
|
51
|
+
self.LocatorId = None
|
|
52
|
+
self.BuildResultHash = None
|
|
53
|
+
self.InstanceProviderData = None
|
|
54
|
+
self.SceneProviderData = None
|
|
55
|
+
self.ResourceProviderData = None
|
|
56
|
+
self.ProviderIds = None
|
|
57
|
+
self.InternalIds = None
|
|
58
|
+
self.Keys = None
|
|
59
|
+
self.ResourceTypes = None
|
|
60
|
+
self.InternalIdPrefixes = None
|
|
61
|
+
self.Resources = None
|
|
62
|
+
|
|
63
|
+
self.Header = None
|
|
64
|
+
|
|
65
|
+
def ReadJson(self, data: ContentCatalogDataJson):
|
|
66
|
+
self.LocatorId = data.m_LocatorId
|
|
67
|
+
self.BuildResultHash = data.m_BuildResultHash
|
|
68
|
+
|
|
69
|
+
self.InstanceProviderData = ObjectInitializationData()
|
|
70
|
+
self.InstanceProviderData.ReadJson(data.m_InstanceProviderData)
|
|
71
|
+
|
|
72
|
+
self.SceneProviderData = ObjectInitializationData()
|
|
73
|
+
self.SceneProviderData.ReadJson(data.m_SceneProviderData)
|
|
74
|
+
|
|
75
|
+
self.ResourceProviderData = []
|
|
76
|
+
for i in range(len(data.m_ResourceProviderData)):
|
|
77
|
+
o = ObjectInitializationData()
|
|
78
|
+
o.ReadJson(data.m_ResourceProviderData[i])
|
|
79
|
+
self.ResourceProviderData.append(o)
|
|
80
|
+
|
|
81
|
+
self.ProviderIds = []
|
|
82
|
+
for i in range(len(data.m_ProviderIds)):
|
|
83
|
+
self.ProviderIds.append(data.m_ProviderIds[i])
|
|
84
|
+
|
|
85
|
+
self.InternalIds = []
|
|
86
|
+
for i in range(len(data.m_InternalIds)):
|
|
87
|
+
self.InternalIds.append(data.m_InternalIds[i])
|
|
88
|
+
|
|
89
|
+
if data.m_Keys is not None:
|
|
90
|
+
self.Keys = []
|
|
91
|
+
for i in range(len(data.m_Keys)):
|
|
92
|
+
self.Keys.append(data.m_Keys[i])
|
|
93
|
+
else:
|
|
94
|
+
self.Keys = None
|
|
95
|
+
|
|
96
|
+
self.ResourceTypes = []
|
|
97
|
+
for i in range(len(data.m_resourceTypes)):
|
|
98
|
+
o = SerializedType()
|
|
99
|
+
o.ReadJson(data.m_resourceTypes[i])
|
|
100
|
+
self.ResourceTypes.append(o)
|
|
101
|
+
|
|
102
|
+
if data.m_InternalIdPrefixes is not None:
|
|
103
|
+
self.InternalIdPrefixes = []
|
|
104
|
+
for i in range(len(data.m_InternalIdPrefixes)):
|
|
105
|
+
self.InternalIdPrefixes.append(data.m_InternalIdPrefixes[i])
|
|
106
|
+
else:
|
|
107
|
+
self.InternalIdPrefixes = None
|
|
108
|
+
|
|
109
|
+
self.ReadResourcesJson(data)
|
|
110
|
+
|
|
111
|
+
def ReadBinary(self, reader: CatalogBinaryReader):
|
|
112
|
+
header = ContentCatalogDataBinaryHeader()
|
|
113
|
+
header.Read(reader)
|
|
114
|
+
|
|
115
|
+
self.Version = reader.Version
|
|
116
|
+
self.Header = header
|
|
117
|
+
|
|
118
|
+
self.LocatorId = reader.ReadEncodedString(header.IdOffset)
|
|
119
|
+
self.BuildResultHash = reader.ReadEncodedString(header.BuildResultHashOffset)
|
|
120
|
+
|
|
121
|
+
self.InstanceProviderData = ObjectInitializationData()
|
|
122
|
+
self.InstanceProviderData.ReadBinary(reader, header.InstanceProviderOffset)
|
|
123
|
+
|
|
124
|
+
self.SceneProviderData = ObjectInitializationData()
|
|
125
|
+
self.SceneProviderData.ReadBinary(reader, header.SceneProviderOffset)
|
|
126
|
+
|
|
127
|
+
resourceProviderDataOffsets = reader.ReadOffsetArray(
|
|
128
|
+
header.InitObjectsArrayOffset
|
|
129
|
+
)
|
|
130
|
+
self.ResourceProviderData = []
|
|
131
|
+
for i in range(len(resourceProviderDataOffsets)):
|
|
132
|
+
o = ObjectInitializationData()
|
|
133
|
+
o.ReadBinary(reader, resourceProviderDataOffsets[i])
|
|
134
|
+
self.ResourceProviderData.append(o)
|
|
135
|
+
|
|
136
|
+
self.ReadResourcesBinary(reader, header)
|
|
137
|
+
|
|
138
|
+
def ReadResourcesJson(self, data: ContentCatalogDataJson):
|
|
139
|
+
buckets: list[ContentCatalogData.Bucket] = []
|
|
140
|
+
|
|
141
|
+
bucketStream = BytesIO(b64decode(data.m_BucketDataString))
|
|
142
|
+
bucketReader = BinaryReader(bucketStream)
|
|
143
|
+
bucketCount = bucketReader.ReadInt32()
|
|
144
|
+
for i in range(bucketCount):
|
|
145
|
+
offset = bucketReader.ReadInt32()
|
|
146
|
+
entryCount = bucketReader.ReadInt32()
|
|
147
|
+
entries: list[int] = []
|
|
148
|
+
for j in range(entryCount):
|
|
149
|
+
entries.append(bucketReader.ReadInt32())
|
|
150
|
+
buckets.append(ContentCatalogData.Bucket(offset, entries))
|
|
151
|
+
|
|
152
|
+
keys: list[
|
|
153
|
+
ClassJsonObject
|
|
154
|
+
| TypeReference
|
|
155
|
+
| Hash128
|
|
156
|
+
| int
|
|
157
|
+
| str
|
|
158
|
+
| WrappedSerializedObject[AssetBundleRequestOptions]
|
|
159
|
+
] = []
|
|
160
|
+
|
|
161
|
+
keyDataStream = BytesIO(b64decode(data.m_KeyDataString))
|
|
162
|
+
keyReader = BinaryReader(keyDataStream)
|
|
163
|
+
keyCount = keyReader.ReadInt32()
|
|
164
|
+
for i in range(keyCount):
|
|
165
|
+
keyDataStream.seek(buckets[i].offset)
|
|
166
|
+
keys.append(SerializedObjectDecoder.DecodeV1(keyReader))
|
|
167
|
+
|
|
168
|
+
locations: list[ResourceLocation] = []
|
|
169
|
+
|
|
170
|
+
entryDataStream = BytesIO(b64decode(data.m_EntryDataString))
|
|
171
|
+
extraDataStream = BytesIO(b64decode(data.m_ExtraDataString))
|
|
172
|
+
entryReader = BinaryReader(entryDataStream)
|
|
173
|
+
extraReader = BinaryReader(extraDataStream)
|
|
174
|
+
entryCount = entryReader.ReadInt32()
|
|
175
|
+
for i in range(entryCount):
|
|
176
|
+
internalIdIndex = entryReader.ReadInt32()
|
|
177
|
+
providerIndex = entryReader.ReadInt32()
|
|
178
|
+
dependencyKeyIndex = entryReader.ReadInt32()
|
|
179
|
+
depHash = entryReader.ReadInt32()
|
|
180
|
+
dataIndex = entryReader.ReadInt32()
|
|
181
|
+
primaryKeyIndex = entryReader.ReadInt32()
|
|
182
|
+
resourceTypeIndex = entryReader.ReadInt32()
|
|
183
|
+
|
|
184
|
+
internalId = self.InternalIds[internalIdIndex]
|
|
185
|
+
splitIndex = internalId.find("#")
|
|
186
|
+
if splitIndex != -1:
|
|
187
|
+
try:
|
|
188
|
+
prefixIndex = int(internalId[:splitIndex])
|
|
189
|
+
internalId = (
|
|
190
|
+
self.InternalIdPrefixes[prefixIndex]
|
|
191
|
+
+ internalId[splitIndex + 1 :]
|
|
192
|
+
)
|
|
193
|
+
except ValueError:
|
|
194
|
+
pass
|
|
195
|
+
|
|
196
|
+
providerId = self.ProviderIds[providerIndex]
|
|
197
|
+
|
|
198
|
+
dependencyKey = (
|
|
199
|
+
keys[dependencyKeyIndex] if dependencyKeyIndex >= 0 else None
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if dataIndex >= 0:
|
|
203
|
+
extraDataStream.seek(dataIndex)
|
|
204
|
+
objData = SerializedObjectDecoder.DecodeV1(extraReader)
|
|
205
|
+
else:
|
|
206
|
+
objData = None
|
|
207
|
+
|
|
208
|
+
if self.Keys is None:
|
|
209
|
+
primaryKey = keys[primaryKeyIndex]
|
|
210
|
+
else:
|
|
211
|
+
primaryKey = self.Keys[primaryKeyIndex]
|
|
212
|
+
|
|
213
|
+
resourceType = self.ResourceTypes[resourceTypeIndex]
|
|
214
|
+
|
|
215
|
+
loc = ResourceLocation()
|
|
216
|
+
loc.ReadJson(
|
|
217
|
+
internalId,
|
|
218
|
+
providerId,
|
|
219
|
+
dependencyKey,
|
|
220
|
+
objData,
|
|
221
|
+
depHash,
|
|
222
|
+
primaryKey,
|
|
223
|
+
resourceType,
|
|
224
|
+
)
|
|
225
|
+
locations.append(loc)
|
|
226
|
+
|
|
227
|
+
self.Resources = {}
|
|
228
|
+
for i in range(len(buckets)):
|
|
229
|
+
bucketEntries = buckets[i].entries
|
|
230
|
+
locs = []
|
|
231
|
+
for j in range(len(bucketEntries)):
|
|
232
|
+
locs.append(locations[bucketEntries[j]])
|
|
233
|
+
self.Resources[keys[i]] = locs
|
|
234
|
+
|
|
235
|
+
def ReadResourcesBinary(
|
|
236
|
+
self, reader: CatalogBinaryReader, header: ContentCatalogDataBinaryHeader
|
|
237
|
+
):
|
|
238
|
+
keyLocationOffsets = reader.ReadOffsetArray(header.KeysOffset)
|
|
239
|
+
self.Resources = {}
|
|
240
|
+
for i in range(0, len(keyLocationOffsets), 2):
|
|
241
|
+
keyOffset = keyLocationOffsets[i]
|
|
242
|
+
locationListOffset = keyLocationOffsets[i + 1]
|
|
243
|
+
key = SerializedObjectDecoder.DecodeV2(reader, keyOffset)
|
|
244
|
+
|
|
245
|
+
locationOffsets = reader.ReadOffsetArray(locationListOffset)
|
|
246
|
+
locations = []
|
|
247
|
+
for j in range(len(locationOffsets)):
|
|
248
|
+
location = ResourceLocation()
|
|
249
|
+
location.ReadBinary(reader, locationOffsets[j])
|
|
250
|
+
locations.append(location)
|
|
251
|
+
|
|
252
|
+
self.Resources[key] = locations
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
__all__ = ["ContentCatalogData"]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from .SerializedType import SerializedType
|
|
2
|
+
from ..JSON.ObjectInitializationDataJson import ObjectInitializationDataJson
|
|
3
|
+
from ..Reader.CatalogBinaryReader import CatalogBinaryReader
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ObjectInitializationData:
|
|
7
|
+
Id: str | None
|
|
8
|
+
ObjectType: SerializedType | None
|
|
9
|
+
Data: str | None
|
|
10
|
+
|
|
11
|
+
def __repr__(self):
|
|
12
|
+
return (
|
|
13
|
+
f"<{self.__class__.__name__}(Id={self.Id}, ObjectType={self.ObjectType})>"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
def __init__(self):
|
|
17
|
+
self.Id = None
|
|
18
|
+
self.ObjectType = None
|
|
19
|
+
self.Data = None
|
|
20
|
+
|
|
21
|
+
def ReadJson(self, obj: ObjectInitializationDataJson):
|
|
22
|
+
self.Id = obj.m_Id
|
|
23
|
+
self.ObjectType = SerializedType()
|
|
24
|
+
self.ObjectType.ReadJson(obj.m_ObjectType)
|
|
25
|
+
self.Data = obj.m_Data
|
|
26
|
+
|
|
27
|
+
def ReadBinary(self, reader: CatalogBinaryReader, offset: int):
|
|
28
|
+
reader.BaseStream.seek(offset)
|
|
29
|
+
idOffset = reader.ReadUInt32()
|
|
30
|
+
objectTypeOffset = reader.ReadUInt32()
|
|
31
|
+
dataOffset = reader.ReadUInt32()
|
|
32
|
+
|
|
33
|
+
self.Id = reader.ReadEncodedString(idOffset)
|
|
34
|
+
self.ObjectType = SerializedType()
|
|
35
|
+
self.ObjectType.ReadBinary(reader, objectTypeOffset)
|
|
36
|
+
self.Data = reader.ReadEncodedString(dataOffset)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
__all__ = ["ObjectInitializationData"]
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .SerializedType import SerializedType
|
|
4
|
+
from .ClassJsonObject import ClassJsonObject
|
|
5
|
+
from .SerializedObjectDecoder import SerializedObjectDecoder
|
|
6
|
+
from ..Reader.CatalogBinaryReader import CatalogBinaryReader
|
|
7
|
+
from ..Classes.TypeReference import TypeReference
|
|
8
|
+
from ..Classes.Hash128 import Hash128
|
|
9
|
+
from ..Classes.AssetBundleRequestOptions import AssetBundleRequestOptions
|
|
10
|
+
from ..Catalog.WrappedSerializedObject import WrappedSerializedObject
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ResourceLocation:
|
|
14
|
+
InternalId: str | None
|
|
15
|
+
ProviderId: str | None
|
|
16
|
+
DependencyKey: object
|
|
17
|
+
Dependencies: list[ResourceLocation] | None
|
|
18
|
+
Data: (
|
|
19
|
+
ClassJsonObject
|
|
20
|
+
| TypeReference
|
|
21
|
+
| Hash128
|
|
22
|
+
| int
|
|
23
|
+
| str
|
|
24
|
+
| bool
|
|
25
|
+
| WrappedSerializedObject[AssetBundleRequestOptions]
|
|
26
|
+
| None
|
|
27
|
+
)
|
|
28
|
+
HashCode: int
|
|
29
|
+
DependencyHashCode: int
|
|
30
|
+
PrimaryKey: str | None
|
|
31
|
+
Type: SerializedType | None
|
|
32
|
+
|
|
33
|
+
def __repr__(self):
|
|
34
|
+
return (
|
|
35
|
+
f"<{self.__class__.__name__}("
|
|
36
|
+
f"InternalId={self.InternalId}, "
|
|
37
|
+
f"ProviderId={self.ProviderId}, "
|
|
38
|
+
f"DependencyKey={self.DependencyKey}, "
|
|
39
|
+
f"Dependencies={self.Dependencies}, "
|
|
40
|
+
f"Data={self.Data}, "
|
|
41
|
+
f"HashCode={self.HashCode}, "
|
|
42
|
+
f"DependencyHashCode={self.DependencyHashCode}, "
|
|
43
|
+
f"PrimaryKey={self.PrimaryKey}, "
|
|
44
|
+
f"Type={self.Type}"
|
|
45
|
+
f")>"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def __init__(self):
|
|
49
|
+
self.InternalId = None
|
|
50
|
+
self.ProviderId = None
|
|
51
|
+
self.DependencyKey = None
|
|
52
|
+
self.Dependencies = None
|
|
53
|
+
self.Data = None
|
|
54
|
+
self.HashCode = 0
|
|
55
|
+
self.DependencyHashCode = 0
|
|
56
|
+
self.PrimaryKey = None
|
|
57
|
+
self.Type = None
|
|
58
|
+
|
|
59
|
+
def ReadJson(
|
|
60
|
+
self,
|
|
61
|
+
internalId: str | None,
|
|
62
|
+
providerId: str | None,
|
|
63
|
+
dependencyKey: object,
|
|
64
|
+
objData: (
|
|
65
|
+
ClassJsonObject
|
|
66
|
+
| TypeReference
|
|
67
|
+
| Hash128
|
|
68
|
+
| int
|
|
69
|
+
| str
|
|
70
|
+
| bool
|
|
71
|
+
| WrappedSerializedObject[AssetBundleRequestOptions]
|
|
72
|
+
| None
|
|
73
|
+
),
|
|
74
|
+
depHash: int,
|
|
75
|
+
primaryKey: object,
|
|
76
|
+
resourceType: SerializedType | None,
|
|
77
|
+
):
|
|
78
|
+
self.InternalId = internalId
|
|
79
|
+
self.ProviderId = providerId
|
|
80
|
+
self.DependencyKey = dependencyKey
|
|
81
|
+
self.Dependencies = None
|
|
82
|
+
self.Data = objData
|
|
83
|
+
self.HashCode = hash(self.InternalId) * 31 + hash(self.ProviderId)
|
|
84
|
+
self.DependencyHashCode = depHash
|
|
85
|
+
self.PrimaryKey = str(primaryKey)
|
|
86
|
+
self.Type = resourceType
|
|
87
|
+
|
|
88
|
+
def ReadBinary(self, reader: CatalogBinaryReader, offset: int):
|
|
89
|
+
reader.BaseStream.seek(offset)
|
|
90
|
+
primaryKeyOffset = reader.ReadUInt32()
|
|
91
|
+
internalIdOffset = reader.ReadUInt32()
|
|
92
|
+
providerIdOffset = reader.ReadUInt32()
|
|
93
|
+
dependenciesOffset = reader.ReadUInt32()
|
|
94
|
+
dependencyHashCode = reader.ReadInt32()
|
|
95
|
+
dataOffset = reader.ReadUInt32()
|
|
96
|
+
typeOffset = reader.ReadUInt32()
|
|
97
|
+
|
|
98
|
+
self.PrimaryKey = reader.ReadEncodedString(primaryKeyOffset, "/")
|
|
99
|
+
self.InternalId = reader.ReadEncodedString(internalIdOffset, "/")
|
|
100
|
+
self.ProviderId = reader.ReadEncodedString(providerIdOffset, ".")
|
|
101
|
+
|
|
102
|
+
dependenciesOffsets = reader.ReadOffsetArray(dependenciesOffset)
|
|
103
|
+
dependencies: list[ResourceLocation] = []
|
|
104
|
+
for i in range(len(dependenciesOffsets)):
|
|
105
|
+
objectOffset = dependenciesOffsets[i]
|
|
106
|
+
dependencyLocation = reader.ReadCustom(
|
|
107
|
+
objectOffset,
|
|
108
|
+
lambda: (x := ResourceLocation()).ReadBinary(reader, objectOffset) or x,
|
|
109
|
+
)
|
|
110
|
+
dependencies.append(dependencyLocation)
|
|
111
|
+
|
|
112
|
+
self.DependencyKey = None
|
|
113
|
+
self.Dependencies = dependencies
|
|
114
|
+
|
|
115
|
+
self.DependencyHashCode = dependencyHashCode
|
|
116
|
+
self.Data = SerializedObjectDecoder.DecodeV2(reader, dataOffset)
|
|
117
|
+
self.Type = SerializedType()
|
|
118
|
+
self.Type.ReadBinary(reader, typeOffset)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
__all__ = ["ResourceLocation"]
|