ULimenGridSpawner
Overview
ULimenGridSpawner is a USceneComponent that allows you to create and manage a grid of nodes. It provides functionality to spawn, retrieve, and clean up these nodes based on specified parameters such as grid size and node offset. This component can be used in various scenarios where a structured layout of actors is required.
Properties
Type | Name | Access | Description |
|---|---|---|---|
int32 | GridX | EditAnywhere, BlueprintReadOnly | The number of nodes along the X-axis (default: 3). Must be at least 3. |
int32 | GridY | EditAnywhere, BlueprintReadOnly | The number of nodes along the Y-axis (default: 3). Must be at least 3. |
TSubclassOf | GridNodeActorClass | EditAnywhere, BlueprintReadOnly | The class of actor to use as a node in the grid. |
FVector2D | GridNodeOffset | EditAnywhere, BlueprintReadOnly | The offset between nodes in the X and Y directions (default: (10.f, 10.f)). |
Functions
Return Type | Signature | Description |
|---|---|---|
void | CreateGrid() | Creates a grid of nodes based on the specified parameters. |
bool | CanCreateGrid() const | Checks if it is possible to create a grid with the current settings. |
TArray<UChildActorComponent*> | GetNodes() const | Returns an array of all child actor components representing the grid nodes. |
UChildActorComponent* | GetNodeAt(const int32 Index) const | Retrieves the node at the specified index in the grid. |
UChildActorComponent* | GetNodeByCoordinate(const FIntVector2& Coordinates) const | Retrieves the node at the specified coordinate (X, Y). |
AActor* | GetNodeActorByCoordinate(const FIntVector2& Coordinates) const | Retrieves the actor associated with the node at the specified coordinate. |
Usage & Implementation Notes
Threading Constraints: This component does not perform any operations that require threading constraints.
Replication Requirements: This component is designed to be used in a single-player or local environment and does not require replication.
Memory Lifetime Management: Nodes are created as transient objects, meaning they will be automatically cleaned up when the owning actor is destroyed. The
CleanupGridfunction ensures that all nodes are properly unregistered, destroyed, and removed from memory.Initialization Dependencies: This component requires a valid
GridNodeActorClassto be set before callingCreateGrid.