GridPositionerLogic

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Static utility class for GridPositioner logic (visibility and decision helpers).

Source File: addons/grid_building/systems/grid_targeting/grid_positioner/grid_positioner_logic.gd

Extends: RefCounted

Constants

  • Constant: ProjectionMethod = GBEnums.ProjectionMethod
  • Constant: RecenterDecision = {

Public Methods

proj_method_to_string

1
proj_method_to_string(p_method: GBEnums.ProjectionMethod) -> String

Flags: static


should_be_visible

1
2
3
4
5
6
should_be_visible(
    mode: GBEnums.Mode,
    targeting_settings: GridTargetingSettings,
    last_mouse_input_status: GBMouseInputStatus,
    has_mouse_world: bool
) -> bool

Flags: static

Computes whether the positioner should be visible based on mode and settings.

Visibility is determined by the following priority order:

  1. Mode-based visibility: OFF mode respects remain_active_in_off_mode, INFO mode is always hidden
  2. Recent allowed input: If mouse input was recently allowed, show positioner
  3. Cached mouse world override: If mouse world position exists and mouse input enabled, show positioner (overrides hide_on_handled)
  4. Hide on handled: If mouse input enabled + hide_on_handled=true + input blocked, hide positioner
  5. Default: Show positioner for active modes (BUILD, MOVE, etc.)

Hide on handled behavior:

  • Only applies when targeting_settings.enable_mouse_input is true
  • When mouse input is disabled, hide_on_handled setting is ignored
  • Cached mouse world position takes precedence over hide_on_handled logic

mode The current building mode (GBEnums.Mode) targeting_settings The targeting settings object last_mouse_input_status Dictionary with last mouse input gate status has_mouse_world Whether cached mouse world position exists [return] True if the positioner should be visible


should_be_visible_for_mode

1
2
3
4
should_be_visible_for_mode(
    mode: GBEnums.Mode,
    targeting_settings: GridTargetingSettings
) -> bool

Flags: static

Computes visibility for a specific mode value. mode The mode to check targeting_settings The targeting settings [return] True if visible in this mode


is_positioner_active

1
2
3
4
is_positioner_active(
    mode: GBEnums.Mode,
    targeting_settings: GridTargetingSettings
) -> bool

Flags: static

Returns whether the positioner is considered active for the given mode/settings.


is_mouse_follow_allowed

1
2
3
4
5
is_mouse_follow_allowed(
    mode: GBEnums.Mode,
    targeting_settings: GridTargetingSettings,
    input_ready: bool
) -> bool

Flags: static

Mouse follow allowed gate


visibility_decision_trace

1
2
3
4
5
6
visibility_decision_trace(
    mode_state: ModeState,
    targeting_settings: GridTargetingSettings,
    last_mouse_input_status: GBMouseInputStatus,
    has_mouse_world: bool
) -> String

Flags: static

Builds a diagnostic trace string for visibility decisions. mode_state The mode state object (can be null) targeting_settings The targeting settings (can be null) last_mouse_input_status Last mouse input status dict has_mouse_world Whether cached mouse world exists [return] Formatted trace string


visibility_on_mouse_event

1
2
3
4
5
visibility_on_mouse_event(
    mode: GBEnums.Mode,
    targeting_settings: GridTargetingSettings,
    input_allowed: bool
)

Flags: static

Event-driven visibility decision helper. Returns a MouseEventVisibilityResult with apply=true when the positioner visibility should be changed because of an InputEvent (mouse motion) and visible indicating the target visibility. Reason is a short string for diagnostics.


visibility_on_process_tick

1
2
3
4
5
6
7
visibility_on_process_tick(
    mode: GBEnums.Mode,
    targeting_settings: GridTargetingSettings,
    input_ready: bool,
    last_mouse_input_status: GBMouseInputStatus,
    has_mouse_world: bool
) -> MouseEventVisibilityResult

Flags: static

Per-tick visibility decision helper used by GridPositioner2D._process. It centralizes the behavior where, even when continuous follow without events is disabled, we keep the positioner visible if recent mouse input was allowed or a cached mouse world exists. Only applies when hide_on_handled is true.


visibility_reconcile

1
2
3
4
5
6
7
visibility_reconcile(
    mode: GBEnums.Mode,
    targeting_settings: GridTargetingSettings,
    current_visible: bool,
    last_mouse_input_status: GBMouseInputStatus,
    has_mouse_world: bool
) -> MouseEventVisibilityResult

Flags: static

Per-tick reconciliation: if computed visibility differs from current, request an update. This ensures that when no event has fired yet (e.g., on scene load), the positioner is set to the expected visibility derived from mode/settings.


recenter_on_enable_decision

1
2
3
4
5
6
recenter_on_enable_decision(
    policy: int,
    has_cached_mouse_world: bool,
    mouse_input_enabled: bool,
    viewport_available: bool
) -> int

Flags: static

Decide how to recenter on enable based on policy and available context. Returns a RecenterDecision enum value indicating the preferred action. Policy mapping:

  • NONE -> NONE
  • LAST_SHOWN -> LAST_SHOWN if cached; else MOUSE_CURSOR if mouse enabled; else VIEW_CENTER
  • VIEW_CENTER -> VIEW_CENTER
  • MOUSE_CURSOR -> MOUSE_CURSOR if cached or (mouse enabled and viewport available); else VIEW_CENTER

get_tile_delta_from_key_event

1
2
3
4
get_tile_delta_from_key_event(
    event: InputEventKey,
    actions: GBActions
) -> Vector2i

Flags: static

Keyboard helper: compute tile delta from a key event and actions


get_rotation_direction_from_key_event

1
2
3
4
get_rotation_direction_from_key_event(
    event: InputEventKey,
    actions: GBActions
) -> int

Flags: static

Keyboard helper: detect rotation input from a key event and actions event The keyboard input event to check actions GBActions containing rotation action mappings [return] Rotation direction: 1 for clockwise, -1 for counter-clockwise, 0 for no rotation