ManipulationSystem
AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
Source: systems/manipulation/manipulation_system.gd
Version: 5.0
class_name: ManipulationSystem
extends: GBSystem
Summary
System for manipulating (move, rotate, flip, demolish, build preview integration) grid building objects.
Responsibilities:
- Creates and manages a temporary manipulation copy (“move copy”) when entering MOVE workflows.
- Delegates spatial translation to the external targeting/positioner system. (No per-frame movement logic here.)
- Sets up and tears down placement validation rules for move and build actions.
- Manages physics layer disabling/enabling during active manipulation.
- Emits structured status transitions via
ManipulationData.status(STARTED, FAILED, FINISHED, CANCELED).
Non‑Responsibilities (by design):
- Calculating or enforcing cursor/keyboard driven position updates (handled by GridTargetingSystem & its positioner node).
- Determining selection/target acquisition (handled by targeting state & systems).
- Rendering or UI feedback (delegated to name displayer / external UI nodes).
Design Notes:
- The move copy is parented under the active positioner when available so that any positioner movement (mouse, keyboard, gamepad) naturally repositions the copy without duplicate logic or tight coupling.
- If no positioner exists (edge/test fallback), the copy is parented under the manipulation parent as a legacy behavior.
- Rotation / flip actions operate directly on the target Node2D passed in, typically the move copy’s root while an action is active.
Signals
move_indicators_ready- Emitted when move indicators have been fully set up after physics frame Passes the array of created indicators for debugging and validation
Exports
(none)
Methods
_are_dependencies_ready()- Validates that all required dependencies are properly set. Returns list of validation issues (empty if valid). Checks if all critical dependencies are ready for operation. Returns true if the system can safely process operations.
get_runtime_issues()resolve_gb_dependencies()_ensure_manipulation_settings()- Ensures _manipulation_settings is initialized with a default instance if null. This prevents string formatting crashes when dependencies haven’t been resolved yet. The default will be replaced with the real settings when resolve_gb_dependencies() is called.
_check_dependencies_resolved()- Checks if dependencies have been properly resolved. Returns false and logs error if not resolved.
_get_unsupported_node_type_message()- Gets the unsupported node type error message. [param p_node_class] The class name of the unsupported node
try_move()- Attempts to move a targeted object. Failed or successful move data available through state signals.[br][br] [code]p_root[/code]: [i]Node[/i] - Container node to search for Manipulatable component
_start_move()- Creates a manipulation (move) copy and prepares rule validation.
Flow:
- Clone source manipulatable root via
create_copy. - Parent under manipulation parent node.
- Reset transform if configured.
- Align initial global position to the parent root. Parent root is responsible for moving object.
- Initialize placement validation rules using IndicatorManager.
- Disable configured physics layers on the original source.
Returns true if setup succeeded; false if rule setup failed.
try_placement()- Attempts to place a manipulated object at the desired location. Validates placement rules and commits the move if successful.[br][br] [code]p_move[/code]: [i]ManipulationData[/i] - Movement data containing source and target information
is_ready()- Checks if the manipulation system is ready for operations.
cancel()- Cancels the active manipulation action.
try_demolish()- Attempts to demolish the given manipulatable object and returns manipulation data for result inspection. Only succeeds if the object is configured as demolishable.[br][br] [code]p_manipulatable[/code]: [i]Manipulatable[/i] - Component to demolish
demolish()- Demolishes a manipulatable object and returns true when the object is successfully removed. [code]p_manipulatable[/code]: [i]Manipulatable[/i] - Component to demolish; defaults to active manipulatable when null
rotate()- Rotates the target node by the specified degrees. Delegates to ManipulationParent’s transform coordination.
flip_horizontal()- Flips the target node horizontally. Delegates to ManipulationParent’s transform coordination.
flip_vertical()- Flips the target node vertically. Delegates to ManipulationParent’s transform coordination.
get_targeted()- Get the root node of the current targeted object for this manipulation system
set_targeted()- Sets the manipulation root to be the obj root
_unhandled_input()- Handles input events for manipulation system controls. Responds to demolish, info, moving, and off mode actions.[br][br] [code]event[/code]: [i]InputEvent[/i] - Input event to process for manipulation controls
_input()- Route standard input to unhandled to support tests or scenes that call _input directly.
_perform_manipulation_actions()_finish()- Finishes a manipulation action and cleans up resources.
_on_mode_changed()_process()- While moving, keep the target copy aligned with the positioner so tests detect movement shifts.
_on_target_changed()- NOTE: _process removed. Movement visuals are driven by reparenting the move copy under the positioner.
_on_preview_changed()_send_manipulation_failed()- Sends manipulation failed signal for failed operations.
_disable_selected_physics()- Disables physics layers for objects during manipulation.
_enable_selected_physics()- Re-enables physics layers that were disabled during manipulation.
_on_source_tree_exiting()- Handles source object leaving the scene tree during manipulation. Automatically cancels manipulation to prevent operating on deleted objects.
_disconnect_source_monitoring()- Disconnects source object monitoring signal if connected.
_get_demolish_display_name()- Gets a display name appropriate for demolish messaging, preferring the manipulatable root when available.
_clear_manipulation_data()- Clears manipulation data reference when the provided data matches the active state.
_debug_node()_describe_layers()