Skip to content

Commit 8c7d063

Browse files
authored
Merge pull request #294 from cc004/fix
fix: assetmgr download
2 parents 9f6fadd + ed68b94 commit 8c7d063

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

autopcr/db/assetmgr.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#type: ignore
22
from typing import List
33
from ..util import aiorequests
4+
from ..util.logger import instance as logger
45
from ..constants import CACHE_DIR
56
import os, pydantic
67
import UnityPy
8+
from UnityPy.enums import ClassIDType
79
from ..util.logger import instance as logger
10+
UnityPy.config.FALLBACK_UNITY_VERSION = "2021.3.20f1"
811

912
class content(pydantic.BaseModel):
1013
url: str = None
@@ -90,17 +93,35 @@ async def init(self, ver):
9093
self.root.register_to(self)
9194

9295
async def download(self, url: str) -> bytes:
96+
logger.info(f"resolving {url}...")
97+
9398
content = self.registries[url]
9499
def genHash(hash):
95100
return f'{self.pool}/{content.category}/{hash[:2]}/{hash}'
96101
return await content.download(genHash)
97102

98103
async def db(self) -> bytes:
99-
UnityPy.config.FALLBACK_UNITY_VERSION = "2021.3.20f1"
100104
ab = UnityPy.load(await self.download('a/masterdata_master.unity3d'))
101105
asset = ab.objects[0].read()
102106
return asset.script
103107

108+
async def unit_icon(self, unit_id: int) -> bytes:
109+
ab = UnityPy.load(await self.download(f'a/unit_icon_unit_{unit_id}.unity3d'))
110+
for object in ab.objects:
111+
if object.type == ClassIDType.Texture2D:
112+
asset = object.read()
113+
return asset.image
114+
return None
115+
116+
async def ex_equip_icon(self, equip_id: int) -> bytes:
117+
ab = UnityPy.load(await self.download(f'a/icon_icon_extra_equip_{equip_id}.unity3d'))
118+
for object in ab.objects:
119+
if object.type == ClassIDType.Texture2D:
120+
asset = object.read()
121+
return asset.image
122+
return None
123+
104124

105125
# should lock before use
106126
instance = assetmgr()
127+

0 commit comments

Comments
 (0)