From abdfbfa52e8e92c41ec41ac00c7fc60d263bc79b Mon Sep 17 00:00:00 2001
From: David Gilbert <gilbert@vr.rwth-aachen.de>
Date: Fri, 6 Dec 2024 09:59:01 +0100
Subject: [PATCH] chore: Uses GetModifyCookDelegate to add the ndisplay configs
 to always cook. Removes not working config ini

---
 Config/DefaultRWTHVRClusterPlugin.ini         |  2 --
 .../RWTHVRCluster/Private/RWTHVRCluster.cpp   | 22 ++++++++++++++++++-
 Source/RWTHVRCluster/Public/RWTHVRCluster.h   |  3 +++
 3 files changed, 24 insertions(+), 3 deletions(-)
 delete mode 100644 Config/DefaultRWTHVRClusterPlugin.ini

diff --git a/Config/DefaultRWTHVRClusterPlugin.ini b/Config/DefaultRWTHVRClusterPlugin.ini
deleted file mode 100644
index 59efe63..0000000
--- a/Config/DefaultRWTHVRClusterPlugin.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[/Script/UnrealEd.ProjectPackagingSettings]
-+DirectoriesToAlwaysCook=(Path="/RWTHVRCluster")
\ No newline at end of file
diff --git a/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp b/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp
index 5632551..a43e1e3 100644
--- a/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp
+++ b/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp
@@ -1,11 +1,31 @@
 #include "RWTHVRCluster.h"
 
+
+#include "GameDelegates.h"
+#include "Logging/StructuredLog.h"
+
 #define LOCTEXT_NAMESPACE "FRWTHVRClusterModule"
 
-void FRWTHVRClusterModule::StartupModule() { ClusterConsole.Register(); }
+void FRWTHVRClusterModule::StartupModule()
+{
+	ClusterConsole.Register();
+
+	FGameDelegates::Get().GetModifyCookDelegate().AddRaw(this, &FRWTHVRClusterModule::GetPackagesToAlwaysCook);
+}
 
 void FRWTHVRClusterModule::ShutdownModule() { ClusterConsole.Unregister(); }
 
+void FRWTHVRClusterModule::GetPackagesToAlwaysCook(TConstArrayView<const ITargetPlatform*> InTargetPlatforms,
+												   TArray<FName>& InOutPackagesToCook,
+												   TArray<FName>& InOutPackagesToNeverCook)
+{
+	InOutPackagesToCook.Add("/RWTHVRCluster/Config/aixcave.aixcave");
+	InOutPackagesToCook.Add("/RWTHVRCluster/Config/aixcave_two_player.aixcave_two_player");
+
+	UE_LOGFMT(LogTemp, Display,
+			  "GetPackagesToAlwaysCook delegate called, adding aixcave configs to always cook list...");
+}
+
 #undef LOCTEXT_NAMESPACE
 
 IMPLEMENT_MODULE(FRWTHVRClusterModule, RWTHVRCluster)
diff --git a/Source/RWTHVRCluster/Public/RWTHVRCluster.h b/Source/RWTHVRCluster/Public/RWTHVRCluster.h
index 71a7693..2432355 100644
--- a/Source/RWTHVRCluster/Public/RWTHVRCluster.h
+++ b/Source/RWTHVRCluster/Public/RWTHVRCluster.h
@@ -10,6 +10,9 @@ public:
 	virtual void StartupModule() override;
 	virtual void ShutdownModule() override;
 
+	void GetPackagesToAlwaysCook(TConstArrayView<const ITargetPlatform*> InTargetPlatforms,
+								 TArray<FName>& InOutPackagesToCook, TArray<FName>& InOutPackagesToNeverCook);
+
 private:
 	FClusterConsole ClusterConsole;
 };
-- 
GitLab