feat: define action completion costs
This commit is contained in:
@@ -7,6 +7,8 @@ extends Resource
|
||||
@export var preferred_profession_id: StringName
|
||||
@export var target_type: StringName = SimulationIds.TARGET_ACTIVITY
|
||||
@export var resource_action_id: StringName
|
||||
@export var completion_cost_resource_id: StringName
|
||||
@export_range(0.0, 1000.0, 0.1) var completion_cost_amount := 0.0
|
||||
|
||||
|
||||
func validate() -> Array[String]:
|
||||
@@ -26,4 +28,12 @@ func validate() -> Array[String]:
|
||||
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)
|
||||
if completion_cost_resource_id.is_empty() and completion_cost_amount > 0.0:
|
||||
errors.append("completion cost resource is required for '%s'" % action_id)
|
||||
if not completion_cost_resource_id.is_empty() and completion_cost_amount <= 0.0:
|
||||
errors.append("completion cost amount must be positive for '%s'" % action_id)
|
||||
return errors
|
||||
|
||||
|
||||
func has_completion_cost() -> bool:
|
||||
return not completion_cost_resource_id.is_empty() and completion_cost_amount > 0.0
|
||||
|
||||
@@ -129,4 +129,15 @@ static func validate() -> Array[String]:
|
||||
% [definition.action_id, definition.resource_action_id]
|
||||
)
|
||||
)
|
||||
if (
|
||||
not definition.completion_cost_resource_id.is_empty()
|
||||
and definition.completion_cost_resource_id
|
||||
not in [SimulationIds.RESOURCE_FOOD, SimulationIds.RESOURCE_WOOD]
|
||||
):
|
||||
errors.append(
|
||||
(
|
||||
"Action '%s' references unknown completion cost resource '%s'"
|
||||
% [definition.action_id, definition.completion_cost_resource_id]
|
||||
)
|
||||
)
|
||||
return errors
|
||||
|
||||
@@ -38,4 +38,5 @@ const EVENT_ITEM_CONSUMED := &"item_consumed"
|
||||
const EVENT_NPC_SLEPT := &"npc_slept"
|
||||
const EVENT_NPC_DIED := &"npc_died"
|
||||
const EVENT_TASK_STARTED := &"task_started"
|
||||
const EVENT_TASK_BLOCKED := &"task_blocked"
|
||||
const EVENT_RESOURCE_DEPLETED := &"resource_depleted"
|
||||
|
||||
@@ -9,3 +9,5 @@ display_name = "Patrol"
|
||||
default_duration = 6.0
|
||||
preferred_profession_id = &"guard"
|
||||
target_type = &"activity"
|
||||
completion_cost_resource_id = &"wood"
|
||||
completion_cost_amount = 1.0
|
||||
|
||||
@@ -9,3 +9,5 @@ display_name = "Study"
|
||||
default_duration = 6.0
|
||||
preferred_profession_id = &"scholar"
|
||||
target_type = &"activity"
|
||||
completion_cost_resource_id = &"wood"
|
||||
completion_cost_amount = 1.0
|
||||
|
||||
Reference in New Issue
Block a user