GFInventoryOperationResult¶
API Reference / Domain / 类索引
- 路径:
addons/gf/extensions/domain/inventory/gf_inventory_operation_result.gd - 模块:
Domain - 继承:
RefCounted - API:
public - 类别:值对象 (
value_object) - 首次版本:
3.17.0
通用库存操作结果。 描述一次添加、移除、移动或合并操作的接受数量、剩余数量和失败原因。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 属性 | ok |
var ok: bool = false |
| 属性 | item_id |
var item_id: StringName = &"" |
| 属性 | requested_amount |
var requested_amount: int = 0 |
| 属性 | accepted_amount |
var accepted_amount: int = 0 |
| 属性 | remaining_amount |
var remaining_amount: int = 0 |
| 属性 | source_slot |
var source_slot: int = -1 |
| 属性 | target_slot |
var target_slot: int = -1 |
| 属性 | reason |
var reason: StringName = &"" |
| 属性 | metadata |
var metadata: Dictionary = {} |
| 方法 | success |
static func success( result_item_id: StringName, amount: int, result_source_slot: int = -1, result_target_slot: int = -1 ) -> GFInventoryOperationResult: |
| 方法 | partial |
static func partial( result_item_id: StringName, requested: int, accepted: int, result_reason: StringName, result_source_slot: int = -1, result_target_slot: int = -1 ) -> GFInventoryOperationResult: |
| 方法 | is_partial_success |
func is_partial_success() -> bool: |
| 方法 | to_dict |
func to_dict() -> Dictionary: |
属性¶
ok¶
- API:
public
操作是否完全成功。
item_id¶
- API:
public
物品标识。
requested_amount¶
- API:
public
请求处理的数量。
accepted_amount¶
- API:
public
实际处理的数量。
remaining_amount¶
- API:
public
未处理的剩余数量。
source_slot¶
- API:
public
源槽位。没有源槽位时为 -1。
target_slot¶
- API:
public
目标槽位。没有目标槽位时为 -1。
reason¶
- API:
public
操作结果原因。
metadata¶
- API:
public
项目自定义元数据。
结构:
metadata: Dictionary,项目自定义操作结果元数据;GF 会在 to_dict() 中复制输出。
方法¶
success¶
- API:
public
static func success( result_item_id: StringName, amount: int, result_source_slot: int = -1, result_target_slot: int = -1 ) -> GFInventoryOperationResult:
创建成功结果。
参数:
| 名称 | 说明 |
|---|---|
result_item_id |
物品标识。 |
amount |
处理数量。 |
result_source_slot |
源槽位。 |
result_target_slot |
目标槽位。 |
返回:操作结果。
partial¶
- API:
public
static func partial( result_item_id: StringName, requested: int, accepted: int, result_reason: StringName, result_source_slot: int = -1, result_target_slot: int = -1 ) -> GFInventoryOperationResult:
创建失败或部分成功结果。
参数:
| 名称 | 说明 |
|---|---|
result_item_id |
物品标识。 |
requested |
请求数量。 |
accepted |
实际处理数量。 |
result_reason |
操作结果原因。 |
result_source_slot |
源槽位。 |
result_target_slot |
目标槽位。 |
返回:操作结果。
is_partial_success¶
- API:
public
检查操作是否处理了部分数量。
返回:有部分处理返回 true。
to_dict¶
- API:
public
转换为字典。
返回:操作结果字典。
结构:
return: Dictionary,包含 ok、item_id、requested_amount、accepted_amount、remaining_amount、source_slot、target_slot、reason 与 metadata。