Grid Placement

BuildingSystem

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: systems/building/building_system.gd

Version: 5.1

class_name: BuildingSystem extends: GBSystem

Summary

Manages building/placement orchestration for a single owner scope.

Behavior contract:

  • Service-first system: delegates placement session state, validation, and configuration to injected services (e.g. PlacementService / TargetingService2D / ManipulationService2D).
  • Does not read or mutate shared state objects directly.
  • Coordinates preview lifecycle and build actions, emitting success/failure via services.

Scope/Topology:

  • Create exactly one BuildingSystem per GBOwner scope that needs building/placement.
  • Multiple owners (players/agents) should each have their own GBCompositionContainer and their own BuildingSystem instance (no cross-owner state or service sharing).

Signals

(none)

Exports

(none)

Methods

  • get_placement_service()
    • Returns the PlacementService from the injected GBCompositionContainer, or null when unavailable.
  • is_ready_to_place()
    • Returns true if system is ready to place a selected placeable Delegates to PlacementService for state-agnostic validation
  • is_in_build_mode()
    • Returns true if the building system is currently in build mode Delegates to PlacementService for mode state checking
  • exit_build_mode()
    • Exits build mode and cleans up all build-related elements Delegates to PlacementService for mode management
  • resolve_gb_dependencies()
    • Resolves and injects all required dependencies from the composition container.

Sets up all system dependencies including states, settings, contexts, actions, and logger. Connects to mode change signals and initializes lazy components. Validates that all dependencies are properly configured and logs any issues found.

[param p_container] The composition container providing all system dependencies and configuration.

  • try_build()
    • Attempts to build the current placement configuration Delegates to PlacementService for placement logic and validation

[param p_build_type] Type of build operation (SINGLE, DRAG, or AREA). Defaults to SINGLE.

  • try_build_at_position()
    • Attempts to build at a specific position Delegates to PlacementService for position-based placement
  • enter_build_mode()
    • Sets up a preview instance for the selected placeable. Switches to build mode, clears previous preview, and creates a new preview instance. Returns true if setup is successful.[br][br] [code]p_placeable[/code]: [i]Placeable[/i] - Placeable resource to create preview for
  • clear_preview()
    • Clears the current building preview and resets all related state.

Removes the preview instance, tears down placement indicators, and resets the manipulation parent transform to prevent rotation persistence between placeables. Called when exiting build mode, switching placeables, or clearing the current preview.

  • _on_build_mode_pressed()
  • _on_off_mode_pressed()
  • _on_confirm_build_pressed()
  • instance_preview()
    • Creates and sets up a preview instance for the specified placeable.

Instantiates a preview version of the placeable, sets it as the selected placeable, and initializes placement rules and indicators for visual feedback. The preview instance is used to show where the building will be placed before confirmation.

[param p_placeable] The placeable resource to create a preview instance for. [return] The created preview Node2D instance, or null if creation fails.

  • get_runtime_issues()
    • Validates that all required dependencies are set. This is called automatically when entering build mode, but can also be called manually after scene loads to check if all dependencies are properly configured. Returns list of validation issues (empty if valid).
  • get_builder_owner()
    • Retrieves the current builder owner from the placement service.

Gets the GBOwner instance that represents the root node context for building operations. This owner is used to determine the scene hierarchy and ownership for placed buildings.

[return] The current GBOwner instance, or null if placement service is not available.

  • report_built()
    • Reports a successful build action through the placement service.

[param p_report] The placement report for the build action [param p_build_type] Type of build operation (SINGLE, DRAG, or AREA)

  • report_failure()
    • Reports a failed build action through the placement service.

[param p_report] The placement report containing failure details and issues. [param p_build_type] Type of build operation that failed (SINGLE, DRAG, or AREA).

  • report_success()
    • Reports a successful build action through the placement service.

Emits the success signal on the placement service with the placement report and build type. Used to notify listeners that a build operation succeeded and provide details about the success.

[param p_report] The placement report containing success details. [param p_build_type] Type of build operation that succeeded (SINGLE, DRAG, or AREA).

  • _validate_build_ready()
    • Validates that all required components are properly configured for building.

Performs comprehensive validation of the building system state, including dependency injection status and critical component availability. Asserts on critical configuration issues to catch setup problems early in development.

[return] True if the building system is ready for placement operations, false otherwise.