游戏包体资源信息分析

包体名称 ---- 大小

BP_AIChar_110020100_CPNSoldier ---- 21.13 MB /Game/AIBehavior/CPN/110020100_CPNSoldier/ ---- 21.13 MB 'E' ---- /Game/Maps/C02_StormFortress/Quest/Sequence/M_Light_shinny 'E' ---- /Game/Avatar/Base/Male_mesh_3P_Skeleton

BP_AIChar_150012100_MUTRockBreaker ---- 12.37 MB /Game/AIBehavior/MUT/150012100_MUTRockBreaker/ ---- 12.37 MB 'E' ---- /Game/Avatar/Base/Male_mesh_3P_Skeleton 'E' ---- /Game/Maps/C02_StormFortress/Quest/Sequence/M_Light_shinny 'E' ---- /Game/GenTexDir/Game/Environment/BL01_Wild/Props/Textures/T_VMGen_EmissiveMap_9d49d7eec28ca8720dde347518992234

总包体数量:45

代码示例

def parse_package_asset_info(content: str) -> List[PackageAssetInfo]:
    lines = content.split('
')
    result = []
    parent_stack = []
    parent_id_stack = []
    parent_leaf_stack = []
    id_row = 1
    for line in lines:
        if not line.strip():
            continue
        depth = len(line) - len(line.lstrip())  # 缩进空格数量表示深度
        name, size = line.strip().split('  ----  ')
        size = int(size[:-3]) if size.endswith('MB') else None
        leaf = True if name.startswith('/') else False
        name = name.strip('/')

        # 如果当前深度小于栈顶深度,则出栈,直到找到父级节点
        while parent_stack and depth <= parent_stack[-1]:
            parent_stack.pop()
            parent_id_stack.pop()
            parent_leaf_stack.pop()

        # 父级节点信息
        if parent_stack:
            parent_name = parent_stack[-1]
            parent_id = parent_id_stack[-1]
            parent_leaf = parent_leaf_stack[-1]
        else:
            parent_name = None
            parent_id = None
            parent_leaf = None

        # 当前节点信息
        node = PackageAssetInfo(name=name, size=size, id_row=id_row, parent_id=parent_id, depth=depth, leaf=leaf)
        result.append(node)

        # 如果当前节点是叶节点,则更新父级节点为非叶节点
        if not leaf and parent_id:
            PackageAssetInfo.objects.filter(id_row=parent_id).update(leaf=False)

        # 更新栈信息
        parent_stack.append(name)
        parent_id_stack.append(id_row)
        parent_leaf_stack.append(leaf)
        id_row += 1

    return result

数据入库示例:

  • BP_AIChar_110020100_CPNSoldier ---- 21.13 MB
    • depth=0,name='BP_AIChar_110020100_CPNSoldier',size=21.13,id_row=1,leaf=True
  • /Game/AIBehavior/CPN/110020100_CPNSoldier/ ---- 21.13 MB
    • depth=1,name='/Game/AIBehavior/CPN/110020100_CPNSoldier/',size=21.13,id_row=2,leaf=True
  • 'E' ---- /Game/Maps/C02_StormFortress/Quest/Sequence/M_Light_shinny
    • depth=2,name='/Game/Maps/C02_StormFortress/Quest/Sequence/M_Light_shinny',size=None,id_row=3,leaf=False
  • 'E' ---- /Game/Avatar/Base/Male_mesh_3P_Skeleton
    • depth=2,name='/Game/Avatar/Base/Male_mesh_3P_Skeleton',size=None,id_row=4,leaf=False

代码中的PackageAssetInfo类用于存储游戏包体资源信息。

游戏包体资源信息分析

原文地址: https://www.cveoy.top/t/topic/nACA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录