跳转至

GFTurnPhase

API Reference / Turn Based / 类索引

  • 路径:addons/gf/extensions/turn_based/resources/gf_turn_phase.gd
  • 模块:Turn Based
  • 继承:Resource
  • API:public
  • 类别:协议与扩展点 (protocol)
  • 首次版本:3.17.0

通用回合阶段基类。 阶段只提供 _enter/_execute/_exit 生命周期和完成信号, 不绑定任何具体游戏流程。

成员概览

类型 名称 签名
信号 finished signal finished
属性 phase_id var phase_id: StringName = &""
属性 auto_finish var auto_finish: bool = true
方法 finish func finish(context: GFTurnContext = null) -> void:
方法 is_finished_for func is_finished_for(context: GFTurnContext) -> bool:
方法 _enter func _enter(_context: GFTurnContext) -> void:
方法 _execute func _execute(_context: GFTurnContext) -> Variant:
方法 _exit func _exit(_context: GFTurnContext) -> void:

信号

finished

  • API:public
signal finished

阶段完成时发出。

属性

phase_id

  • API:public
var phase_id: StringName = &""

阶段标识。

auto_finish

  • API:public
var auto_finish: bool = true

_execute() 返回后是否自动完成阶段。

方法

finish

  • API:public
  • 首次版本:8.0.0
func finish(context: GFTurnContext = null) -> void:

标记指定上下文的阶段运行完成。

参数:

名称 说明
context 活动 Flow 的上下文;只有一个运行态时可省略。

is_finished_for

  • API:public
  • 首次版本:8.0.0
func is_finished_for(context: GFTurnContext) -> bool:

查询指定上下文的阶段是否完成。

参数:

名称 说明
context 活动 Flow 的上下文。

返回:对应运行态存在且已经完成时返回 true。

_enter

  • API:protected
func _enter(_context: GFTurnContext) -> void:

进入阶段时由 GFTurnFlowSystem 调用。

参数:

名称 说明
_context 回合上下文。

_execute

  • API:protected
  • 首次版本:3.17.0
func _execute(_context: GFTurnContext) -> Variant:

执行阶段逻辑时由 GFTurnFlowSystem 调用。

参数:

名称 说明
_context 回合上下文。

返回:可等待结果。

结构:

  • return: Variant that is null or a Signal awaited before phase completion.

_exit

  • API:protected
func _exit(_context: GFTurnContext) -> void:

退出阶段时由 GFTurnFlowSystem 调用。

参数:

名称 说明
_context 回合上下文。