Skip to content

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 ​

Stringschedule_name"Default Schedule"
Array[BehaviorTask]task_sequence[]
boolloop_sequencetrue
floatcooldown_time0.0
Array[EntityCondition]activation_conditions[]
boolrequire_all_conditionstrue
FailureHandlingfailure_handlingFailureHandling.SKIP_TO_NEXT
boolrandomize_orderfalse

Variables ​

Entityentity
floatlast_activation_time-INF
intexecution_count0
BehaviorTaskcurrent_executing_tasknull
ChronoManagerchrono_manager

Methods ​

voidsetup_schedule( system_hub: GameHost.SystemHub, entity_ref: Entity )
voidon_activated()
voidon_deactivated()
voidstart_schedule()
voidon_task_completed( completed_task: BehaviorTask )
voidon_task_failed( failed_task: BehaviorTask, reason: String )
voidon_task_interrupted( interrupted_task: BehaviorTask, reason: String )
boolcan_activate( entity: Entity )
voidadd_task( task: BehaviorTask )
voidinsert_task( index: int, task: BehaviorTask )
voidremove_task( index: int )
BehaviorTaskget_effective_task( index: int )
intget_effective_size()
BehaviorTaskget_current_task()
voidreset_schedule()
Stringget_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