PrioritySchedule ​
Inherits: TaskSchedule < Resource
PrioritySchedule executes tasks based on priority and conditions using clean signal-based communication. Tasks are evaluated each time and the highest priority valid task is selected. This is ideal for reactive behavior where conditions frequently change.
Properties ​
ExecutionType | execution_type | ExecutionType.PRIORITY |
float | priority_evaluation_interval | 1.0 |
bool | allow_task_interruption | true |
int | interruption_priority_threshold | 10 |
Variables ​
Timer | priority_timer | null |
float | last_priority_check | 0.0 |
Array[Dictionary] | last_evaluation_results | [] |
Methods ​
void | start_schedule() |
void | on_task_completed( completed_task: BehaviorTask ) |
void | on_task_failed( failed_task: BehaviorTask, reason: String ) |
void | on_task_interrupted( interrupted_task: BehaviorTask, reason: String ) |
void | on_deactivated() |
void | reset_schedule() |
void | force_priority_evaluation() |
void | set_interruption_threshold( threshold: int ) |
void | add_task_with_evaluation( task: BehaviorTask, evaluate_immediately: bool = true ) |
void | remove_task_with_replacement( index: int ) |
BehaviorTask | get_current_task() |
bool | has_available_tasks() |
Array[BehaviorTask] | get_available_tasks_by_priority() |
Array[Dictionary] | get_last_evaluation_results() |
String | get_debug_status() |
Dictionary | get_evaluation_stats() |
Signals ​
priority_evaluated( selected_task: BehaviorTask, available_tasks: Array[BehaviorTask] ) ​
Emitted when priority evaluation occurs
task_interrupted_for_priority( old_task: BehaviorTask, new_task: BehaviorTask ) ​
Emitted when a task is interrupted for higher priority
no_valid_tasks_available() ​
Emitted when no valid tasks are available
Enumerations ​
enum ExecutionType ​
The execution strategy for this schedule
Property descriptions ​
ExecutionType execution_type = ExecutionType.PRIORITY ​
Priority: the highest task whose conditions are met runs.
Priority Settings
float priority_evaluation_interval = 1.0 ​
How often to re-evaluate task priorities (seconds)
bool allow_task_interruption = true ​
Whether to interrupt current task if higher priority task becomes available
int interruption_priority_threshold = 10 ​
Minimum priority difference required to interrupt current task
Variable descriptions ​
Timer priority_timer = null ​
Timer for priority re-evaluation
float last_priority_check = 0.0 ​
Last time priorities were evaluated
Array[Dictionary] last_evaluation_results = [] ​
Cache of last evaluation results
Method descriptions ​
void start_schedule() ​
Start this schedule - find and start highest priority task
void on_task_completed( completed_task: BehaviorTask ) ​
Called when current task completes - find next best task
void on_task_failed( failed_task: BehaviorTask, reason: String ) ​
Called when current task fails
void on_task_interrupted( interrupted_task: BehaviorTask, reason: String ) ​
Called when current task is interrupted
void on_deactivated() ​
Called when the schedule stops: the priority timer is freed.
void reset_schedule() ​
Reset the schedule
void force_priority_evaluation() ​
Force immediate priority re-evaluation
void set_interruption_threshold( threshold: int ) ​
Set minimum priority difference for interruption
void add_task_with_evaluation( task: BehaviorTask, evaluate_immediately: bool = true ) ​
Add a task and optionally trigger immediate evaluation
void remove_task_with_replacement( index: int ) ​
Remove a task and find replacement if it was current
BehaviorTask get_current_task() ​
Get current task (compatibility method)
bool has_available_tasks() ​
Check if schedule has tasks available
Array[BehaviorTask] get_available_tasks_by_priority() ​
Get all available tasks sorted by priority
Array[Dictionary] get_last_evaluation_results() ​
Get task evaluation results for debugging
String get_debug_status() ​
Get detailed status for debugging
Dictionary get_evaluation_stats() ​
Get priority evaluation statistics