Skip to content

SwitchAction ​

Inherits: EventAction < Resource

A multi-branch conditional action that executes different sets of actions based on which condition is met first. Works like a switch/case statement.

Description ​

Each case consists of a condition and a set of actions. The first condition that evaluates to true will have its associated actions executed.

Properties ​

Array[Case]cases[]
Array[EventAction]default_actions[]
boolwait_for_actionstrue

Variables ​

Eventparent_eventnull
intactive_case_index-2
Array[EventAction]active_actions[]
Array[bool]completed_actions[]

Methods ​

voidset_system_hub( p_system_hub: GameHost.SystemHub )
Stringget_function_description()
voidset_parent_event( event: Event )
voidcleanup()
voidforce_complete()
voidreset()
Dictionarysave()
voidload_data( data: Dictionary )

Property descriptions ​

Array[Case] cases = [] ​

Array of cases with conditions and actions

Array[EventAction] default_actions = [] ​

Actions to execute if no conditions are met (default case)

bool wait_for_actions = true ​

Whether to complete this action when all child actions complete

Variable descriptions ​

Event parent_event = null ​

Reference to parent event (set by Event when action starts)

int active_case_index = -2 ​

Currently active case index (-1 for default case)

Array[EventAction] active_actions = [] ​

Actions of the active case

Array[bool] completed_actions = [] ​

Tracks which actions have completed

Method descriptions ​

void set_system_hub( p_system_hub: GameHost.SystemHub ) ​

Gives the action, its conditions and its branches the hub of the game systems.

String get_function_description() ​

The sentence the editor shows for the action, with {placeholders} for its values.

void set_parent_event( event: Event ) ​

Set the parent event (called by Event before starting action)

void cleanup() ​

Override cleanup to disconnect from child actions

void force_complete() ​

Override force_complete to force-complete all child actions

void reset() ​

Override reset to reset all child actions

Dictionary save() ​

Override save to include all case and action states

void load_data( data: Dictionary ) ​

Override load_data to restore all case and action states