Owns all brush-shape, drag, and pending-shape state for PlacementSystem. Extracted from PlacementSystem to reduce the god-class footprint. PlacementSystem delegates state queries and mutations to this class instead of tracking half a dozen raw boolean/Vector2i flags. Lifecycle invariants: Only one of (TERRAIN_DRAG, OBJECT_LINE_DRAG, PENDING_SHAPE) can be active at a time. The previous design tracked independent booleans which made impossible composite states observable. This file now derives all is_*() queries from a single [_current_lifecycle] enum. Lifecycle rules enforced here:
- Setting a new brush shape cancels all pending/drag state (IDLE).
- Starting a drag cancels any pending state and enters TERRAIN_DRAG.
- Starting an object LINE drag cancels any pending state and enters OBJECT_LINE_DRAG.
- Anchoring a pending shape cancels any drag/state and enters PENDING_SHAPE.
- Committing or canceling clears the relevant state and returns to IDLE.
Source: addons/grid_placement/systems/building/brush_state.gd
Syntax
class BrushState extends RefCountedMembers
| Name | Kind | Summary |
|---|---|---|
active | Property | Mutually exclusive lifecycle state for the brush. Stored in [_current_lifecycle]; all is_*() getters derive from this single field. Pending multi-cell shape (see PendingShapePlacement inner class below). |
shape | Property | |
cells | Property | |
is_active | Method | |
anchor | Method | |
clear | Method | |
brush_shape | Property | -- Brush shape ------------------------------------------------ |
get_brush_shape | Method | |
set_brush_shape | Method | |
get_lifecycle | Method | |
is_terrain_dragging | Method | |
is_object_line_dragging | Method | |
is_pending | Method | |
is_idle | Method | |
start_terrain_drag | Method | |
complete_terrain_drag | Method | |
get_drag_start | Method | |
start_object_line_drag | Method | |
complete_object_line_drag | Method | |
get_object_line_drag_start | Method | |
anchor_pending | Method | |
get_pending_cells | Method | |
commit_pending | Method | |
cancel_pending | Method | |
cancel_all | Method |
Source
addons/grid_placement/systems/building/brush_state.gd
Plugin docs root:gdscript/plugins/grid_placement_dev/docs