|
1 | 1 | #type: ignore |
2 | 2 | from typing import List |
3 | 3 | from ..util import aiorequests |
| 4 | +from ..util.logger import instance as logger |
4 | 5 | from ..constants import CACHE_DIR |
5 | 6 | import os, pydantic |
6 | 7 | import UnityPy |
| 8 | +from UnityPy.enums import ClassIDType |
7 | 9 | from ..util.logger import instance as logger |
| 10 | +UnityPy.config.FALLBACK_UNITY_VERSION = "2021.3.20f1" |
8 | 11 |
|
9 | 12 | class content(pydantic.BaseModel): |
10 | 13 | url: str = None |
@@ -90,17 +93,35 @@ async def init(self, ver): |
90 | 93 | self.root.register_to(self) |
91 | 94 |
|
92 | 95 | async def download(self, url: str) -> bytes: |
| 96 | + logger.info(f"resolving {url}...") |
| 97 | + |
93 | 98 | content = self.registries[url] |
94 | 99 | def genHash(hash): |
95 | 100 | return f'{self.pool}/{content.category}/{hash[:2]}/{hash}' |
96 | 101 | return await content.download(genHash) |
97 | 102 |
|
98 | 103 | async def db(self) -> bytes: |
99 | | - UnityPy.config.FALLBACK_UNITY_VERSION = "2021.3.20f1" |
100 | 104 | ab = UnityPy.load(await self.download('a/masterdata_master.unity3d')) |
101 | 105 | asset = ab.objects[0].read() |
102 | 106 | return asset.script |
103 | 107 |
|
| 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 | + |
104 | 124 |
|
105 | 125 | # should lock before use |
106 | 126 | instance = assetmgr() |
| 127 | + |
0 commit comments