PlacementReport
Summary
Section titled “Summary”Comprehensive report for placement operation results and validation feedback.
The PlacementReport class serves as a detailed snapshot of any placement attempt within the Grid Building system. It encapsulates all relevant information about build, move, or placement operations, providing a complete audit trail for debugging, logging, and user feedback.
Core Purpose:
This class aggregates data from multiple sources to provide a unified view of:
-
The entity performing the placement action
-
The object being placed or manipulated
-
Validation results from rule checking systems
-
Any issues or problems encountered during the process
-
Diagnostic notes for debugging and monitoring
Primary Use Cases:
-
Success Validation: Determine if a placement operation completed successfully
-
Error Reporting: Collect and present validation failures to users
-
Debugging Support: Provide detailed diagnostic information for developers
-
Audit Logging: Maintain records of all placement attempts and outcomes
-
System Integration: Pass placement results between different system components
Architecture Integration:
The report works closely with:
-
[member indicators_report]: Results from RuleCheckIndicator validation
-
[member placer]: The GBOwner entity initiating the placement
-
[member preview_instance]: The Node2D being tested for placement validity
Usage Example:
# Create a placement report after attempting to buildvar report = PlacementReport.new(placer, preview, indicators_report, GBEnums.Action.BUILD)
# Check if placement was successfulif report.is_successful(): print("Placement completed successfully!") # Log successful placement for analytics log_placement_success(report)else: print("Placement failed: ", report.get_issues()) # Handle placement failure - show user feedback show_placement_errors(report)Key Properties:
-
[member placer]: The GBOwner entity responsible for initiating placement
-
[member preview_instance]: The Node2D object being placed/tested
-
[member indicators_report]: Validation results from IndicatorSetupReport
-
[member action_type]: Type of placement action (GBEnums.Action)
-
[member issues]: Array of error messages and validation failures
-
[member notes]: Additional diagnostic information and metadata
Thread Safety: This class is not thread-safe. All operations should be
performed on the main thread to ensure proper integration with Godot’s scene system.
Performance Notes: Reports are lightweight objects designed for frequent
creation during placement operations. Memory usage scales with the number of
issues and notes collected.
Properties
Section titled “Properties”placer: GBOwnerGBOwner for the root entity responsible for placing the preview_instance into the game world. This represents the player, AI, or other entity that initiated the placement action.
preview_instance: NodeThe preview instance for the object being manipulated (built, placed, etc.). This is the Node2D that represents the object being tested for placement validity.
placed: NodeThe root of the placed object (if any). This should be set after successful placement
indicators_report: IndicatorSetupReportThe report from RuleCheckIndicator generation for the preview object. Contains detailed information about collision detection, rule validation, and indicator setup.
action_type: GBEnums.ActionThe type of action that was attempted for this placement. Indicates whether this was a BUILD, MOVE, or other type of placement operation.
issues: Array[String] = []General setup issues encountered during the placement attempt. Contains error messages and validation failures that prevented successful placement.
notes: Array[String] = []Additional notes collected at setup time (aggregated from indicator reports and validator). Contains diagnostic information and metadata about the placement process.
Methods
Section titled “Methods”func add_issue( p_issue: String ) -> voidAdds an issue to the report’s issues list.
Issues represent problems or validation failures that occurred during placement.
p_issue: The issue message to add to the reportfunc add_note( p_note: String ) -> voidAdds a diagnostic note to the report’s notes list.
Notes contain additional information about the placement process that may be useful for debugging or logging, but don’t represent errors.
p_note: The diagnostic note to add to the reportfunc get_owner_root( ) -> NodeReturns the root node of the entity responsible for placement.
This is a convenience method that accesses the owner_root property of the placer.
Returns: The root Node of the GBOwner entity, or null if no placer is set
func to_verbose_string( ) -> StringConverts the report to a detailed multi-line string representation.
Generates a comprehensive string containing all report information including success status, action type, preview details, indicator report summary, issues, and notes. Useful for debugging and logging.
Returns: A formatted string representation of the entire report
func is_successful( ) -> boolDetermines if the placement attempt was successful.
A placement is considered successful if there are no issues in either the main report or the indicators report.
Returns:
trueif placement was successful,falseotherwisefunc get_issues( ) -> Array[String]Returns all issues from both the main report and indicators report.
Combines issues from the report’s own issues array with any issues found in the indicators report, providing a complete list of all problems encountered during the placement attempt.
Returns: An array containing all issues from the report and indicators
Source
Section titled “Source”addons/grid_building/placement/manager/placement_report.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.