GFExecutionRequirement¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/common/gf_execution_requirement.gd - 模块:
Standard - 继承:
RefCounted - API:
public - 类别:值对象 (
value_object) - 首次版本:
7.0.0
通用执行条件集合。 用于在任务、系统、工具按钮或资源流程执行前统一评估一组声明式条件。 它只读取调用方传入的 context 字典和可选谓词,不绑定具体调度器或业务系统。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 常量 | MODE_ALL |
const MODE_ALL: StringName = &"all" |
| 常量 | MODE_ANY |
const MODE_ANY: StringName = &"any" |
| 常量 | MODE_NONE |
const MODE_NONE: StringName = &"none" |
| 常量 | KIND_PREDICATE |
const KIND_PREDICATE: StringName = &"predicate" |
| 常量 | KIND_VALUE |
const KIND_VALUE: StringName = &"value" |
| 常量 | KIND_PRESENT |
const KIND_PRESENT: StringName = &"present" |
| 属性 | requirement_id |
var requirement_id: StringName = &"" |
| 属性 | label |
var label: String = "" |
| 属性 | metadata |
var metadata: Dictionary = {} |
| 方法 | configure |
func configure( p_requirement_id: StringName, p_label: String = "", p_metadata: Dictionary = {} ) -> GFExecutionRequirement: |
| 方法 | add_predicate |
func add_predicate(condition_id: StringName, predicate: Callable, options: Dictionary = {}) -> Dictionary: |
| 方法 | add_value |
func add_value( condition_id: StringName, key: Variant, expected_value: Variant, options: Dictionary = {} ) -> Dictionary: |
| 方法 | add_presence |
func add_presence(condition_id: StringName, key: Variant, options: Dictionary = {}) -> Dictionary: |
| 方法 | evaluate |
func evaluate(context: Dictionary = {}) -> Dictionary: |
| 方法 | is_satisfied |
func is_satisfied(context: Dictionary = {}) -> bool: |
| 方法 | get_conditions |
func get_conditions() -> Array[Dictionary]: |
| 方法 | clear |
func clear() -> void: |
| 方法 | get_debug_snapshot |
func get_debug_snapshot() -> Dictionary: |
常量¶
MODE_ALL¶
- API:
public - 首次版本:
7.0.0
条件必须满足。
MODE_ANY¶
- API:
public - 首次版本:
7.0.0
同组条件至少满足一个。
MODE_NONE¶
- API:
public - 首次版本:
7.0.0
条件必须不满足。
KIND_PREDICATE¶
- API:
public - 首次版本:
7.0.0
Callable 谓词条件。
KIND_VALUE¶
- API:
public - 首次版本:
7.0.0
context 值比较条件。
KIND_PRESENT¶
- API:
public - 首次版本:
7.0.0
context key 存在性条件。
属性¶
requirement_id¶
- API:
public - 首次版本:
7.0.0
条件集合稳定标识。
label¶
- API:
public - 首次版本:
7.0.0
条件集合显示名称。
metadata¶
- API:
public - 首次版本:
7.0.0
调用方元数据。
结构:
metadata: Dictionary for caller-defined requirement metadata.
方法¶
configure¶
- API:
public - 首次版本:
7.0.0
func configure( p_requirement_id: StringName, p_label: String = "", p_metadata: Dictionary = {} ) -> GFExecutionRequirement:
配置条件集合。
参数:
| 名称 | 说明 |
|---|---|
p_requirement_id |
条件集合稳定标识。 |
p_label |
显示名称。 |
p_metadata |
调用方元数据。 |
返回:当前条件集合。
结构:
p_metadata: Dictionary copied into metadata.
add_predicate¶
- API:
public - 首次版本:
7.0.0
func add_predicate(condition_id: StringName, predicate: Callable, options: Dictionary = {}) -> Dictionary:
添加 Callable 谓词条件。谓词签名为 (context: Dictionary) -> bool|Dictionary。
参数:
| 名称 | 说明 |
|---|---|
condition_id |
条件稳定标识。 |
predicate |
条件谓词。 |
options |
条件选项,支持 mode、label、negate 和 metadata。 |
返回:条件快照;predicate 无效时为空字典。
结构:
options: Dictionary,可包含 mode: StringName、label: String、negate: bool、metadata: Dictionary。return: Dictionary,包含 condition_id、kind、mode、label、negate、metadata 和 has_predicate。
add_value¶
- API:
public - 首次版本:
7.0.0
func add_value( condition_id: StringName, key: Variant, expected_value: Variant, options: Dictionary = {} ) -> Dictionary:
添加 context 值比较条件。
参数:
| 名称 | 说明 |
|---|---|
condition_id |
条件稳定标识。 |
key |
要从 context 读取的 key。 |
expected_value |
期望值。 |
options |
条件选项,支持 mode、label、negate、metadata 和 equals_options。 |
返回:条件快照。
结构:
key: Variant context key,通常为 String 或 StringName。expected_value: Variant expected context value.options: Dictionary,可包含 mode: StringName、label: String、negate: bool、metadata: Dictionary、equals_options: Dictionary。return: Dictionary,包含 condition_id、kind、mode、label、key、expected、negate 和 metadata。
add_presence¶
- API:
public - 首次版本:
7.0.0
添加 context key 存在性条件。
参数:
| 名称 | 说明 |
|---|---|
condition_id |
条件稳定标识。 |
key |
要检查的 context key。 |
options |
条件选项,支持 mode、label、negate 和 metadata。 |
返回:条件快照。
结构:
key: Variant context key,通常为 String 或 StringName。options: Dictionary,可包含 mode: StringName、label: String、negate: bool、metadata: Dictionary。return: Dictionary,包含 condition_id、kind、mode、label、key、negate 和 metadata。
evaluate¶
- API:
public - 首次版本:
7.0.0
评估条件集合。
参数:
| 名称 | 说明 |
|---|---|
context |
调用方上下文字典。 |
返回:条件评估报告。
结构:
context: Dictionary read by value and predicate conditions.return: Dictionary,包含 ok、requirement_id、label、all_satisfied、any_satisfied、none_clear、satisfied_count、failed_count、conditions 和 metadata。
is_satisfied¶
- API:
public - 首次版本:
7.0.0
检查条件集合是否满足。
参数:
| 名称 | 说明 |
|---|---|
context |
调用方上下文字典。 |
返回:满足时返回 true。
结构:
context: Dictionary read by value and predicate conditions.
get_conditions¶
- API:
public - 首次版本:
7.0.0
获取条件快照数组。
返回:条件快照数组,不包含 Callable 本体。
结构:
return: Array[Dictionary],每个元素包含 condition_id、kind、mode、label、key、expected、negate、metadata 和 has_predicate。
clear¶
- API:
public - 首次版本:
7.0.0
清空全部条件。
get_debug_snapshot¶
- API:
public - 首次版本:
7.0.0
获取调试快照。
返回:调试快照。
结构:
return: Dictionary,包含 requirement_id、label、condition_count、conditions 和 metadata。