refactor: unify interactable components
This commit is contained in:
20
_Core/interactions/InteractionAction.gd
Normal file
20
_Core/interactions/InteractionAction.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
class_name InteractionAction
|
||||
extends RefCounted
|
||||
|
||||
# 交互管理器使用的强类型动作数据,避免各交互物品以 Dictionary 约定字段。
|
||||
var id: String = ""
|
||||
var title: String = ""
|
||||
var priority: int = 100
|
||||
var distance: float = INF
|
||||
var activate: Callable = Callable()
|
||||
|
||||
static func create(action_id: String, action_title: String, action_priority: int, callback: Callable) -> InteractionAction:
|
||||
var action: InteractionAction = InteractionAction.new()
|
||||
action.id = action_id
|
||||
action.title = action_title
|
||||
action.priority = action_priority
|
||||
action.activate = callback
|
||||
return action
|
||||
|
||||
func is_valid() -> bool:
|
||||
return not id.strip_edges().is_empty() and not title.strip_edges().is_empty() and activate.is_valid()
|
||||
Reference in New Issue
Block a user