ManipulationParent
Summary
Section titled “Summary”ManipulationParent - Transform container for preview objects during manipulation.
Applies rotation, translation, and scale transforms to preview objects during building/manipulation. All child nodes automatically inherit these transforms through Godot’s scene tree.
Indicators are ALWAYS parented to IndicatorManager.
IMPORTANT: IndicatorManager should be parented to ManipulationParent (not as a sibling). This ensures indicators inherit rotation and transform from ManipulationParent via scene tree.
Top-Down/Platformer: IndicatorManager as child of ManipulationParent (indicators rotate with preview) Isometric: IndicatorManager as child of ManipulationParent (indicators maintain correct orientation)
Key Methods - apply_rotation(degrees)
- Rotate this node and all children - apply_horizontal_flip()
- Flip horizontally - apply_vertical_flip()
- Flip vertically - reset()
- Reset to identity transform
Section titled “Key Methods - apply_rotation(degrees) - Rotate this node and all children - apply_horizontal_flip() - Flip horizontally - apply_vertical_flip() - Flip vertically - reset() - Reset to identity transform”Transform Behavior - Manipulation start: Resets to identity - During manipulation: Accumulates transforms - Manipulation end/cancel: Resets to identity
Section titled “Transform Behavior - Manipulation start: Resets to identity - During manipulation: Accumulates transforms - Manipulation end/cancel: Resets to identity”For detailed parenting decisions, isometric considerations, and architectural patterns: See docs/v5-0/guides/isometric_implementation.mdx
For system architecture: See docs/systems/parent_node_architecture.md
Methods
Section titled “Methods”func reset( )
Resets the transform of the node to identity. This is called at the start, end, and cancellation of manipulation operations to ensure consistent positioning and prevent transform accumulation issues.
func apply_rotation( degrees: float ) -> void
Applies rotation to this ManipulationParent node. All child nodes will automatically inherit this rotation through Godot’s scene tree.
Architecture Reasoning: - ManipulationParent is a Node2D, so transforming it automatically transforms all children - Preview objects are typically children of ManipulationParent - Indicators are parented to IndicatorManager; IndicatorManager should be child of ManipulationParent - IndicatorManager as child of ManipulationParent: indicators inherit rotation/scale/flip transforms - No need for complex child-finding logic - Godot handles transform inheritance - Cleaner separation of concerns: ManipulationSystem handles logic, ManipulationParent handles transforms
degrees
: Rotation amount in degrees to apply to this node and all childrenfunc apply_grid_rotation_clockwise( target_map: TileMapLayer, increment_degrees: float ) -> float
Apply grid-aware clockwise rotation to this ManipulationParent. Uses cardinal direction rotation (90-degree increments) for grid-aligned objects.
:::tip[Important] When ManipulationParent rotates, all child nodes inherit the rotation transform. Indicators are always parented to IndicatorManager. IndicatorManager should be a child of ManipulationParent so indicators inherit the same rotation/scale/flip transforms as the preview object. :::
See docs/v5-0/guides/isometric_implementation.mdx for parenting strategies.
target_map
: TileMapLayer for grid alignment calculationsincrement_degrees
: Rotation increment in degrees (default 90.0 for 4-direction) Returns: The new rotation angle in degrees (0-360 range)func apply_grid_rotation_counter_clockwise( target_map: TileMapLayer, increment_degrees: float ) -> float
Apply grid-aware counter-clockwise rotation to this ManipulationParent. Uses the rotation increment from parameter (default 90° for 4-direction). Supports configurable increments: 45° for 8-direction, 30° for 12-direction, etc.
target_map
: TileMapLayer for grid alignment calculationsincrement_degrees
: Rotation increment in degrees (default 90.0 for 4-direction) Returns: The new rotation angle in degrees (0-360 range)func apply_horizontal_flip( ) -> void
Applies horizontal flip to this ManipulationParent node. All child nodes will automatically inherit this scale change through transform inheritance.
[param] None - applies horizontal flip (scale.x *= -1) to this node and all children
func apply_vertical_flip( ) -> void
Applies vertical flip to this ManipulationParent node. All child nodes will automatically inherit this scale change through transform inheritance.
[param] None - applies vertical flip (scale.y *= -1) to this node and all children
func _unhandled_input( event: InputEvent ) -> void
— FLIP H / V —
Handles input events for manipulation transform operations. Processes transform inputs directly at the point where transform methods are defined.
Architecture Reasoning: - ManipulationParent owns transform methods and should handle related input - Eliminates delegation chain: Input → ManipulationSystem → ManipulationParent - Creates self-contained transform handling in one place - ManipulationSystem can focus on higher-level manipulation logic
func _input( event: InputEvent ) -> void
Route standard input to unhandled to support tests or scenes that call _input directly.
func _get_manipulation_settings( ) -> ManipulationSettings
Gets manipulation settings from dependency context.
func _get_actions( ) -> GBActions
Gets actions from dependency context.
func _get_target_map_from_states( states: GBStates ) -> TileMapLayer
Gets the target map from the targeting state for grid-aware rotation.
states
: The complete states container Returns: TileMapLayer for grid calculations, or null if not availablefunc resolve_gb_dependencies( p_container: GBCompositionContainer ) -> void
func get_runtime_issues( ) -> Array[String]
Validates that manipulation state is properly configured. Returns validation issues if state is missing or incorrectly configured.
Ensures that: - ManipulationState is properly assigned - This node is registered as the parent in ManipulationState - Transform operations will function correctly
return
: Array[String] - List of validation issues (empty if valid)func _on_started( p_data: ManipulationData )
func _on_finished( p_data: ManipulationData )
func _on_canceled( p_data: ManipulationData )
Source
Section titled “Source”addons/grid_building/systems/manipulation/manipulation_parent.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.