ControllerLogic ​
Inherits: Resource
Inherited by: PointAndClickRTSLogic, PointAndClickSingleLogic, WASDWithMouseLogic
Base player controller logic resource - both configuration and runtime behavior Save instances to res://src/data/controller_logic/player/
Description ​
Child classes:
Add exported properties for configuration
Override setup/process_input/handle_input_event for behavior
Override get_type_display_name() for editor display
Properties ​
String | preset_name | "Unnamed Controller" |
bool | block_input_with_window_open | false |
String | description | "" |
float | look_sensitivity_scale | 1.0 |
Variables ​
GameHost.SystemHub | system_hub | |
PlayerController | controller | |
Player | current_player | null |
Methods ​
void | initialize( p_system_hub: GameHost.SystemHub ) |
void | setup( controller: PlayerController ) |
bool | is_typing() |
bool | is_blocked_by_window() |
void | process_input( delta: float ) |
void | handle_input_event( event: InputEvent ) |
void | cleanup() |
Array[Entity] | get_selected_units() |
Entity | get_current_player() |
bool | can_handle_targeting() |
bool | can_handle_abilities() |
bool | can_handle_direct_movement() |
bool | can_handle_keyboard_interact() |
void | select_single_player( player: Entity ) |
void | toggle_player_selection( player: Entity ) |
MovementBasis | get_movement_basis() |
Array[LookBinding] | get_look_bindings() |
Array[int] | get_exclusive_buttons() |
void | handle_look( kind: LookBinding.Kind, delta_rad: Vector2 ) |
void | on_look_state( kind: LookBinding.Kind, active: bool ) |
void | on_click_completed( button_index: int, position: Vector2 ) |
void | process_target_lock( delta: float ) |
void | on_target_lock_changed( is_locked: bool, target: Variant ) |
bool | handle_esc_input() |
String | get_type_display_name() |
String | get_editor_icon() |
Array[String] | validate() |
bool | is_enemy( player: Player, target: Entity ) static |
bool | should_interrupt_cast( player: Player ) static |
float | get_attack_range( player: Player ) static |
bool | is_within_interaction_distance( player: Player, interactable: Variant ) static |
bool | can_interact_with_npc( npc: NPC ) static |
float | get_npc_interaction_distance( npc: NPC, player: Player ) static |
void | move_player_with_cast_check( player: Player, target_position: Vector3, face_target: bool = false, stop_distance: float = 0.0 ) static |
void | move_to_and_attack( player: Player, target: Entity ) static |
void | set_target_with_cast_stop( player: Player, target: Entity ) static |
Enumerations ​
enum MovementBasis ​
What direction WASD-style movement is relative to
- CHARACTER =
0 - CAMERA =
1
enum SecondaryActionTrigger ​
When a controller's right-click action (attack / interact / command) fires
- PRESS =
0 - RELEASE_WITHOUT_DRAG =
1
Property descriptions ​
String preset_name = "Unnamed Controller" ​
Display name shown in editor dropdowns
bool block_input_with_window_open = false ​
While a window (an inventory, a character sheet) is open the controller ignores the keys and the mouse of the game: the player stands still and uses nothing until the window is closed (the keys that open and close the windows still work). Off: the player walks and fights with a window open. A window of screen space 0 does not count
String description = "" ​
Description of controller behavior
Mouse Look
float look_sensitivity_scale = 1.0 ​
How sensitive THIS preset feels, relative to the player's mouse sensitivity setting (SettingsConfig.mouse_x/y_axis_sensitivity). 1.0 = exactly the player's setting. The player's setting itself is never changed here - this is only the preset's feel.
Variable descriptions ​
GameHost.SystemHub system_hub ​
System hub reference (set at runtime)
PlayerController controller ​
The player controller this logic belongs to.
Player current_player = null ​
The player this logic controls now.
Method descriptions ​
void initialize( p_system_hub: GameHost.SystemHub ) ​
Initialize with system hub reference - called by PlayerController
void setup( controller: PlayerController ) ​
Setup controller behavior - override in child classes
bool is_typing() ​
Is the player typing in a text field (the chat box)? The keys are letters then, not movement or abilities
bool is_blocked_by_window() ​
Is the input of the game blocked now: the controller blocks it while a window is open (block_input_with_window_open) and a window is open
void process_input( delta: float ) ​
Per-frame input processing - override in child classes
void handle_input_event( event: InputEvent ) ​
Handle input events - override in child classes
void cleanup() ​
Cleanup when switching controllers - override in child classes
Array[Entity] get_selected_units() ​
Get currently selected units (RTS mode)
Entity get_current_player() ​
Get the primary controlled player
bool can_handle_targeting() ​
Can this controller handle ability targeting?
bool can_handle_abilities() ​
Can this controller handle ability keybinds?
bool can_handle_direct_movement() ​
Can this controller handle direct WASD movement?
bool can_handle_keyboard_interact() ​
Can this controller handle keyboard-based interactions?
void select_single_player( player: Entity ) ​
Select a single player (called by UI/external systems)
void toggle_player_selection( player: Entity ) ​
Toggle player selection (called by UI/external systems)
MovementBasis get_movement_basis() ​
What movement is relative to. The camera asks this: with CAMERA movement it must not follow the body while walking (the body follows the camera instead) and right-drag orbits the camera.
Array[LookBinding] get_look_bindings() ​
Mouse gestures this controller wants (button + LookBinding.Kind). Called when a gesture starts.
Array[int] get_exclusive_buttons() ​
Mouse buttons this controller uses for its own click/drag handling (e.g. LMB drag-box select). Look bindings that a camera declares on these buttons are dropped.
void handle_look( kind: LookBinding.Kind, delta_rad: Vector2 ) ​
Look movement for a gesture this controller declared. delta_rad is screen-space radians with the player's sensitivity and invert settings applied (x > 0 = mouse right, y > 0 = mouse down). Multiply by look_sensitivity_scale.
void on_look_state( kind: LookBinding.Kind, active: bool ) ​
A gesture this controller declared started (active = true) or ended (active = false)
void on_click_completed( button_index: int, position: Vector2 ) ​
A look binding that requires a drag was released before it became a drag (a plain click)
void process_target_lock( delta: float ) ​
Called every frame when player has a locked target Child classes should implement character rotation toward target here
void on_target_lock_changed( is_locked: bool, target: Variant ) ​
Called when target lock is toggled on/off Child classes can use this for setup/cleanup
bool handle_esc_input() ​
Handle ESC key press with priority chain Returns true if the logic handled it, false to let controller handle it Priority chain (controller will handle these if logic returns false): 1. Cancel targeting mode 2. Clear target 3. Clear selection (multi-unit)
String get_type_display_name() ​
Get display name for editor
String get_editor_icon() ​
Get icon for editor
Array[String] validate() ​
Validate settings - return errors array
bool is_enemy( player: Player, target: Entity ) ​
Check if player and target are enemies
bool should_interrupt_cast( player: Player ) ​
Check if player should interrupt their cast (immobilizing cast + new action)
float get_attack_range( player: Player ) ​
Get the attack range for a player's basic attack
bool is_within_interaction_distance( player: Player, interactable: Variant ) ​
Check if player is within interaction distance of an interactable
bool can_interact_with_npc( npc: NPC ) ​
Check if an NPC has a valid interaction
float get_npc_interaction_distance( npc: NPC, player: Player ) ​
Get the interaction distance for an NPC (falls back to player's range)
void move_player_with_cast_check( player: Player, target_position: Vector3, face_target: bool = false, stop_distance: float = 0.0 ) ​
Helper to interrupt cast if needed and move player
void move_to_and_attack( player: Player, target: Entity ) ​
Helper to move player to target and initiate attack
void set_target_with_cast_stop( player: Player, target: Entity ) ​
Helper to set target and stop casting