AGKFogOfWarVolume#
Defined in File GKFogOfWarVolume.h
Inheritance Relationships#
Base Type#
public AVolume
Class Documentation#
-
class AGKFogOfWarVolume : public AVolume#
AGKFogOfWarVolume manages fog of war for multiple factions. All units inside the same faction share visions.
Note
The fog of war will darken your screen, it is advised to disable UE default auto exposure using a Post Process Volume and enabling
Exposure > Metering Mode > Auto Exposure Basic
as well as setting min and max brightness to 1Public Functions
-
AGKFogOfWarVolume()#
- void InitializeAuthority (UPARAM(ref) TArray< struct FGKFogTeamInfo > &Teams)
-
void InitializeAuthorityFromTeamInfoProvider(TScriptInterface<IGKFogOfWarGameStateInterface> GameState)#
-
void PreInitializeComponents() override#
-
void InitializeServer()#
-
void InitializeClient()#
-
inline void SetupActor(class UGKFogOfWarComponent *Component)#
-
void BeginPlay()#
-
void Tick(float DeltaTime)#
-
void EndPlay(const EEndPlayReason::Type EndPlayReason) override#
-
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty> &OutLifetimeProps) const override#
-
inline class UTexture *GetFactionTexture(FGenericTeamId TeamID)#
Returns the vision texture.
-
class UTexture *GetFactionTexture(FName name)#
-
inline class UTexture *GetOriginalFactionTexture(FGenericTeamId TeamID)#
Returns the vision texture before upscaling.
-
class UTexture *GetOriginalFactionTexture(FName name)#
-
inline class UTexture *GetFactionExplorationTexture(FGenericTeamId TeamID)#
Returns the exploration render target associated with the faction name.
-
class UTexture *GetFactionExplorationTexture(FName name)#
-
inline class UMaterialInstanceDynamic *GetFogOfWarPostprocessMaterial(TScriptInterface<IGenericTeamAgentInterface> Agent)#
Returns the post process material the actor should use for its camera.
-
class UMaterialInstanceDynamic *GetFogOfWarPostprocessMaterial(IGenericTeamAgentInterface *Agent)#
-
void SetSpecatorFogOfWarMaterialParameters(class UMaterialInstanceDynamic *Material)#
Add all the faction to the fog of war It will set 2 textures parameters for each factions (<team_name>_Vision, <team_name>_Exploration) and one scalar parameter <team_name>_Enabled you can use this to conditionnally render which faction is seen by the spectator
-
inline int SetCameraPostprocessMaterial(TScriptInterface<IGenericTeamAgentInterface> Agent, class UCameraComponent *CameraComponent)#
Add a post process material to the camera.
-
int SetCameraPostprocessMaterial(IGenericTeamAgentInterface *Agent, class UCameraComponent *CameraComponent)#
-
inline class UMaterialInstanceDynamic *GetFogOfWarMaterial(TScriptInterface<IGenericTeamAgentInterface> Agent, class UMaterialInterface *BaseMaterial)#
-
class UMaterialInstanceDynamic *GetFogOfWarMaterial(IGenericTeamAgentInterface *Agent, class UMaterialInterface *BaseMaterial)#
-
inline TArray<class UGKFogOfWarComponent*> const &GetBlocking() const#
Returns a list of all the blocking component.
-
inline EDrawDebugTrace::Type DebugTrace()#
-
void FinishedDrawingComponent(float Time)#
-
inline FVector GetMapSize() const#
-
void SetTextureSize(FVector2D Size)#
-
inline FVector2D GetTextureSize()#
-
inline FVector2D GetTextureCoordinate(FVector WorldCoordinate)#
Returns the texture coordinate given world coordinates.
-
inline FIntVector ToGridTexture(FIntVector Pos)#
-
inline FIntVector FromTextureToGrid(FIntVector Pos)#
-
inline int GetTeamCount() const#
-
inline bool IsVisible(FGenericTeamId SeerTeam, FVector Loc) const#
Returns true if the location is visible by the given team Note: on clients this can only work for the local team
-
inline bool IsVisible(AActor const *A, AActor const *B) const#
-
inline bool IsVisible(FGenericTeamId SeerTeam, AActor const *Target) const#
-
inline FVector GetVolumeOffset() const#
-
inline FVector GetWorldLocation(FVector Loc) const#
-
inline FVector GetVolumeLocation(FVector Loc) const#
-
inline FVector GetActorVolumeLocation(class AActor const *Actor) const#
-
FVector GetActorVolumeLocation(class UGKFogOfWarComponent const *Component) const#
-
inline bool HasCanHandleCosmetic() const#
-
FName GetTeamName(FGenericTeamId TeamID) const#
-
inline class AGKFogOfWarTeam *GetFogOfWarTeam(FGenericTeamId TeamId) const#
-
inline int K2_GetTeamCount()#
Makes TeamA allow TeamB to see its units.
Does TeamA share its vision with Team B ?
-
void OnTeamVisibilitySharingChanged()#
This is O(n * m) with n = units, m = Teams because we do not know what changed so we have to redo everything
-
void OnTeamVisibilitySharingChanged(FGenericTeamId TeamA, FGenericTeamId TeamB, bool bShareVision)#
This is O(n) where n = units of A alone much cheaper than the version without arguments
Public Members
-
float ClientLimitFramePerSeconds#
How often the fog gets drawn.
-
float ServerLimitFramePerSeconds#
-
float FramePerSeconds#
Represents how often the fog is updated when AsyncDraw is true.
-
bool bAsyncDraw#
Enable Async drawing.
-
class UGKFogOfWarStrategy *Strategy#
Actor Component that does the actual vision computation.
-
FVector Grid#
Specify the grid size, used to derivate the texture size we need to draw the fog; a grid size of 10x10 and a map size of 20000 will result in a texture size of 2000x2000 (20000/10)
-
class UGKTransformerStrategy *Upscaler#
Class used to perform the upscaling.
-
class UGKExplorationTransform *Exploration#
class used to generate the exploration
-
class UMaterialParameterCollection *FogMaterialParameters#
Parameter collection used to talk to shader/materials The volume sets the following parameters WithExploration FoWEnabled MapSize TextureSize
-
class UMaterialInterface *BasePostProcessMaterial#
Base Material used to draw the fog of war in a post process step, it uses the texture parameters FoWView & FoWExploration
-
bool bFogOfWarEnabled#
Allow you to disable all the functionality related to Fog of war without removing it This only pause the timer so the fog of war is not updated anymore It will also set a dynamic material parameter so material can disable the post processing
-
FGKFogStats Stats#
Holds performance stats.
-
FVector MapSize#
Size of the Volume box.
-
FGKFogOfWarReady OnReady#
-
bool bDebug#
Enable debug printing and drawing.
-
bool bCacheSimilarAllyVision#
If true, a TeamHash is computed which is used to know if a vision texture as already drawn or not. This is only relevant for servers
If A & B are allies and both share vision then their vision texture is the same and the TeamHash value will be the same.
This means that drawing of vision B will be skipped since A was drawn already. You can use
GetSimilarAlly()
to fetch the drawn texture.
-
bool bBroadcastSightingEvents#
If true sighting events will be sent to the fog of war component NOTE: that this does use some resources as it needs to keep track of who see who from frame to frame and comparing the result the algo is O(m * n) where m is the number of teams and n the number of units
One thing you can do to avoid this, is to call IsVisible(Team) inside the Tick and dispatch it there.
-
EGKVisionSharingSetting VisionSharingSetting#
Specify how the team agent interface and the fog of war work together
UseGenericTeamSolver: The fog of war use FGenericTeamId::GetAttitude to decide if team share visions Allies share vision, Enemies do not
UseFogOfwarTeamSolver: The fog of war overrides FGenericTeamId::GetAttitude Team that share visions are Friendly Team that do not are Hostile
UseBoth: FGenericTeamId::GetAttitude and Fog of War visions are entirely decoupled Team can be allies and share vison Team can be allies and not share vision Team can be enemies and share vision Team can be enemies and not share vision
Protected Functions
-
void DrawFactionFog()#
Draw the fog of war for each factions.
-
void DrawFactionFogParallel()#
-
void DrawFactionFogSingleThread()#
-
void DrawFactionFogParallel_AsyncTask()#
-
void UpdateTextures()#
-
void UpdateVisbility()#
-
void GetBrushSizes(FVector2D &TextureSize, FVector &MapSize)#
-
void UpdateVolumeSizes()#
Updates the Texture Size, given the size covered by the Fog of War volume.
-
class UMaterialParameterCollection *GetMaterialParameterCollection()#
Returns the material parameter collection used to configure the Fog of War.
-
void UpdateMaterialParamCollection()#
-
void InitializeStrategy()#
After that functions all the data necessary for drawing and replicating the fog of war is setup
-
void InitializeUpscaler()#
-
void InitializeExploration()#
-
void OnRep_TeamFogs()#
-
void UpdateTrackedMaterials(bool bForce = false)#
List of materials we allocated for post processing.
-
bool UpdateFogOfWarMaterialParameters(class AGKFogOfWarTeam *Team, class UMaterialInstanceDynamic *Material)#
Protected Attributes
-
TArray<class UGKFogOfWarComponent*> ActorComponents#
-
TArray<class AGKFogOfWarTeam*> TeamFogs#
-
TArray<class UGKFogOfWarComponent*> Blocking#
-
TMap<FName, class AGKFogOfWarTeam*> NameToFogs#
Dealing with Faction name instead of their teamid is easier for debugging.
-
bool bClientReady#
-
bool bReady#
-
TArray<FGKPendingFogMaterial> PendingMaterials#
-
TArray<FGTrackedFogMaterial> TrackedMaterials#
Friends
- friend class UGKFogOfWarStrategy
- friend class UGKShadowCasting
- friend class UGKRayCasting_Line
- friend class UGKRayCasting_Triangles
-
AGKFogOfWarVolume()#