PlaceableSequenceFactory
Summary
Section titled “Summary”Factory utilities for creating and normalizing PlaceableSequence collections.
This factory implements the “Helper Factory (Suggested)” pattern mentioned in the UI PlaceableSequence guide documentation. It provides convenient methods for: - Converting individual Placeables into single-item sequences - Normalizing mixed arrays of Placeables and PlaceableSequences - Reducing UI wiring code when working with PlaceableList components
Usage Context: These utilities are designed for cases where you have existing Placeable collections but need to use them with PlaceableSequenceSelectionUI or PlaceableList components that expect PlaceableSequence objects.
:::note[Note] Currently not used in the main plugin demos, but provided as convenience utilities for game developers who need sequence normalization. :::
Methods
Section titled “Methods”static func from_placeables( placeables: Array[Placeable] ) -> Array[PlaceableSequence]
Converts an array of individual Placeables into single-item PlaceableSequences. Each Placeable becomes a sequence containing only that one item, preserving the original display name and allowing it to work with sequence-based UI components.
placeables
: Array of Placeable resources to convert Returns: Array of PlaceableSequence objects, each containing one original PlaceableUsage Example:
var individual_buildings: Array[Placeable] = [tower, wall, gate]var sequences: Array[PlaceableSequence] = PlaceableSequenceFactory.from_placeables(individual_buildings)placeable_sequence_ui.sequences = sequences:::note[Note] Null placeables are automatically filtered out during conversion. :::
static func ensure_sequences( mixed: Array ) -> Array[PlaceableSequence]
Normalizes a mixed array of Placeables and PlaceableSequences into sequences only. This implements the “normalize_sequences” pattern suggested in the documentation, allowing flexible input while ensuring consistent sequence-based output for UI components.
mixed
: Array containing any combination of Placeable and PlaceableSequence objects Returns: Array containing only PlaceableSequence objects (singles wrapped, sequences preserved)Usage Example:
var mixed_items: Array = [single_tower, wall_sequence, gate_placeable, defense_sequence]var normalized: Array[PlaceableSequence] = PlaceableSequenceFactory.ensure_sequences(mixed_items)placeable_list.populate_with_sequences(normalized)Behavior: - PlaceableSequence objects are preserved as-is - Placeable objects are wrapped in single-item sequences - Null items are automatically filtered out - Maintains original display names and properties
Source
Section titled “Source”addons/grid_building/placeables/placeable_sequence_factory.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.