54 lines
1.0 KiB
GDScript
54 lines
1.0 KiB
GDScript
class_name ActionCommand
|
|
extends RefCounted
|
|
|
|
var _command_id: StringName
|
|
var _actor_id: StringName
|
|
var _action_id: StringName
|
|
var _target: WorldTargetHandle
|
|
var _parameters: Dictionary
|
|
|
|
|
|
func _init(
|
|
command_id: StringName = &"",
|
|
actor_id: StringName = &"",
|
|
action_id: StringName = &"",
|
|
target: WorldTargetHandle = null,
|
|
parameters: Dictionary = {}
|
|
) -> void:
|
|
_command_id = command_id
|
|
_actor_id = actor_id
|
|
_action_id = action_id
|
|
_target = target
|
|
_parameters = parameters.duplicate(true)
|
|
|
|
|
|
func is_valid() -> bool:
|
|
return (
|
|
not _command_id.is_empty()
|
|
and not _actor_id.is_empty()
|
|
and not _action_id.is_empty()
|
|
and _target != null
|
|
and _target.is_well_formed()
|
|
and not WorldTargetCapability._contains_object(_parameters)
|
|
)
|
|
|
|
|
|
func get_command_id() -> StringName:
|
|
return _command_id
|
|
|
|
|
|
func get_actor_id() -> StringName:
|
|
return _actor_id
|
|
|
|
|
|
func get_action_id() -> StringName:
|
|
return _action_id
|
|
|
|
|
|
func get_target() -> WorldTargetHandle:
|
|
return _target
|
|
|
|
|
|
func get_parameters() -> Dictionary:
|
|
return _parameters.duplicate(true)
|