CFOWSpawner

Overview

ACFOWSpawner is the main actor to place in a level for fog of war. It inherits from ACAbstractSpawner and implements ICFOWData. It reads its configuration from a DataTable row, finds the level’s APostProcessVolume, instantiates UCFOWMaker and drives the fog loop on tick.

Properties

Name Description
pawnToTrack Pawn whose location drives fog computation. If null, generates at origin then stops
fowMakerRH FDataTableRowHandle pointing to a FCFOWMakerStruct row
fowMaker Transient reference to the instantiated UCFOWMaker
postProcessVolume Transient reference to the first APostProcessVolume found in the level

Lifecycle

Name Description
init Finds the PostProcessVolume, reads the DataTable row, instantiates UCFOWMaker
Tick Calls fowMaker->buildASync with the tracked pawn position. Stops ticking if no pawn and fog is built
clean Destroys the fog maker and its resources
storeSpawnerSingleton Registers the spawner as CNAME_Singleton_FOWSpawner
// ACFOWSpawner is placed in the level.
// Configure fowMakerRH to point to a DataTable row of type FCFOWMakerStruct.
// Assign pawnToTrack to the player pawn.

// init() is called by the spawner system (ACAbstractSpawner).
// It retrieves the PostProcessVolume and instantiates UCFOWMaker:
UCFOWMaker::instanciate(GetRootComponent(), fowMaker, stream, *data, postProcessVolume);

// On Tick, the spawner delegates to the fog maker:
fowMaker->buildASync(this,
    pawnToTrack->GetActorLocation().X,
    pawnToTrack->GetActorLocation().Y);

// If no pawn is assigned, fog builds once at (0,0) then tick stops:
if (fowMaker->isBuilt()) {
    SetActorTickEnabled(false);
}

ICFOWData interface

ACFOWSpawner implements ICFOWData, providing fog data access to other systems.

Name Description
currentFOWData Returns the current cluster, view render target and revealed render target
setMinimapZDistance Forwards the minimap Z distance to the fog maker material
// Other systems can query fog data via the ICFOWData interface:
FCRectangle* cluster;
UTextureRenderTarget2D* rtView;
UTextureRenderTarget2D* rtRevealed;
if (fowSpawner->currentFOWData(cluster, rtView, rtRevealed)) {
    // cluster, rtView and rtRevealed are valid
}

// Set minimap distance parameter on the fog material:
fowSpawner->setMinimapZDistance(5000.0f);