BuildingSystem
AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
Source: systems/building/building_system.gd
Version: 5.0
class_name: BuildingSystem
extends: GBSystem
Summary
Manages placement of objects in the game world.
Handles preview, placement validation, and build actions. Uses tile collision indicators to show valid/invalid spots before placement. Checks all rules before adding objects to the world and emits signals for build success or failure.
Signals
(none)
Exports
(none)
Methods
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. Sets the mode to OFF, clears the preview, and tears down indicators.
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.
[param 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.[br][br] [code]p_placeable[/code]: [i]Placeable[/i] - 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.
_exit_build_cleanup()- Cleans up build mode elements and resets indicators. Cleans up build mode elements, clears preview, and resets indicator manager. Called when exiting build mode or switching modes.
_unhandled_input()- 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.
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.[br][br] [code]p_placeable[/code]: [i]Placeable[/i] - 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
[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 BuildingState
[param p_report] The placement report for the build action [param p_build_type] Type of build operation (SINGLE, DRAG, or AREA)
_get_lazy_building_instantiator()- Private lazy getter for building instantiator. Creates and configures the instantiator if it doesn’t exist.[br][br] [code]return[/code]: [i]BuildingInstantiator[/i] - The building instantiator instance
_get_lazy_preview_builder()- Private lazy getter for preview builder. Creates and configures the preview builder if it doesn’t exist.[br][br] [code]return[/code]: [i]PreviewBuilder[/i] - The preview builder instance
_try_setup()_build_instance()- 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.[br][br] [code]p_placeable[/code]: [i]Placeable[/i] - Placeable resource to build[br] [code]p_attach_placeable_instance[/code]: [i]bool[/i] - Whether to attach PlaceableInstance component
_validate_build_ready()- Validates if the building system is ready for placement.
_align_preview_to_grid()- 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()- Handles changes to build mode. Cleans up build state and indicators when switching out of build mode.