Event ​
Inherits: DatabaseResource < Resource
Self-managing event that handles its own trigger evaluation and condition checking
Properties ​
bool | enabled | true |
bool | run_once | false |
Array[EventTrigger] | triggers | [] |
Array[Condition] | conditions | [] |
Array[EventAction] | actions | [] |
LocalVariables | local_variables | LocalVariables.new() |
Variables ​
EventState | state | EventState.NOT_STARTED |
int | current_action_index | 0 |
EventAction | current_action | null |
Methods ​
Signals ​
state_changed( event: Event, new_state: int ) ​
Emitted when the state of the event changes.
trigger_activated( event: Event, trigger: EventTrigger, event_data: Dictionary ) ​
Emitted when a trigger of the event fires, with its data.
conditions_failed( event: Event ) ​
Emitted when a trigger fired but the conditions of the event were not met.
local_variable_changed( event: Event, key: String, old_value: Variant, new_value: Variant ) ​
Emitted when a local variable of the event changes: its name, the old and the new value.
local_variable_removed( event: Event, key: String, old_value: Variant ) ​
Emitted when a local variable of the event is removed.
Enumerations ​
enum EventState ​
The states of an event: not started, in progress, completed or failed.
- NOT_STARTED =
0 - IN_PROGRESS =
1 - COMPLETED =
2 - FAILED =
3
Property descriptions ​
bool enabled = true ​
True when the event can run. A disabled event ignores its triggers.
bool run_once = false ​
Runs only once: after the event has completed, its triggers no longer start it (a new game starts it fresh again). Off: it runs every time a trigger fires
Array[EventTrigger] triggers = [] ​
What starts the event (a signal, a place, a timer ...).
Array[Condition] conditions = [] ​
What must be true when a trigger fires for the event to run.
Array[EventAction] actions = [] ​
What the event does, in order.
LocalVariables local_variables = LocalVariables.new() ​
The variables of this event (see the Variables chapter).
Variable descriptions ​
EventState state = EventState.NOT_STARTED ​
The state of the event now.
int current_action_index = 0 ​
The place of the action that runs now.
EventAction current_action = null ​
The action that runs now.
Method descriptions ​
void set_system_hub( system_hub: GameHost.SystemHub ) ​
Gives the triggers, conditions and actions the hub of the game systems.
void setup_triggers() ​
Setup this event's triggers (called by EventManager during initialization)
void cleanup_triggers() ​
Cleanup this event's triggers
bool check_conditions() ​
Are all the conditions of the event met (the event is not run)? A spawner asks it to know whether it may work.
bool can_trigger() ​
Check if the event can be triggered
void start() ​
Start the event (conditions already checked)
void force_complete() ​
Force-complete all actions in the event
void fail() ​
Mark the event as failed
void reset() ​
Reset the event to its initial state
bool force_trigger() ​
Manually trigger this event (bypasses conditions)
bool try_trigger( event_data: Dictionary = {} ) ​
Manually trigger this event with condition checking
String get_action_progress() ​
Get current action progress info for debugging
EventAction get_current_action() ​
Get currently executing action
Array[Condition] get_failed_conditions() ​
Get list of failed conditions for debugging
Dictionary save() ​
The state of the event for a save: its state, the action that runs and its variables.
void load_data( data: Dictionary ) ​
Restores the event from a save.
void set_local_variable( key: String, value: Variant ) ​
Sets a local variable of the event.
Variant get_local_variable( key: String, default_value: Variant = null ) ​
The value of a local variable, or the default when it does not exist.
bool has_local_variable( key: String ) ​
Does the event have this local variable?
bool remove_local_variable( key: String ) ​
Removes a local variable. False when it did not exist.
void clear_all_local_variables() ​
Removes every local variable of the event.
Array get_all_local_variable_keys() ​
The names of the local variables of the event.
int get_local_variable_count() ​
How many local variables the event has.
void increment_local_variable( key: String, amount: float = 1.0 ) ​
Increment a numeric local variable
void decrement_local_variable( key: String, amount: float = 1.0 ) ​
Decrement a numeric local variable
void toggle_local_variable( key: String ) ​
Toggle a boolean local variable
void append_to_local_variable( key: String, text: String ) ​
Append to a string local variable
void add_to_local_array_variable( key: String, item: Variant ) ​
Add item to array local variable
bool remove_from_local_array_variable( key: String, item: Variant ) ​
Remove item from array local variable
bool local_array_variable_contains( key: String, item: Variant ) ​
Check if array local variable contains item
Array[Dictionary] get_local_variables_for_editor() ​
Get local variables formatted for editor display
Array[Dictionary] validate_local_variables() ​
Validate all local variables
String get_local_variables_debug_string() ​
Get local variables debug string
Dictionary create_local_variables_snapshot() ​
Create snapshot of local variables
bool restore_local_variables_from_snapshot( snapshot: Dictionary ) ​
Restore local variables from snapshot
void set_id( new_id: int ) ​
Override to ensure local variables always has correct parent event ID
LocalVariables get_local_variables() ​
Get local variables instance (for direct access if needed)