BuildingSystem
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
Manages placement of objects in the game world.
Source File: /addons/grid_building/systems/building/building_system.gd
Extends: GBSystem
Properties
- Property:
placement_polygons: Array[CollisionPolygon2D]- Collision polygons for placement indicators. - Property:
preview_layer: int- Preview layer index for buildable/unbuildable tiles. - Property:
selected_placeable: [Placeable](./placeable/)- Currently selected placeable resource. - Property:
indicators_group: Node2D- Parent node for collision indicators.
Private Properties
Property:
_building_instantiator : [BuildingInstantiator](./building-instantiator/)(private) - Instantiates building objects for placement.Property:
_building_settings : [BuildingSettings](./building-settings/)(private) - Settings for grid building system operation.Property:
_states : [GBStates](./gb-states/)(private) - Shared states for plugin systems.Property:
_systems_context : [GBSystemsContext](./gb-systems-context/)(private) - Context for resolving references to current objects.Property:
_indicator_context : [IndicatorContext](./indicator-context/)(private) - Placement management and rules context.Property:
_actions : [GBActions](./gb-actions/)(private)Property:
_logger : [GBLogger](./gb-logger/)(private)Property:
_container: [GBCompositionContainer](./gb-composition-container/)(private) - Keep a reference to the container for lazy component creationProperty:
_cleaning_up: bool = false(private)Guard flag to prevent re-entrant calls to _exit_build_cleanup. Reset in exit_build_mode() to prevent leakage across scene_runner test cycles.
Property:
_preview_builder : [PreviewBuilder](./preview-builder/)(private)Property:
_report : [PlacementReport](./placement-report/)(private) - The report of the active ongoing placementProperty:
_build_drag_event: InputEventScreenDrag(private)Tracks drag events for build button. InputEventScreenDrag instance used to track drag events for build actions. Updated as the user drags to new tiles during multi-build mode.
Constants
- Constant:
WARNING_INVALID_PLACEABLE = "Invalid placeable resource. Can't instantiate. [%s]" - Constant:
WARNING_NO_PREVIEW = "No preview instance created to instantiate yet. Returning null."
Public Methods
create_with_injection
| |
Flags: static
Creates a BuildingSystem with injected dependencies from the container.
get_building_state
| |
legacy accessors expected in some validator/integration tests
get_targeting_state
| |
is_ready_to_place
| |
Returns true if system is ready to place a selected placeable (should already be set) Checks if the system is ready to build by validating the selected placeable and build context. Returns true if all build requirements are met and no issues are found.
is_in_build_mode
| |
Returns true if the building system is currently in build mode. Checks the current mode state to determine if build mode is active.
exit_build_mode
| |
Exits build mode and cleans up all build-related elements. Resets the _cleaning_up guard to prevent leakage across scene_runner test cycles.
resolve_gb_dependencies
| |
try_build
| |
Attempts to place a building at the current preview location if all placement rules pass. Validates all placement rules and emits success or failure signals based on the result. Returns the built Node2D if successful, null otherwise.
p_build_type Type of build operation (SINGLE, DRAG, or AREA). Defaults to SINGLE.
try_build_at_position
| |
Legacy API compatibility method for tests Attempts to place a building at the specified position Temporarily moves the targeting system to the position, attempts placement, then restores position
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.
p_placeable: Placeable - Placeable resource to create preview for
clear_preview
| |
Removes the current preview instance. Removes the current preview instance and resets placement manager state. Called when exiting build mode or clearing preview.
instance_preview
| |
Creates a preview instance with limited functionality. Strips scripts not needed for preview and replaces root node script if set in config. Used for visual feedback before placement.
p_placeable: Placeable - Placeable resource to create preview instance for
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
| |
Get the current GBOwner of the building object which is the root node of the GBOwner in the active GBOwnerContext that is assigned to the BuildingState
report_built
| |
Connects BuildingSystem to a DragManager scene component for drag-building support. Reports a successful build action through the BuildingState
p_report The placement report for the build action
p_build_type Type of build operation (SINGLE, DRAG, or AREA)
report_failure
| |
Reports a failed build action through the BuildingState
p_report The placement report for the build action
p_build_type Type of build operation (SINGLE, DRAG, or AREA)
Private Methods
_exit_build_cleanup
| |
Flags: private
Cleans up build mode elements and resets indicators. Uses a _cleaning_up guard to prevent re-entrant calls from multiple exit paths. The guard flag is NOT reset at the end — it’s reset by exit_build_mode() or _on_mode_changed() before the next cleanup cycle. This prevents the mode_changed signal callback from defeating the guard for the subsequent direct call.
_unhandled_input
| |
Flags: private
Handles input for building controls. Handles input events for building controls, including build confirmation and mode switching. Processes input based on current build mode and user actions.
_get_lazy_building_instantiator
| |
Flags: private
Private lazy getter for building instantiator. Creates and configures the instantiator if it doesn’t exist.
return: BuildingInstantiator - The building instantiator instance
_get_lazy_preview_builder
| |
Flags: private
Private lazy getter for preview builder. Creates and configures the preview builder if it doesn’t exist.
return: PreviewBuilder - The preview builder instance
_try_setup
| |
Flags: private
_build_instance
| |
Flags: private
Places the buildable scene into the world. Instantiates and places the buildable scene into the world at the preview location. Attaches PlaceableInstance if required and applies placement rules.
p_placeable: Placeable - Placeable resource to build
p_attach_placeable_instance: bool - Whether to attach PlaceableInstance component
_validate_build_ready
| |
Flags: private
Validates if the building system is ready for placement.
_align_preview_to_grid
| |
Flags: private
Aligns preview to the grid system. Aligns the preview instance to the grid system based on the given global position. Used to snap preview to grid tiles for accurate placement feedback.
_on_mode_changed
| |
Flags: private
Handles changes to build mode. Cleans up build state and indicators when switching out of build mode. Resets the _cleaning_up guard for non-exit_build_mode mode-change paths.
Grid Building v5.0.8 | Generated 24/05/2026