EntityStateComponent ​
Inherits: RefCounted
Consolidated EntityStateComponent that manages all entity state systems. Uses clean signal-based communication throughout for better decoupling. Replaces EntityStatesComponent, BehaviorStateComponent, and CombatStateComponent.
Variables ​
Entity | entity | |
bool | is_initialized | false |
bool | is_active | false |
ChronoManager | chrono_manager | |
ModularBehaviorScript | behavior_script | |
ModularCombatScript | combat_script | |
MovementStateComponent | movement_state_component | |
NavigationController | navigation_controller | |
Area3D | pull_range_area | |
Area3D | attack_range_area | |
Area3D | player_detection_area | |
Array[Entity] | tracked_targets | [] |
Timer | los_check_timer | |
bool | player_detection_enabled | false |
Methods ​
void | initialize_for_entity( system_hub: GameHost.SystemHub, entity_ref: Entity ) |
void | activate( system_hub: GameHost.SystemHub ) |
void | complete_navigation_setup() |
void | set_active_state( system_hub: GameHost.SystemHub, active: bool ) |
void | apply_lod_level( level: GameplayConfig.LODLevel ) |
float | get_behavior_update_interval() |
bool | are_detection_areas_enabled() |
void | process_physics( delta: float ) |
void | pause_behavior() |
void | resume_behavior() |
bool | activate_schedule_by_name( schedule_name: String ) |
bool | set_active_schedule_by_index( schedule_index: int ) |
TaskSchedule | get_current_schedule() |
void | reset_current_schedule() |
void | enable_player_detection() |
void | disable_player_detection() |
void | handle_entity_death() |
void | handle_combat_entry() |
void | handle_combat_exit() |
bool | request_combat_state_change( state_name: ModularCombatScript.ActionStateName, data: Dictionary = {} ) |
void | activate_player_command_state() |
bool | is_companion() |
void | refresh_control_state() |
void | set_suspended( suspended: bool ) |
bool | may_start_fights() |
void | set_encounter( encounter: CombatSession ) |
bool | command_move_to( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_move_keep_facing( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_backpedal_to( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_strafe_to( target_position: Vector3, strafe_direction: int, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_move_to_sync( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_move_keep_facing_sync( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_backpedal_to_sync( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_strafe_to_sync( target_position: Vector3, strafe_direction: int, walk: bool = false, min_distance: float = -1.0 ) |
bool | command_follow( target: Node3D, min_distance: float = 2.0, should_walk: bool = false ) |
void | command_stop() |
void | set_approach_distance( distance: float ) |
void | handle_player_command_input() |
Dictionary | to_save_data() |
void | from_save_data( save_data: Dictionary ) |
void | cleanup_timers() |
Signals ​
entity_state_component_activated() ​
Entity lifecycle signals
entity_state_component_deactivated() ​
Emitted when the states of the entity are turned off.
behavior_paused() ​
Behavior system signals
behavior_resumed() ​
Emitted when the behavior of the entity runs again.
behavior_schedule_changed( old_schedule: TaskSchedule, new_schedule: TaskSchedule ) ​
Emitted when the entity switches to another schedule of tasks.
combat_state_changed( old_state: String, new_state: String ) ​
Combat system signals
player_detected() ​
Detection signals
player_lost() ​
Emitted when the entity loses sight of the player it was after.
Constants ​
floatPLAYER_DETECTION_RADIUS =10.0- How near the player must come for "Player nearby" reactions (the Behaviour tab draws this circle)
Variable descriptions ​
Entity entity ​
Reference to the entity this component controls
bool is_initialized = false ​
Whether the component is fully initialized
bool is_active = false ​
Whether the component is currently active
ChronoManager chrono_manager ​
ChoronoManager for timers
ModularBehaviorScript behavior_script ​
The modular behavior script that manages all behavior logic
ModularCombatScript combat_script ​
The modular combat script that manages all combat logic
MovementStateComponent movement_state_component ​
Movement state component (kept separate as it's more complex)
NavigationController navigation_controller ​
Navigation controller (kept separate as it's more complex)
Area3D pull_range_area ​
Area3D for pull range detection
Area3D attack_range_area ​
Area3D for attack range detection
Area3D player_detection_area ​
Area3D for player detection
Array[Entity] tracked_targets = [] ​
Entities being tracked for line-of-sight checking
Timer los_check_timer ​
Timer for periodic LOS checks
bool player_detection_enabled = false ​
Whether player detection is enabled
Method descriptions ​
void initialize_for_entity( system_hub: GameHost.SystemHub, entity_ref: Entity ) ​
Initialize the component with entity reference (does NOT activate systems)
void activate( system_hub: GameHost.SystemHub ) ​
Activate all systems - called when entity becomes active
void complete_navigation_setup() ​
Complete navigation setup for entities spawned before tree entry
void set_active_state( system_hub: GameHost.SystemHub, active: bool ) ​
Set the active state of all systems
void apply_lod_level( level: GameplayConfig.LODLevel ) ​
Apply LOD level settings to behavior and detection systems This is called when the Entity's lod_level property changes
float get_behavior_update_interval() ​
Get current behavior update interval
bool are_detection_areas_enabled() ​
Check if detection areas are currently enabled
void process_physics( delta: float ) ​
Called every physics frame to update all systems
void pause_behavior() ​
Pause behavior system
void resume_behavior() ​
Resume behavior system
bool activate_schedule_by_name( schedule_name: String ) ​
Activate schedule by name
bool set_active_schedule_by_index( schedule_index: int ) ​
Set active schedule by index
TaskSchedule get_current_schedule() ​
Get current schedule
void reset_current_schedule() ​
Reset current schedule
void enable_player_detection() ​
Enable player detection
void disable_player_detection() ​
Disable player detection
void handle_entity_death() ​
Handle entity's death
void handle_combat_entry() ​
Handle the entity entering combat
void handle_combat_exit() ​
Handle the entity exiting combat
bool request_combat_state_change( state_name: ModularCombatScript.ActionStateName, data: Dictionary = {} ) ​
Request combat state change
void activate_player_command_state() ​
Activate player command state
bool is_companion() ​
Is this a party member the player does not control (an AI companion)?
void refresh_control_state() ​
Put the combat state in order after the player took over this entity or gave it up (or a stance changed): the entity in control is never moved by the combat states, a companion follows the one in control or joins the fight
void set_suspended( suspended: bool ) ​
A suspended entity (a companion in the reserve) does not detect anything and its combat script is off
bool may_start_fights() ​
May this entity start a fight on its own (a pull, an ally that is fighting)? A companion on a passive stance does not
void set_encounter( encounter: CombatSession ) ​
Set encounter for combat system
bool command_move_to( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to move to a position
bool command_move_keep_facing( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to move without changing facing
bool command_backpedal_to( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to backpedal
bool command_strafe_to( target_position: Vector3, strafe_direction: int, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to strafe
bool command_move_to_sync( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to move to a position
bool command_move_keep_facing_sync( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to move without changing facing
bool command_backpedal_to_sync( target_position: Vector3, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to backpedal
bool command_strafe_to_sync( target_position: Vector3, strafe_direction: int, walk: bool = false, min_distance: float = -1.0 ) ​
Command entity to strafe
bool command_follow( target: Node3D, min_distance: float = 2.0, should_walk: bool = false ) ​
Command entity to follow another entity
void command_stop() ​
Command entity to stop moving
void set_approach_distance( distance: float ) ​
Set approach distance
void handle_player_command_input() ​
Handle player command input
Dictionary to_save_data() ​
Save runtime state for behavior and combat scripts
void from_save_data( save_data: Dictionary ) ​
Restore runtime state from saved data
void cleanup_timers() ​
Clean up all timers and resources