GFSaveSlotMetadata¶
API Reference / Save / 类索引
- 路径:
addons/gf/extensions/save/slots/gf_save_slot_metadata.gd - 模块:
Save - 继承:
Resource - API:
public - 类别:值对象 (
value_object) - 首次版本:
3.17.0
通用存档槽元数据。 只描述槽位、版本、时间、标签和项目自定义字典,不绑定任何具体游戏业务字段。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 属性 | slot_id |
var slot_id: StringName = &"" |
| 属性 | display_name |
var display_name: String = "" |
| 属性 | description |
var description: String = "" |
| 属性 | schema_id |
var schema_id: StringName = &"" |
| 属性 | schema_version |
var schema_version: int = 1 |
| 属性 | app_version |
var app_version: String = "" |
| 属性 | created_at_unix |
var created_at_unix: int = 0 |
| 属性 | updated_at_unix |
var updated_at_unix: int = 0 |
| 属性 | elapsed_seconds |
var elapsed_seconds: float = 0.0 |
| 属性 | tags |
var tags: PackedStringArray = PackedStringArray() |
| 属性 | custom_metadata |
var custom_metadata: Dictionary = {} |
| 方法 | to_dict |
func to_dict(include_empty: bool = true) -> Dictionary: |
| 方法 | to_patch_dict |
func to_patch_dict() -> Dictionary: |
| 方法 | apply_dict |
func apply_dict(data: Dictionary) -> void: |
| 方法 | duplicate_metadata |
func duplicate_metadata() -> GFSaveSlotMetadata: |
| 方法 | get_display_name |
func get_display_name(fallback: String = "") -> String: |
| 方法 | validate_metadata |
func validate_metadata() -> Dictionary: |
| 方法 | from_dict |
static func from_dict(data: Dictionary) -> GFSaveSlotMetadata: |
| 方法 | from_values |
static func from_values( p_slot_id: StringName, p_display_name: String = "", p_custom_metadata: Dictionary = {} ) -> GFSaveSlotMetadata: |
属性¶
slot_id¶
- API:
public
槽位逻辑标识。可由项目映射到整数槽、文件名或云端 key。
display_name¶
- API:
public
展示名称。
description¶
- API:
public
展示描述。
schema_id¶
- API:
public
存档数据结构标识。
schema_version¶
- API:
public
存档数据结构版本。
app_version¶
- API:
public
项目版本号。
created_at_unix¶
- API:
public
创建时间戳。
updated_at_unix¶
- API:
public
更新时间戳。
elapsed_seconds¶
- API:
public
通用游玩时长或业务耗时。
tags¶
- API:
public
通用标签。
custom_metadata¶
- API:
public
项目自定义元数据。
结构:
custom_metadata: Dictionary,可包含项目自定义展示、兼容性或索引字段。
方法¶
to_dict¶
- API:
public
转换为 Dictionary。
参数:
| 名称 | 说明 |
|---|---|
include_empty |
是否包含空值。 |
返回:元数据字典。
结构:
return: Dictionary,可包含 slot_id、display_name、description、schema_id、schema_version、app_version、created_at_unix、updated_at_unix、elapsed_seconds、tags 与 custom_metadata。
to_patch_dict¶
- API:
public
转换为只包含非空值的补丁字典。
返回:补丁字典。
结构:
return: Dictionary,字段同 to_dict(),但会省略空值。
apply_dict¶
- API:
public
应用字典数据。
参数:
| 名称 | 说明 |
|---|---|
data |
元数据字典。 |
结构:
data: Dictionary,可包含 slot_id、display_name、description、schema_id、schema_version、app_version、created_at_unix、updated_at_unix、elapsed_seconds、tags 与 custom_metadata。
duplicate_metadata¶
- API:
public
创建深拷贝。
返回:新元数据。
get_display_name¶
- API:
public
获取展示名称,允许调用方提供兜底文本。
参数:
| 名称 | 说明 |
|---|---|
fallback |
兜底文本。 |
返回:展示名称。
validate_metadata¶
- API:
public
校验元数据的通用结构。
返回:诊断报告。
结构:
return: Dictionary,包含 ok、healthy、issues、issue_count、warning_count、error_count、summary 与 next_actions 等校验报告字段。
from_dict¶
- API:
public
从 Dictionary 创建元数据。
参数:
| 名称 | 说明 |
|---|---|
data |
元数据字典。 |
返回:新元数据。
结构:
data: Dictionary,字段同 to_dict() 返回值。
from_values¶
- API:
public
static func from_values( p_slot_id: StringName, p_display_name: String = "", p_custom_metadata: Dictionary = {} ) -> GFSaveSlotMetadata:
使用常用字段创建元数据。
参数:
| 名称 | 说明 |
|---|---|
p_slot_id |
槽位标识。 |
p_display_name |
展示名称。 |
p_custom_metadata |
自定义元数据。 |
返回:新元数据。
结构:
p_custom_metadata: Dictionary,可包含项目自定义展示、兼容性或索引字段。