TaskSchedule ​
Inherits: Resource
Inherited by: OrderedSchedule, PrioritySchedule
Enhanced TaskSchedule with comprehensive signal-based task management. Clean signal architecture for better decoupling and easier debugging.
Properties ​
String | schedule_name | "Default Schedule" |
Array[BehaviorTask] | task_sequence | [] |
bool | loop_sequence | true |
float | cooldown_time | 0.0 |
Array[EntityCondition] | activation_conditions | [] |
bool | require_all_conditions | true |
FailureHandling | failure_handling | FailureHandling.SKIP_TO_NEXT |
bool | randomize_order | false |
Variables ​
Entity | entity | |
float | last_activation_time | -INF |
int | execution_count | 0 |
BehaviorTask | current_executing_task | null |
ChronoManager | chrono_manager |
Methods ​
void | setup_schedule( system_hub: GameHost.SystemHub, entity_ref: Entity ) |
void | on_activated() |
void | on_deactivated() |
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 ) |
bool | can_activate( entity: Entity ) |
void | add_task( task: BehaviorTask ) |
void | insert_task( index: int, task: BehaviorTask ) |
void | remove_task( index: int ) |
BehaviorTask | get_effective_task( index: int ) |
int | get_effective_size() |
BehaviorTask | get_current_task() |
void | reset_schedule() |
String | get_debug_status() |
Signals ​
schedule_task_started( task: BehaviorTask ) ​
Emitted when the schedule starts a new task
schedule_task_completed( task: BehaviorTask ) ​
Emitted when the schedule completes a task
schedule_task_failed( task: BehaviorTask, reason: String ) ​
Emitted when the schedule fails a task
schedule_task_interrupted( task: BehaviorTask, reason: String ) ​
Emitted when a task is interrupted
schedule_completed() ​
Emitted when the entire schedule completes
schedule_aborted( reason: String ) ​
Emitted when the schedule is aborted
schedule_looped() ​
Emitted when the schedule loops back to start
Enumerations ​
enum FailureHandling ​
The options of failure handling: skip to next, retry task, restart schedule, abort schedule.
- SKIP_TO_NEXT =
0- Skip failed task and continue to next - RETRY_TASK =
1- Retry the failed task - RESTART_SCHEDULE =
2- Restart from beginning of schedule - ABORT_SCHEDULE =
3- Stop schedule execution
Property descriptions ​
String schedule_name = "Default Schedule" ​
Display name for this schedule (used for identification and debugging)
Array[BehaviorTask] task_sequence = [] ​
The sequence of tasks to execute in order
bool loop_sequence = true ​
Whether to loop through tasks when reaching the end
float cooldown_time = 0.0 ​
Minimum time between schedule activations (seconds)
Execution Conditions
Array[EntityCondition] activation_conditions = [] ​
Conditions that must be met for this schedule to be selectable
bool require_all_conditions = true ​
Whether ALL conditions must be met (true) or ANY condition (false)
Behavior Settings
FailureHandling failure_handling = FailureHandling.SKIP_TO_NEXT ​
How to handle task failures in this schedule
bool randomize_order = false ​
Whether to randomize task order within the sequence
Variable descriptions ​
Entity entity ​
Reference to the entity using this schedule
float last_activation_time = -INF ​
When this schedule was last activated
int execution_count = 0 ​
Number of times this schedule has been executed
BehaviorTask current_executing_task = null ​
Currently executing task
ChronoManager chrono_manager ​
ChronoManager ref
Method descriptions ​
void setup_schedule( system_hub: GameHost.SystemHub, entity_ref: Entity ) ​
Setup the schedule with entity reference
void on_activated() ​
Called when this schedule becomes active
void on_deactivated() ​
Called when this schedule is deactivated
void start_schedule() ​
Start this schedule - should be overridden by derived classes
void on_task_completed( completed_task: BehaviorTask ) ​
Called when current task completes - should be overridden by derived classes
void on_task_failed( failed_task: BehaviorTask, reason: String ) ​
Called when current task fails - handled by _handle_task_failure first
void on_task_interrupted( interrupted_task: BehaviorTask, reason: String ) ​
Called when current task is interrupted
bool can_activate( entity: Entity ) ​
Check if this schedule can be activated based on all conditions
void add_task( task: BehaviorTask ) ​
Add a task to the end of the sequence
void insert_task( index: int, task: BehaviorTask ) ​
Insert a task at a specific index
void remove_task( index: int ) ​
Remove a task at a specific index
BehaviorTask get_effective_task( index: int ) ​
Get the effective task at the given index (considering randomization)
int get_effective_size() ​
Get the effective size of the task sequence
BehaviorTask get_current_task() ​
Get the current task being executed
void reset_schedule() ​
Reset the schedule to its initial state
String get_debug_status() ​
Get a status string for debugging