CHexaSpawner
Overview
ACHexaSpawner is the main actor to place in a level. It inherits from ACAbstractSpawner and implements ICHexaData. It reads its configuration from a DataTable row, instantiates the UCHexamaker instances and drives the generation loop on tick.
Properties
| Name |
Description |
| pawnToTrack |
Pawn whose position drives generation. If null, generates at origin then stops |
| hexaSpawnerRH |
FDataTableRowHandle pointing to a FCHexaSpawnerDataStruct row |
| hexamakerMap |
Map of instantiated UCHexamaker (index → hexamaker) |
| bannedArea |
Array of FCCircle defining exclusion zones |
Lifecycle
| Name |
Description |
| init |
Reads the DataTable row, distributes layers across CPU cores, instantiates hexamakers (normal + ghost) |
| Tick |
Calls UCHexamaker::buildASync with the pawn position. Stops if no pawn and generation is complete |
| clean |
Destroys all hexamakers and clears banned areas |
| storeSpawnerSingleton |
Registers the spawner as singleton CNAME_Singleton_HexaSpawner |
// ACHexaSpawner is placed in the level.
// Configure hexaSpawnerRH to point to a DataTable row of type FCHexaSpawnerDataStruct.
// Assign pawnToTrack to the player pawn.
// init() distributes layers across available CPU cores:
int cpuCoreNumber = FPlatformMisc::NumberOfCores() * 0.5; // leaves cores free for ParallelFor
// Each group of layers receives 2 hexamakers: one normal + one ghost (preview).
// On Tick, the spawner delegates to each hexamaker:
hexaMaker->buildASync(hexaMaker, pawnX, pawnY);
// If no pawn and generation is complete, tick is disabled.
ICHexaData interface
ACHexaSpawner implements ICHexaData, making hexagonal operations globally accessible via HexaUtility.
| Name |
Description |
| withBannedArea |
Accesses banned areas via callback. If refresh=true, forces a redraw of all hexamakers |
| removeTile |
Removes the tile at the given position in all hexamakers |
// Add a banned area (exclusion circle):
HexaUtility::withBannedArea([](TArray<FCCircle>* bannedArea) {
bannedArea->Add(FCCircle(FVector2D(1000, 2000), 500)); // center + radius
}, true); // refresh = true → forces redraw
// Remove a tile at a world position:
HexaUtility::removeTile(FVector2D(1000, 2000));