跳转至

GFContentPackageCatalog

API Reference / Extensions / Content Package / 类索引

  • 路径:addons/gf/extensions/content_package/runtime/gf_content_package_catalog.gd
  • 模块:Extensions / Content Package
  • 继承:RefCounted
  • API:public
  • 类别:运行时服务 (runtime_service)
  • 首次版本:4.4.0

内容包集合与依赖图诊断。 管理一组 GFContentPackageManifest,提供包查询、依赖顺序、重复/缺失/循环依赖报告, 并可把内容包资源键映射注册到 GFResourceResolverUtility。

成员概览

类型 名称 签名
方法 clear func clear() -> void:
方法 add_manifest func add_manifest(manifest: GFContentPackageManifest) -> bool:
方法 set_manifests func set_manifests(manifests: Array[GFContentPackageManifest]) -> GFContentPackageCatalog:
方法 remove_manifest func remove_manifest(package_id: StringName) -> bool:
方法 has_package func has_package(package_id: StringName) -> bool:
方法 get_manifest func get_manifest(package_id: StringName) -> GFContentPackageManifest:
方法 get_package_ids func get_package_ids() -> PackedStringArray:
方法 get_ordered_package_ids func get_ordered_package_ids() -> PackedStringArray:
方法 get_graph_report func get_graph_report(options: Dictionary = {}) -> Dictionary:
方法 register_resources func register_resources(resolver: GFResourceResolverUtility, options: Dictionary = {}) -> Dictionary:
方法 get_debug_snapshot func get_debug_snapshot() -> Dictionary:

方法

clear

  • API:public
func clear() -> void:

清空目录。

add_manifest

  • API:public
func add_manifest(manifest: GFContentPackageManifest) -> bool:

注册内容包 manifest。

参数:

名称 说明
manifest 内容包 manifest。

返回:注册成功返回 true;重复或空 ID 返回 false。

set_manifests

  • API:public
func set_manifests(manifests: Array[GFContentPackageManifest]) -> GFContentPackageCatalog:

批量替换内容包 manifest。

参数:

名称 说明
manifests manifest 列表。

返回:当前目录。

结构:

  • manifests: Array[GFContentPackageManifest],无效项会被忽略或进入诊断。

remove_manifest

  • API:public
func remove_manifest(package_id: StringName) -> bool:

移除内容包 manifest。

参数:

名称 说明
package_id 内容包 ID。

返回:移除成功返回 true。

has_package

  • API:public
func has_package(package_id: StringName) -> bool:

检查内容包是否存在。

参数:

名称 说明
package_id 内容包 ID。

返回:存在返回 true。

get_manifest

  • API:public
func get_manifest(package_id: StringName) -> GFContentPackageManifest:

获取内容包 manifest。

参数:

名称 说明
package_id 内容包 ID。

返回:manifest;不存在时返回 null。

get_package_ids

  • API:public
func get_package_ids() -> PackedStringArray:

获取内容包 ID 列表。

返回:按注册顺序排列的内容包 ID。

get_ordered_package_ids

  • API:public
func get_ordered_package_ids() -> PackedStringArray:

获取按依赖优先排序的内容包 ID。

返回:依赖包先于依赖方出现的内容包 ID 列表。

get_graph_report

  • API:public
func get_graph_report(options: Dictionary = {}) -> Dictionary:

获取依赖图和 manifest 诊断报告。

参数:

名称 说明
options 校验选项,透传给 GFContentPackageManifest。

返回:GFValidationReportDictionary 兼容报告。

结构:

  • options: Dictionary,可包含 check_resource_exists: bool。
  • return: GFValidationReportDictionary.finalize_report() 生成的 Dictionary,并包含 package_count、package_ids、ordered_package_ids 和 duplicate_package_ids。

register_resources

  • API:public
func register_resources(resolver: GFResourceResolverUtility, options: Dictionary = {}) -> Dictionary:

把内容包资源键注册到资源解析器。

参数:

名称 说明
resolver 标准资源解析器。
options 注册选项。base_priority 默认为 0;check_resource_exists 默认为 false。

返回:GFValidationReportDictionary 兼容报告,并包含 registered_count。

结构:

  • options: Dictionary,可包含 base_priority: int 和 check_resource_exists: bool。
  • return: GFValidationReportDictionary.finalize_report() 生成的 Dictionary,并包含 registered_count。

get_debug_snapshot

  • API:public
func get_debug_snapshot() -> Dictionary:

获取调试快照。

返回:目录快照。

结构:

  • return: Dictionary,包含 package_count、package_ids、ordered_package_ids 和 duplicate_package_ids。