mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-06 07:38:46 +00:00
Add CogInterfaces plugin to fix interface usage when compiling shipping builds
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogAbilityDamageActorInterface.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct COGABILITY_API FCogAbilityDamageParams
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
TObjectPtr<AActor> DamageDealer;
|
||||
TObjectPtr<AActor> DamageReceiver;
|
||||
float ReceivedDamage = 0;
|
||||
float IncomingDamage = 0;
|
||||
bool IsCritical = false;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FCogAbilityOnDamageEvent, const FCogAbilityDamageParams&);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UINTERFACE(MinimalAPI, Blueprintable)
|
||||
class UCogAbilityDamageActorInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class ICogAbilityDamageActorInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual FCogAbilityOnDamageEvent& OnDamageEvent() = 0;
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user