class_name ActionDefinition
extends Resource

@export var action_id: StringName
@export var display_name: String
@export_range(0.0, 1000.0, 0.1) var default_duration := 1.0
@export var preferred_profession_id: StringName
@export var target_type: StringName = SimulationIds.TARGET_ACTIVITY
@export var resource_action_id: StringName


func validate() -> Array[String]:
	var errors: Array[String] = []
	if action_id.is_empty():
		errors.append("action_id is empty")
	if display_name.is_empty():
		errors.append("display_name is empty for '%s'" % action_id)
	if default_duration <= 0.0:
		errors.append("default_duration must be positive for '%s'" % action_id)
	if (
		target_type
		not in [
			SimulationIds.TARGET_RESOURCE, SimulationIds.TARGET_ACTIVITY, SimulationIds.TARGET_FREE
		]
	):
		errors.append("target_type '%s' is invalid for '%s'" % [target_type, action_id])
	if target_type == SimulationIds.TARGET_RESOURCE and resource_action_id.is_empty():
		errors.append("resource_action_id is required for '%s'" % action_id)
	return errors
