Add CogInterfaces plugin to fix interface usage when compiling shipping builds

This commit is contained in:
Arnaud Jamin
2023-10-02 17:27:19 -04:00
parent 82eb2d77e7
commit 81540a77f0
30 changed files with 247 additions and 81 deletions
+4
View File
@@ -26,6 +26,10 @@
"Name": "CogImgui",
"Enabled": true
},
{
"Name": "CogInterfaces",
"Enabled": true
},
{
"Name": "CogDebug",
"Enabled": true
@@ -23,6 +23,7 @@ public class CogAbility : ModuleRules
{
"Core",
"CogImgui",
"CogInterfaces",
"CogDebug",
"CogWindow",
"GameplayAbilities",
@@ -1,7 +1,7 @@
#include "CogAbilityWindow_Cheats.h"
#include "CogAbilityDataAsset_Cheats.h"
#include "CogDebugAllegianceInterface.h"
#include "CogInterfacesAllegiance.h"
#include "CogDebugDraw.h"
#include "CogImguiHelper.h"
#include "EngineUtils.h"
@@ -142,15 +142,15 @@ void UCogAbilityWindow_Cheats::RequestCheat(AActor* CheatInstigator, AActor* Sel
{
if (AActor* OtherActor = *It)
{
ECogAllegiance Allegiance = ECogAllegiance::Enemy;
ECogInterfacesAllegiance Allegiance = ECogInterfacesAllegiance::Enemy;
if (ICogAllegianceInterface* AllegianceInterface = Cast<ICogAllegianceInterface>(OtherActor))
if (ICogInterfacesAllegianceActor* AllegianceInterface = Cast<ICogInterfacesAllegianceActor>(OtherActor))
{
AllegianceInterface->GetAllegiance(CheatInstigator);
}
if ((IsShiftDown && (Allegiance == ECogAllegiance::Enemy))
|| (IsAltDown && (Allegiance == ECogAllegiance::Ally)))
if ((IsShiftDown && (Allegiance == ECogInterfacesAllegiance::Enemy))
|| (IsAltDown && (Allegiance == ECogInterfacesAllegiance::Ally)))
{
Actors.Add(OtherActor);
}
@@ -1,6 +1,6 @@
#include "CogAbilityWindow_Damages.h"
#include "CogAbilityDamageActorInterface.h"
#include "CogInterfacesDamageActor.h"
#include "CogImguiHelper.h"
#include "imgui.h"
@@ -149,6 +149,10 @@ static void DrawDamages(FCogDamageStats& Damage)
ImGui::EndTable();
}
ImGui::Text("Timer");
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
ImGui::Text("%0.2f", Damage.Timer);
ImGui::Text("Crits");
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
FCogWindowWidgets::ProgressBarCentered(Damage.Count == 0 ? 0.0f : Damage.Crits / (float)Damage.Count, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), Damage.Crits, Damage.Count)));
@@ -173,11 +177,6 @@ static void DrawDamages(FCogDamageStats& Damage)
ImGui::Spacing();
}
//--------------------------------------------------------------------------------------------------------------------------
UCogAbilityWindow_Damages::UCogAbilityWindow_Damages()
{
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Damages::RenderContent()
{
@@ -237,39 +236,36 @@ void UCogAbilityWindow_Damages::RenderContent()
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Damages::OnSelectionChanged(AActor* OldSelection, AActor* NewSelection)
{
if (ICogAbilityDamageActorInterface* DamageActor = Cast<ICogAbilityDamageActorInterface>(OldSelection))
if (ICogInterfacesDamageActor* DamageActor = Cast<ICogInterfacesDamageActor>(OldSelection))
{
DamageActor->OnDamageEvent().Remove(OnDamageEventDelegate);
}
if (ICogAbilityDamageActorInterface* DamageActor = Cast<ICogAbilityDamageActorInterface>(NewSelection))
if (ICogInterfacesDamageActor* DamageActor = Cast<ICogInterfacesDamageActor>(NewSelection))
{
OnDamageEventDelegate = DamageActor->OnDamageEvent().AddUObject(this, &UCogAbilityWindow_Damages::OnDamageEvent);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Damages::RenderTick(float DeltaSeconds)
void UCogAbilityWindow_Damages::GameTick(float DeltaSeconds)
{
Super::RenderTick(DeltaSeconds);
Super::GameTick(DeltaSeconds);
DamageReceivedStats.Tick(DeltaSeconds);
DamageDealtStats.Tick(DeltaSeconds);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Damages::OnDamageEvent(const FCogAbilityDamageParams& Params)
void UCogAbilityWindow_Damages::OnDamageEvent(const FCogInterfacesDamageParams& Params)
{
DamageDealtStats.Restart();
DamageReceivedStats.Restart();
AActor* Selection = GetSelection();
if (Selection == Params.DamageDealer.Get())
if (Params.Type == ECogInterfacesDamageEventType::DamageDealt)
{
DamageDealtStats.AddDamage(Params.ReceivedDamage, Params.IncomingDamage, Params.IsCritical);
DamageDealtStats.AddDamage(Params.MitigatedDamage, Params.IncomingDamage, Params.IsCritical);
}
else if (Selection == Params.DamageReceiver.Get())
else if (Params.Type == ECogInterfacesDamageEventType::DamageReceived)
{
DamageReceivedStats.AddDamage(Params.ReceivedDamage, Params.IncomingDamage, Params.IsCritical);
DamageReceivedStats.AddDamage(Params.MitigatedDamage, Params.IncomingDamage, Params.IsCritical);
}
}
@@ -4,7 +4,7 @@
#include "CogWindow.h"
#include "CogAbilityWindow_Damages.generated.h"
struct FCogAbilityDamageParams;
struct FCogInterfacesDamageParams;
//--------------------------------------------------------------------------------------------------------------------------
class FCogDamageInstance
@@ -52,17 +52,19 @@ class COGABILITY_API UCogAbilityWindow_Damages : public UCogWindow
GENERATED_BODY()
public:
UCogAbilityWindow_Damages();
virtual void RenderContent() override;
virtual void RenderTick(float DeltaSeconds) override;
protected:
virtual void RenderContent() override;
virtual void GameTick(float DeltaSeconds) override;
virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) override;
private:
UFUNCTION()
void OnDamageEvent(const FCogAbilityDamageParams& Params);
void OnDamageEvent(const FCogInterfacesDamageParams& Params);
FCogDamageStats DamageDealtStats;
FCogDamageStats DamageReceivedStats;
+4
View File
@@ -30,6 +30,10 @@
{
"Name": "CogImgui",
"Enabled": true
},
{
"Name": "CogInterfaces",
"Enabled": true
}
]
}
@@ -22,8 +22,9 @@ public class CogDebug : ModuleRules
new string[]
{
"Core",
"CogImgui"
}
"CogImgui",
"CogInterfaces",
}
);
@@ -12,10 +12,37 @@ DEFINE_LOG_CATEGORY(LogCogServerDebug);
TMap<FName, FCogDebugLogCategoryInfo> FCogDebugLogCategoryManager::LogCategories;
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::AddLogCategory(FLogCategoryBase& LogCategory)
// FCogDebugLogCategoryInfo
//--------------------------------------------------------------------------------------------------------------------------
FString FCogDebugLogCategoryInfo::GetDisplayName() const
{
LogCategories.Add(LogCategory.GetCategoryName(), FCogDebugLogCategoryInfo{ &LogCategory, ELogVerbosity::NumVerbosity });
if (DisplayName.IsEmpty() == false)
{
return DisplayName;
}
if (LogCategory != nullptr)
{
return LogCategory->GetCategoryName().ToString();
}
return FString("Invalid");
}
//--------------------------------------------------------------------------------------------------------------------------
// FCogDebugLogCategoryManager
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugLogCategoryManager::AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName)
{
LogCategories.Add(LogCategory.GetCategoryName(),
FCogDebugLogCategoryInfo
{
&LogCategory,
ELogVerbosity::NumVerbosity,
DisplayName,
});
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -1,8 +1,8 @@
#include "CogDebugPlot.h"
#include "CogDebugFilteredActorInterface.h"
#include "CogDebugDraw.h"
#include "CogDebugHelper.h"
#include "CogInterfacesFilteredActor.h"
#include "CogImguiHelper.h"
FCogDebugPlotEvent FCogDebugPlot::DefaultEvent;
@@ -427,7 +427,7 @@ FCogDebugPlotEntry* FCogDebugPlot::RegisterPlot(const UObject* WorldContextObjec
//---------------------------------------------------------------------------------
// Cast to ICogActorFilteringDebugInterface to know if we should filter
//---------------------------------------------------------------------------------
if (Cast<ICogDebugFilteredActorInterface>(WorldContextObject))
if (Cast<ICogInterfacesFilteredActor>(WorldContextObject))
{
if (WorldContextObject != FCogDebugSettings::GetSelection())
{
@@ -1,5 +1,7 @@
#include "CogDebugSettings.h"
#include "CogInterfacesFilteredActor.h"
//--------------------------------------------------------------------------------------------------------------------------
TWeakObjectPtr<AActor> FCogDebugSettings::Selection;
bool FCogDebugSettings::FilterBySelection = true;
@@ -72,7 +74,7 @@ bool FCogDebugSettings::IsDebugActiveForActor(const AActor* Actor)
return true;
}
if (Cast<ICogDebugFilteredActorInterface>(Actor))
if (Cast<ICogInterfacesFilteredActor>(Actor))
{
return (SelectionPtr == Actor || FilterBySelection == false);
}
@@ -13,12 +13,15 @@ struct COGDEBUG_API FCogDebugLogCategoryInfo
{
FLogCategoryBase* LogCategory = nullptr;
ELogVerbosity::Type ServerVerbosity = ELogVerbosity::NoLogging;
FString DisplayName;
FString GetDisplayName() const;
};
//--------------------------------------------------------------------------------------------------------------------------
struct COGDEBUG_API FCogDebugLogCategoryManager
{
static void AddLogCategory(FLogCategoryBase& LogCategory);
static void AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName = "");
static bool IsVerbosityActive(ELogVerbosity::Type Verbosity);
@@ -71,7 +71,7 @@ void UCogEngineWindow_LogCategories::RenderContent()
FLogCategoryBase* Category = CategoryInfo.LogCategory;
ImGui::PushID(Index);
FString CategoryFriendlyName = Category->GetCategoryName().ToString();
FString CategoryFriendlyName = CategoryInfo.GetDisplayName();
if (bShowAllVerbosity == false)
{
@@ -46,8 +46,7 @@ void UCogEngineWindow_Stats::RenderContent()
//--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Stats::DrawMainMenuWidget(bool Draw, float& Width)
{
const float ResetButtonWidth = FCogWindowWidgets::TextBaseWidth * 5;
Width = FCogWindowWidgets::TextBaseWidth * 15;
Width = FCogWindowWidgets::TextBaseWidth * 25;
if (Draw == false)
{
@@ -56,6 +55,7 @@ void UCogEngineWindow_Stats::DrawMainMenuWidget(bool Draw, float& Width)
extern ENGINE_API float GAverageFPS;
ImGui::TextColored(GetFpsColor(GAverageFPS), "%3dfps ", (int32)GAverageFPS);
ImGui::SetItemTooltip("Frame Per Second");
if (const APlayerController* PlayerController = GetLocalPlayerController())
{
@@ -64,6 +64,7 @@ void UCogEngineWindow_Stats::DrawMainMenuWidget(bool Draw, float& Width)
const float Ping = PlayerState->GetPingInMilliseconds();
ImGui::SameLine();
ImGui::TextColored(GetPingColor(Ping), "%3dms ", (int32)Ping);
ImGui::SetItemTooltip("Ping");
}
if (UNetConnection* Connection = PlayerController->GetNetConnection())
@@ -73,6 +74,7 @@ void UCogEngineWindow_Stats::DrawMainMenuWidget(bool Draw, float& Width)
const float TotalPacketLost = OutPacketLost + InPacketLost;
ImGui::SameLine();
ImGui::TextColored(GetPacketLossColor(TotalPacketLost), "%2d%% ", (int32)TotalPacketLost);
ImGui::SetItemTooltip("Packet Loss");
}
}
}
@@ -0,0 +1,26 @@
{
"FileVersion": 1,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "CogInterfaces",
"Description": "",
"Category": "Other",
"CreatedBy": "Arnaud Jamin",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "CogInterfaces",
"Type": "Runtime",
"LoadingPhase": "Default"
}
],
"Plugins": [
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@@ -0,0 +1,44 @@
using UnrealBuildTool;
public class CogInterfaces : ModuleRules
{
public CogInterfaces(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
}
);
PrivateIncludePaths.AddRange(
new string[] {
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
}
);
}
}
@@ -0,0 +1,17 @@
#include "CogInterfacesModule.h"
#define LOCTEXT_NAMESPACE "FCogInterfacesModule"
//--------------------------------------------------------------------------------------------------------------------------
void FCogInterfacesModule::StartupModule()
{
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogInterfacesModule::ShutdownModule()
{
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FCogInterfacesModule, CogInterfaces)
@@ -1,11 +1,11 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugAllegianceInterface.generated.h"
#include "CogInterfacesAllegiance.generated.h"
//--------------------------------------------------------------------------------------------------------------------------
UENUM(BlueprintType)
enum class ECogAllegiance : uint8
enum class ECogInterfacesAllegiance : uint8
{
Ally,
Enemy
@@ -13,17 +13,17 @@ enum class ECogAllegiance : uint8
//--------------------------------------------------------------------------------------------------------------------------
UINTERFACE(MinimalAPI, Blueprintable)
class UCogAllegianceInterface : public UInterface
class UCogInterfacesAllegianceActor : public UInterface
{
GENERATED_BODY()
};
//--------------------------------------------------------------------------------------------------------------------------
class ICogAllegianceInterface
class ICogInterfacesAllegianceActor
{
GENERATED_BODY()
public:
virtual ECogAllegiance GetAllegiance(const AActor* OtherActor) const = 0;
virtual ECogInterfacesAllegiance GetAllegiance(const AActor* OtherActor) const = 0;
};
@@ -1,33 +1,43 @@
#pragma once
#include "CoreMinimal.h"
#include "CogAbilityDamageActorInterface.generated.h"
#include "CogInterfacesDamageActor.generated.h"
//--------------------------------------------------------------------------------------------------------------------------
UENUM(BlueprintType)
enum class ECogInterfacesDamageEventType : uint8
{
DamageDealt,
DamageReceived,
};
//--------------------------------------------------------------------------------------------------------------------------
USTRUCT()
struct COGABILITY_API FCogAbilityDamageParams
struct FCogInterfacesDamageParams
{
GENERATED_BODY()
ECogInterfacesDamageEventType Type;
TObjectPtr<AActor> DamageDealer;
TObjectPtr<AActor> DamageReceiver;
float ReceivedDamage = 0;
float MitigatedDamage = 0;
float IncomingDamage = 0;
bool IsCritical = false;
};
//--------------------------------------------------------------------------------------------------------------------------
DECLARE_MULTICAST_DELEGATE_OneParam(FCogAbilityOnDamageEvent, const FCogAbilityDamageParams&);
DECLARE_MULTICAST_DELEGATE_OneParam(FCogAbilityOnDamageEvent, const FCogInterfacesDamageParams&);
//--------------------------------------------------------------------------------------------------------------------------
UINTERFACE(MinimalAPI, Blueprintable)
class UCogAbilityDamageActorInterface : public UInterface
class UCogInterfacesDamageActor : public UInterface
{
GENERATED_BODY()
};
//--------------------------------------------------------------------------------------------------------------------------
class ICogAbilityDamageActorInterface
class ICogInterfacesDamageActor
{
GENERATED_BODY()
@@ -1,15 +1,15 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugFilteredActorInterface.generated.h"
#include "CogInterfacesFilteredActor.generated.h"
UINTERFACE(MinimalAPI, Blueprintable)
class UCogDebugFilteredActorInterface : public UInterface
class UCogInterfacesFilteredActor : public UInterface
{
GENERATED_BODY()
};
class ICogDebugFilteredActorInterface
class ICogInterfacesFilteredActor
{
GENERATED_BODY()
@@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class COGINTERFACES_API FCogInterfacesModule : public IModuleInterface
{
public:
static inline FCogInterfacesModule& Get() { return FModuleManager::LoadModuleChecked<FCogInterfacesModule>("CogInterfaces"); }
virtual void StartupModule() override;
virtual void ShutdownModule() override;
private:
};