Created
April 22, 2023 15:04
-
-
Save Delaunay/28c06034214ae68736173a05c80b78c5 to your computer and use it in GitHub Desktop.
GKFogOfWarPawn.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Source/GKFogOfWar/Public/GKFogOfWarPawn.h b/Source/GKFogOfWar/Public/GKFogOfWarPawn.h | |
index b7d940c..33eda34 100644 | |
--- a/Source/GKFogOfWar/Public/GKFogOfWarPawn.h | |
+++ b/Source/GKFogOfWar/Public/GKFogOfWarPawn.h | |
@@ -8,13 +8,16 @@ | |
// Unreal Engine | |
#include "CoreMinimal.h" | |
#include "GameFramework/Pawn.h" | |
+#include "Net/UnrealNetwork.h" | |
// Generated | |
#include "GKFogOfWarPawn.generated.h" | |
UCLASS() | |
-class GKFOGOFWAR_API AGKFogOfWarPawn : public APawn, public IGKFogOfWarAgentInterface | |
+class GKFOGOFWAR_API AGKFogOfWarPawn : public APawn, | |
+ public IGKFogOfWarAgentInterface, | |
+ public IGenericTeamAgentInterface | |
{ | |
GENERATED_BODY() | |
@@ -37,6 +40,51 @@ public: | |
return FoWComponent; | |
} | |
+ // >>>>>> Begin | |
+ void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override { | |
+ Super::GetLifetimeReplicatedProps(OutLifetimeProps); | |
+ DOREPLIFETIME(AGKFogOfWarPawn, Team); | |
+ } | |
+ | |
+ bool IsReplicationPausedForConnection(const FNetViewer& ConnectionOwnerNetViewer) override | |
+ { | |
+ TObjectPtr<AActor> ViewTarget = ConnectionOwnerNetViewer.ViewTarget; | |
+ | |
+ if (FoWComponent && ViewTarget) { | |
+ return !FoWComponent->IsVisibleBy(ViewTarget); | |
+ } | |
+ | |
+ return false; | |
+ } | |
+ | |
+ //! Retrieve team identifier in form of FGenericTeamId | |
+ UFUNCTION(BlueprintPure, Category = "Team") | |
+ FGenericTeamId GetGenericTeamId() const override { | |
+ return Team; | |
+ } | |
+ | |
+ //! This is set by the Player Controller on possession | |
+ UPROPERTY(Replicated, EditAnywhere, BlueprintReadOnly, Category = "Team") | |
+ FGenericTeamId Team; | |
+ | |
+ void OnReplicationPausedChanged(bool bIsReplicationPaused) override { | |
+ bool bIsVisible = !bIsReplicationPaused; | |
+ | |
+ if (bIsVisible) | |
+ { | |
+ SetActorHiddenInGame(false); | |
+ SetActorEnableCollision(true); | |
+ SetActorTickEnabled(true); | |
+ } | |
+ else | |
+ { | |
+ SetActorHiddenInGame(true); | |
+ SetActorEnableCollision(false); | |
+ SetActorTickEnabled(false); | |
+ } | |
+ } | |
+ | |
+ // <<<<< End | |
protected: | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FogOfWar") | |
class UGKFogOfWarComponent* FoWComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment