GFLevelProgressModel¶
API Reference / Domain / 类索引
- 路径:
addons/gf/extensions/domain/level/gf_level_progress_model.gd - 模块:
Domain - 继承:
GFModel - API:
public - 类别:领域模型 (
domain_model) - 首次版本:
3.17.0
通用关卡解锁与完成进度模型。 只记录关卡是否解锁、是否完成以及项目层自定义结果字典。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 信号 | level_unlocked |
signal level_unlocked(level_id: StringName) |
| 信号 | level_locked |
signal level_locked(level_id: StringName) |
| 信号 | level_completed |
signal level_completed(level_id: StringName, result: Dictionary) |
| 信号 | level_result_updated |
signal level_result_updated(level_id: StringName, result: Dictionary) |
| 方法 | unlock_level |
func unlock_level(level_id: StringName) -> void: |
| 方法 | lock_level |
func lock_level(level_id: StringName) -> void: |
| 方法 | is_level_unlocked |
func is_level_unlocked(level_id: StringName) -> bool: |
| 方法 | complete_level |
func complete_level(level_id: StringName, result: Dictionary = {}, merge_result: bool = true) -> void: |
| 方法 | is_level_completed |
func is_level_completed(level_id: StringName) -> bool: |
| 方法 | set_level_result |
func set_level_result(level_id: StringName, result: Dictionary, merge_result: bool = true) -> void: |
| 方法 | get_level_result |
func get_level_result(level_id: StringName) -> Dictionary: |
| 方法 | clear_progress |
func clear_progress() -> void: |
| 方法 | to_dict |
func to_dict() -> Dictionary: |
| 方法 | from_dict |
func from_dict(data: Dictionary) -> void: |
信号¶
level_unlocked¶
- API:
public
关卡解锁时发出。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
level_locked¶
- API:
public
关卡锁定时发出。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
level_completed¶
- API:
public
关卡完成时发出。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
result |
完成结果。 |
结构:
result: Dictionary,项目自定义关卡完成结果副本。
level_result_updated¶
- API:
public
关卡结果更新时发出。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
result |
结果字典。 |
结构:
result: Dictionary,项目自定义关卡结果副本。
方法¶
unlock_level¶
- API:
public
解锁关卡。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
lock_level¶
- API:
public
锁定关卡。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
is_level_unlocked¶
- API:
public
检查关卡是否解锁。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
返回:已解锁时返回 true。
complete_level¶
- API:
public
func complete_level(level_id: StringName, result: Dictionary = {}, merge_result: bool = true) -> void:
标记关卡完成。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
result |
项目层结果数据。 |
merge_result |
是否合并已有结果。 |
结构:
result: Dictionary,项目自定义关卡完成结果;merge_result 为 true 时会覆盖同名字段。
is_level_completed¶
- API:
public
检查关卡是否完成。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
返回:已完成时返回 true。
set_level_result¶
- API:
public
设置关卡结果。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
result |
结果字典。 |
merge_result |
是否合并已有结果。 |
结构:
result: Dictionary,项目自定义关卡结果;merge_result 为 true 时会覆盖同名字段。
get_level_result¶
- API:
public
获取关卡结果。
参数:
| 名称 | 说明 |
|---|---|
level_id |
关卡 ID。 |
返回:结果字典副本。
结构:
return: Dictionary,项目自定义关卡结果副本;不存在时为空字典。
clear_progress¶
- API:
public
清空所有进度。
to_dict¶
- API:
public
序列化进度。
返回:字典数据。
结构:
return: Dictionary,包含 unlocked_levels、completed_levels 与 level_results 三个 String 键字典。
from_dict¶
- API:
public
反序列化进度。
参数:
| 名称 | 说明 |
|---|---|
data |
字典数据。 |
结构:
data: Dictionary,包含 unlocked_levels、completed_levels 与 level_results 三个可选字典字段。