GFTurnFlowSystem¶
API Reference / Turn Based / 类索引
- 路径:
addons/gf/extensions/turn_based/runtime/gf_turn_flow_system.gd - 模块:
Turn Based - 继承:
GFSystem - API:
public - 类别:运行时服务 (
runtime_service) - 首次版本:
3.17.0
通用回合流程系统。 提供阶段推进、行动排队和按优先级解析能力。 它不关心战斗、卡牌、棋盘等具体业务,只调度抽象行动。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 信号 | flow_started |
signal flow_started(context: GFTurnContext) |
| 信号 | flow_stopped |
signal flow_stopped(context: GFTurnContext) |
| 信号 | phase_changed |
signal phase_changed(phase: GFTurnPhase, index: int) |
| 信号 | action_enqueued |
signal action_enqueued(action: GFTurnAction) |
| 信号 | action_resolved |
signal action_resolved(action: GFTurnAction) |
| 属性 | context |
var context: GFTurnContext = GFTurnContext.new() |
| 属性 | phases |
var phases: Array[GFTurnPhase] = [] |
| 属性 | current_phase_index |
var current_phase_index: int = -1 |
| 属性 | is_running |
var is_running: bool = false |
| 属性 | sort_actions_before_resolve |
var sort_actions_before_resolve: bool = true |
| 属性 | signal_timeout_seconds |
var signal_timeout_seconds: float = 30.0 |
| 属性 | signal_timeout_respects_time_scale |
var signal_timeout_respects_time_scale: bool = true |
| 方法 | set_context |
func set_context(p_context: GFTurnContext) -> void: |
| 方法 | set_phases |
func set_phases(p_phases: Array[GFTurnPhase]) -> void: |
| 方法 | start |
func start(reset_indices: bool = true) -> void: |
| 方法 | stop |
func stop(clear_actions: bool = true) -> void: |
| 方法 | advance_phase |
func advance_phase() -> void: |
| 方法 | enqueue_action |
func enqueue_action(action: GFTurnAction) -> void: |
| 方法 | resolve_actions |
func resolve_actions(order_resolver: Callable = Callable()) -> void: |
信号¶
flow_started¶
- API:
public
流程开始时发出。
参数:
| 名称 | 说明 |
|---|---|
context |
当前回合上下文。 |
flow_stopped¶
- API:
public
流程停止时发出。
参数:
| 名称 | 说明 |
|---|---|
context |
当前回合上下文。 |
phase_changed¶
- API:
public
阶段切换时发出。
参数:
| 名称 | 说明 |
|---|---|
phase |
当前阶段。 |
index |
当前阶段索引。 |
action_enqueued¶
- API:
public
行动入队时发出。
参数:
| 名称 | 说明 |
|---|---|
action |
入队行动。 |
action_resolved¶
- API:
public
行动解析完成时发出。
参数:
| 名称 | 说明 |
|---|---|
action |
已解析行动。 |
属性¶
context¶
- API:
public
当前回合上下文。
phases¶
- API:
public
阶段列表。
current_phase_index¶
- API:
public
当前阶段索引。
is_running¶
- API:
public
当前是否正在运行。
sort_actions_before_resolve¶
- API:
public
解析行动前是否按优先级排序。
signal_timeout_seconds¶
- API:
public
Signal 等待超时时间。小于等于 0 表示不启用超时。
signal_timeout_respects_time_scale¶
- API:
public
Signal 超时计时是否跟随 GFTimeUtility 的暂停与 time_scale。
方法¶
set_context¶
- API:
public
设置上下文。
参数:
| 名称 | 说明 |
|---|---|
p_context |
新上下文。 |
set_phases¶
- API:
public
设置阶段列表。
参数:
| 名称 | 说明 |
|---|---|
p_phases |
新阶段列表。 |
start¶
- API:
public
开始流程。
参数:
| 名称 | 说明 |
|---|---|
reset_indices |
是否重置阶段索引和轮次数据。 |
stop¶
- API:
public
停止流程。
参数:
| 名称 | 说明 |
|---|---|
clear_actions |
是否清空待处理行动。 |
advance_phase¶
- API:
public
推进到下一个阶段。
enqueue_action¶
- API:
public
加入一个行动。
参数:
| 名称 | 说明 |
|---|---|
action |
行动实例。 |
resolve_actions¶
- API:
public
解析当前上下文中的所有行动。
参数:
| 名称 | 说明 |
|---|---|
order_resolver |
可选排序回调,签名为 func(a, b) -> bool。 |