Grid Placement

ManipulationService2D

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: core/services/manipulation_service_2d.gd

Version: 5.1

class_name: ManipulationService2D extends: RefCounted

Summary

ManipulationService2D - Domain/workflow service for manipulation.

Contract (Boundary):

  • This service owns manipulation workflow/state transitions and delegates to internal managers.
  • This service does NOT translate raw input/actions. Input adapters and input routing live outside the service (e.g. orchestrators / input services) and call this service’s methods.

Contract (DI + Initialization):

  • The service can be constructed with optional dependencies, but the preferred pattern is: create with no args, then call configure(...) during composition/injection.
  • Methods that require configured dependencies call _ensure_initialized().
  • Internal managers are created lazily once required dependencies are available.

This service contains internal components previously in ManipulationSystem:

  • PhysicsLayerManager: Handles physics layer disabling/enabling during manipulation
  • ManipulationTransformHandler: Handles rotation/flip operations
  • DemolishManager: Handles demolish workflow
  • MoveWorkflowManager: Handles move copy creation and setup
  • PlacementManager: Handles placement validation and completion

Signals

  • manipulation_started
    • Emitted when a simple (legacy) manipulation starts. @param object: Node2D root being manipulated.
  • manipulation_completed
    • Emitted when a simple (legacy) manipulation completes successfully. @param object: Node2D root that was manipulated.
  • manipulation_failed
    • Emitted when a simple (legacy) manipulation fails or is canceled. @param object: Node2D root that was manipulated. @param reason: Failure/cancel reason.
  • manipulation_started_data
    • Emitted when a workflow-based manipulation begins. @param data: ManipulationData describing the started action.
  • manipulation_finished_data
    • Emitted when a workflow-based manipulation finishes successfully. @param data: ManipulationData describing the finished action.
  • manipulation_failed_data
    • Emitted when a workflow-based manipulation fails. @param data: ManipulationData describing the failed action.
  • manipulation_canceled_data
    • Emitted when a workflow-based manipulation is canceled. @param data: ManipulationData describing the canceled action.
  • data_changed
  • active_manipulatable_changed
  • parent_changed

Exports

(none)

Methods

  • _bind_states()
  • _init()
    • Constructor supports optional DI. Prefer: create with no args, then call configure(...). Note: input adapters are owned by the input/routing layer (injector/input service/orchestrators), not by this domain service.
  • configure()
    • Configure the service after creation (preferred). Safe to call multiple times; internal managers will only be created once.

Required dependencies for full workflow behavior:

  • p_manipulation_settings
  • p_states (must contain manipulation state)
  • p_indicator_context
  • set_owner_context()
  • _get_manipulator()
  • commit_active_manipulation()
  • set_build_preview()
  • _ensure_initialized()
  • get_active_manipulation()
  • get_manipulation_mode()
  • start_manipulation()
  • complete_manipulation()
  • cancel_manipulation()
  • disable_selected_physics()
  • enable_selected_physics()
  • rotate()
  • flip_horizontal()
  • flip_vertical()
  • start_move()
  • end_move()
  • try_placement()
  • 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 [return] ManipulationData describing the attempted move (status/message set on failures).
  • _get_unsupported_node_type_message()
  • finish_manipulation()
    • Finishes a manipulation action and cleans up resources. Uses ManipulationStateMachine to determine cleanup commands. Atomic: safe to call with any data state.
  • 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. Uses ManipulationStateMachine for validation logic (pure, testable).

[code]p_manipulatable[/code]: [i]Manipulatable[/i] - Component to demolish [return] ManipulationData describing the demolish attempt.

  • get_active_manipulatable()
  • set_active_manipulatable()
  • set_targeted()
    • Sets the targeted object by resolving it to a Manipulatable component.
  • clear_active_manipulatable()
  • get_data()
  • set_data()
  • clear_data()
  • has_state_mirror()
  • _on_data_status_changed()
  • reset_parent()
    • Resets the manipulation parent to its initial state.
  • _on_source_deleted()
  • _on_disable_physics_requested()
  • _on_enable_physics_requested()
  • _on_mode_changed()
  • _disconnect_source_monitoring()