跳转至

GFBuffEffect

API Reference / Combat / 类索引

  • 路径:addons/gf/extensions/combat/attributes/gf_buff_effect.gd
  • 模块:Combat
  • 继承:Resource
  • API:public
  • 类别:协议与扩展点 (protocol)
  • 首次版本:6.0.0

Buff 可组合效果基类。 作为数据化 Buff 的通用效果扩展点,响应 apply、remove、refresh 和 tick 生命周期。 基类不规定伤害、治疗、控制等业务语义;项目可通过子类实现具体效果。

成员概览

类型 名称 签名
属性 effect_id var effect_id: StringName = &""
属性 metadata var metadata: Dictionary = {}
方法 apply func apply(context: Dictionary) -> Dictionary:
方法 remove func remove(context: Dictionary) -> Dictionary:
方法 refresh func refresh(context: Dictionary) -> Dictionary:
方法 tick func tick(context: Dictionary) -> Dictionary:
方法 get_state_snapshot func get_state_snapshot() -> Dictionary:
方法 restore_state_snapshot func restore_state_snapshot(snapshot: Dictionary) -> void:
方法 _apply func _apply(_context: Dictionary) -> Dictionary:
方法 _remove func _remove(_context: Dictionary) -> Dictionary:
方法 _refresh func _refresh(_context: Dictionary) -> Dictionary:
方法 _tick func _tick(_context: Dictionary) -> Dictionary:
方法 _get_state_snapshot func _get_state_snapshot() -> Dictionary:
方法 _restore_state_snapshot func _restore_state_snapshot(_snapshot: Dictionary) -> void:

属性

effect_id

  • API:public
  • 首次版本:6.0.0
var effect_id: StringName = &""

效果标识,用于诊断、状态快照或项目侧过滤。

metadata

  • API:public
  • 首次版本:6.0.0
var metadata: Dictionary = {}

项目自定义元数据。GF 不解释其中字段。

结构:

  • metadata: Dictionary project-defined effect metadata.

方法

apply

  • API:public
  • 首次版本:6.0.0
func apply(context: Dictionary) -> Dictionary:

响应 Buff 应用。

参数:

名称 说明
context Buff 生命周期上下文。

返回:效果报告。

结构:

  • context: Dictionary with buff, owner, event, and metadata.
  • return: Dictionary with ok, reason, effect_id, and metadata.

remove

  • API:public
  • 首次版本:6.0.0
func remove(context: Dictionary) -> Dictionary:

响应 Buff 移除。

参数:

名称 说明
context Buff 生命周期上下文。

返回:效果报告。

结构:

  • context: Dictionary with buff, owner, event, reason, and metadata.
  • return: Dictionary with ok, reason, effect_id, and metadata.

refresh

  • API:public
  • 首次版本:6.0.0
func refresh(context: Dictionary) -> Dictionary:

响应 Buff 刷新。

参数:

名称 说明
context Buff 生命周期上下文。

返回:效果报告。

结构:

  • context: Dictionary with buff, owner, event, refresh_duration, and metadata.
  • return: Dictionary with ok, reason, effect_id, and metadata.

tick

  • API:public
  • 首次版本:6.0.0
func tick(context: Dictionary) -> Dictionary:

响应 Buff tick。

参数:

名称 说明
context Buff 生命周期上下文。

返回:效果报告。

结构:

  • context: Dictionary with buff, owner, event, delta, and metadata.
  • return: Dictionary with ok, reason, effect_id, and metadata.

get_state_snapshot

  • API:public
  • 首次版本:6.0.0
func get_state_snapshot() -> Dictionary:

获取效果运行时状态快照。

返回:状态快照。

结构:

  • return: Dictionary project-defined effect state payload.

restore_state_snapshot

  • API:public
  • 首次版本:6.0.0
func restore_state_snapshot(snapshot: Dictionary) -> void:

恢复效果运行时状态。

参数:

名称 说明
snapshot 状态快照。

结构:

  • snapshot: Dictionary project-defined effect state payload.

_apply

  • API:protected
  • 首次版本:6.0.0
func _apply(_context: Dictionary) -> Dictionary:

Buff 应用钩子。

参数:

名称 说明
_context Buff 生命周期上下文。

返回:效果报告。

结构:

  • _context: Dictionary with buff, owner, event, and metadata.
  • return: Dictionary with optional ok, reason, and metadata.

_remove

  • API:protected
  • 首次版本:6.0.0
func _remove(_context: Dictionary) -> Dictionary:

Buff 移除钩子。

参数:

名称 说明
_context Buff 生命周期上下文。

返回:效果报告。

结构:

  • _context: Dictionary with buff, owner, event, reason, and metadata.
  • return: Dictionary with optional ok, reason, and metadata.

_refresh

  • API:protected
  • 首次版本:6.0.0
func _refresh(_context: Dictionary) -> Dictionary:

Buff 刷新钩子。

参数:

名称 说明
_context Buff 生命周期上下文。

返回:效果报告。

结构:

  • _context: Dictionary with buff, owner, event, refresh_duration, and metadata.
  • return: Dictionary with optional ok, reason, and metadata.

_tick

  • API:protected
  • 首次版本:6.0.0
func _tick(_context: Dictionary) -> Dictionary:

Buff tick 钩子。

参数:

名称 说明
_context Buff 生命周期上下文。

返回:效果报告。

结构:

  • _context: Dictionary with buff, owner, event, delta, and metadata.
  • return: Dictionary with optional ok, reason, and metadata.

_get_state_snapshot

  • API:protected
  • 首次版本:6.0.0
func _get_state_snapshot() -> Dictionary:

状态快照钩子。

返回:状态快照。

结构:

  • return: Dictionary project-defined effect state payload.

_restore_state_snapshot

  • API:protected
  • 首次版本:6.0.0
func _restore_state_snapshot(_snapshot: Dictionary) -> void:

状态恢复钩子。

参数:

名称 说明
_snapshot 状态快照。

结构:

  • _snapshot: Dictionary project-defined effect state payload.