mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
moved metric to CogDebug
This commit is contained in:
@@ -1,280 +0,0 @@
|
||||
#include "CogAbilityWindow_Metrics.h"
|
||||
|
||||
#include "CogInterfaceMetricActor.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "imgui.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogMetricInstance::Restart()
|
||||
{
|
||||
Last = 0.0f;
|
||||
Min = 0.0f;
|
||||
Max = 0.0f;
|
||||
PerSecond = 0.0f;
|
||||
PerFrame = 0.0f;
|
||||
Total = 0.0f;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogMetricInstance::AddMetric(const float Metric)
|
||||
{
|
||||
Last = Metric;
|
||||
Min = Min == 0.0f ? Metric : FMath::Min(Min, Metric);
|
||||
Max = FMath::Max(Max, Metric);
|
||||
PerFrame += Metric;
|
||||
Total += Metric;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogMetricInstance::UpdateMetricPerSecond(const float Duration)
|
||||
{
|
||||
PerSecond = Duration > 1.0f ? Total / Duration : Total;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogMetricInfo::Restart()
|
||||
{
|
||||
Count = 0;
|
||||
Crits = 0;
|
||||
TotalCritChances = 0.0f;
|
||||
|
||||
IsInProgress = false;
|
||||
Timer = 0.0f;
|
||||
RestartTimer = 0.0f;
|
||||
|
||||
Mitigated.Restart();
|
||||
Unmitigated.Restart();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogMetricInfo::AddEvent(const FCogInterfaceMetricEventParams& Params)
|
||||
{
|
||||
// If the max duration is reached, stop adding
|
||||
if (MaxDurationSetting != 0 && Timer >= MaxDurationSetting)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsInProgress = true;
|
||||
Count++;
|
||||
Crits += Params.IsCritical ? 1 : 0;
|
||||
|
||||
Mitigated.AddMetric(Params.MitigatedValue);
|
||||
Unmitigated.AddMetric(Params.UnmitigatedValue);
|
||||
Mitigated.UpdateMetricPerSecond(Timer);
|
||||
Unmitigated.UpdateMetricPerSecond(Timer);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogMetricInfo::Tick(const float DeltaSeconds)
|
||||
{
|
||||
if (IsInProgress)
|
||||
{
|
||||
// If the max duration is reached, stop increasing time.
|
||||
if (MaxDurationSetting <= 0 || Timer < MaxDurationSetting)
|
||||
{
|
||||
Timer += DeltaSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsInProgress = false;
|
||||
Timer = MaxDurationSetting;
|
||||
Mitigated.UpdateMetricPerSecond(Timer);
|
||||
Unmitigated.UpdateMetricPerSecond(Timer);
|
||||
}
|
||||
}
|
||||
|
||||
if (RestartDelaySetting > 0.0f)
|
||||
{
|
||||
if (Unmitigated.PerFrame == 0.0f)
|
||||
{
|
||||
RestartTimer += DeltaSeconds;
|
||||
if (RestartTimer > RestartDelaySetting)
|
||||
{
|
||||
Restart();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RestartTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
Mitigated.PerFrame = 0.0f;
|
||||
Unmitigated.PerFrame = 0.0f;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Metrics::DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(Title, false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(Color, "%.1f", MitigatedValue);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%.1f", UnmitigatedValue);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%.0f%%", UnmitigatedValue <= 0 ? 0.0 : 100.0f * (1.0f - (MitigatedValue / UnmitigatedValue)));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Metrics::DrawMetrics(FCogMetricInfo& Metric)
|
||||
{
|
||||
FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1.0f));
|
||||
|
||||
if (ImGui::BeginTable("MetricTable", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg))
|
||||
{
|
||||
ImGui::TableSetupColumn("");
|
||||
ImGui::TableSetupColumn("Mitigated");
|
||||
ImGui::TableSetupColumn("Unmitigated");
|
||||
ImGui::TableSetupColumn("Mitigation %");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
DrawMetricRow("Per Second", Metric.Mitigated.PerSecond, Metric.Unmitigated.PerSecond, ImVec4(1.0f, 1.0, 0.0f, 1.0f));
|
||||
DrawMetricRow("Total", Metric.Mitigated.Total, Metric.Unmitigated.Total, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
DrawMetricRow("Last", Metric.Mitigated.Last, Metric.Unmitigated.Last, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
DrawMetricRow("Min", Metric.Mitigated.Min, Metric.Unmitigated.Min, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
DrawMetricRow("Min", Metric.Mitigated.Max, Metric.Unmitigated.Max, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::Text("Crits");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
FCogWindowWidgets::ProgressBarCentered(Metric.Count == 0 ? 0.0f : Metric.Crits / (float)Metric.Count, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), Metric.Crits, Metric.Count)));
|
||||
|
||||
if (Metric.MaxDurationSetting > 0.0f)
|
||||
{
|
||||
ImGui::Text("Timer");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
FCogWindowWidgets::ProgressBarCentered(Metric.Timer / (float)Metric.MaxDurationSetting, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%0.1f / %0.1f"), Metric.Timer, Metric.MaxDurationSetting)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("Timer");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
ImGui::Text("%0.1f", Metric.Timer);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Restart"))
|
||||
{
|
||||
Metric.Restart();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Metrics::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
AActor* Selection = GetSelection();
|
||||
if (Selection == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int32 Index = 0;
|
||||
for (auto& Entry : Metrics)
|
||||
{
|
||||
FName MetricName = Entry.Key;
|
||||
FCogMetricInfo& Metric = Entry.Value;
|
||||
|
||||
if (ImGui::CollapsingHeader(TCHAR_TO_ANSI(*MetricName.ToString())))
|
||||
{
|
||||
ImGui::PushID(Index);
|
||||
DrawMetrics(Metric);
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
Index++;
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Settings"))
|
||||
{
|
||||
ImGui::PushItemWidth(-1);
|
||||
|
||||
bool Reset = false;
|
||||
|
||||
ImGui::Text("Auto Restart");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
bool AutoRestart = RestartDelaySetting > 0;
|
||||
if (ImGui::Checkbox("##Auto Restart", &AutoRestart))
|
||||
{
|
||||
RestartDelaySetting = AutoRestart ? 5.0f : 0.0f;
|
||||
Reset = true;
|
||||
}
|
||||
|
||||
if (AutoRestart)
|
||||
{
|
||||
ImGui::Text("Auto Restart Delay");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
if (ImGui::InputFloat("##Auto Restart Delay", &RestartDelaySetting))
|
||||
{
|
||||
Reset = true;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("Max Time");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
if (ImGui::InputFloat("##Max Time", &MaxDurationSetting, 0.0f, 0.0f, "%0.1f"))
|
||||
{
|
||||
Reset = true;
|
||||
}
|
||||
|
||||
if (Reset)
|
||||
{
|
||||
for (auto& Entry : Metrics)
|
||||
{
|
||||
FCogMetricInfo& Metric = Entry.Value;
|
||||
|
||||
Metric.MaxDurationSetting = MaxDurationSetting;
|
||||
Metric.RestartDelaySetting = RestartDelaySetting;
|
||||
Metric.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Metrics::OnSelectionChanged(AActor* OldSelection, AActor* NewSelection)
|
||||
{
|
||||
if (ICogInterfaceMetricActor* DamageActor = Cast<ICogInterfaceMetricActor>(OldSelection))
|
||||
{
|
||||
DamageActor->OnMetricEvent().Remove(OnMetricDelegate);
|
||||
}
|
||||
|
||||
if (ICogInterfaceMetricActor* DamageActor = Cast<ICogInterfaceMetricActor>(NewSelection))
|
||||
{
|
||||
OnMetricDelegate = DamageActor->OnMetricEvent().AddUObject(this, &UCogAbilityWindow_Metrics::OnEvent);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Metrics::GameTick(float DeltaSeconds)
|
||||
{
|
||||
Super::GameTick(DeltaSeconds);
|
||||
|
||||
for (auto& Entry : Metrics)
|
||||
{
|
||||
FCogMetricInfo& Metric = Entry.Value;
|
||||
Metric.Tick(DeltaSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Metrics::OnEvent(const FCogInterfaceMetricEventParams& Params)
|
||||
{
|
||||
FCogMetricInfo& MetricInfo = Metrics.FindOrAdd(Params.Name);
|
||||
|
||||
MetricInfo.AddEvent(Params);
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogAbilityWindow_Metrics.generated.h"
|
||||
|
||||
struct FCogInterfaceMetricEventParams;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class FCogMetricInstance
|
||||
{
|
||||
public:
|
||||
void Restart();
|
||||
|
||||
void AddMetric(const float Damage);
|
||||
|
||||
void UpdateMetricPerSecond(const float Duration);
|
||||
|
||||
float Last = 0.0f;
|
||||
|
||||
float Min = 0.0f;
|
||||
|
||||
float Max = 0.0f;
|
||||
|
||||
float PerFrame = 0.0f;
|
||||
|
||||
float PerSecond = 0.0f;
|
||||
|
||||
float Total = 0.0f;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class FCogMetricInfo
|
||||
{
|
||||
public:
|
||||
void AddEvent(const FCogInterfaceMetricEventParams& Params);
|
||||
|
||||
void Tick(const float DeltaSeconds);
|
||||
|
||||
void Restart();
|
||||
|
||||
FName Name;
|
||||
|
||||
int Count = 0;
|
||||
|
||||
int Crits = 0;
|
||||
|
||||
bool IsInProgress = false;
|
||||
|
||||
float TotalCritChances = 0.0f;
|
||||
|
||||
float Timer = 0.0f;
|
||||
|
||||
float RestartTimer = 0.0f;
|
||||
|
||||
FCogMetricInstance Mitigated;
|
||||
|
||||
FCogMetricInstance Unmitigated;
|
||||
|
||||
float MaxDurationSetting = 0.0f;
|
||||
|
||||
float RestartDelaySetting = 0.0f;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Config = Cog)
|
||||
class COGABILITY_API UCogAbilityWindow_Metrics : public UCogWindow
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void GameTick(float DeltaSeconds) override;
|
||||
|
||||
virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) override;
|
||||
|
||||
virtual void DrawMetrics(FCogMetricInfo& Metric);
|
||||
|
||||
virtual void DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color);
|
||||
|
||||
private:
|
||||
|
||||
UFUNCTION()
|
||||
void OnEvent(const FCogInterfaceMetricEventParams& Params);
|
||||
|
||||
UPROPERTY(Config)
|
||||
float MaxDurationSetting = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float RestartDelaySetting = 5.0f;
|
||||
|
||||
TMap<FName, FCogMetricInfo> Metrics;
|
||||
|
||||
FDelegateHandle OnMetricDelegate;
|
||||
};
|
||||
@@ -0,0 +1,163 @@
|
||||
#include "CogDebugMetric.h"
|
||||
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogInterfaceFilteredActor.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
float FCogDebugMetric::MaxDurationSetting = 0.0f;
|
||||
float FCogDebugMetric::RestartDelaySetting = 5.0f;
|
||||
bool FCogDebugMetric::IsVisible = false;
|
||||
TMap<FName, FCogDebugMetricEntry> FCogDebugMetric::Metrics;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// FCogDebugMetric
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetric::AddMetric(const FCogDebugMetricParams& Params)
|
||||
{
|
||||
if (Cast<ICogInterfacesFilteredActor>(Params.WorldContextObject))
|
||||
{
|
||||
if (Params.WorldContextObject != FCogDebugSettings::GetSelection())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FCogDebugMetricEntry& Entry = Metrics.FindOrAdd(Params.Name);
|
||||
Entry.Add(Params);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetric::AddMetric(const UObject* WorldContextObject, FName Name, float MitigatedValue, float UnmitigatedValue, bool IsCritical)
|
||||
{
|
||||
FCogDebugMetricParams Params;
|
||||
Params.WorldContextObject = WorldContextObject;
|
||||
Params.Name = Name;
|
||||
Params.MitigatedValue = MitigatedValue;
|
||||
Params.UnmitigatedValue = UnmitigatedValue;
|
||||
Params.IsCritical = IsCritical;
|
||||
AddMetric(Params);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetric::Tick(float DeltaSeconds)
|
||||
{
|
||||
for (auto& Entry : Metrics)
|
||||
{
|
||||
FCogDebugMetricEntry& Metric = Entry.Value;
|
||||
Metric.Tick(DeltaSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetric::Reset()
|
||||
{
|
||||
for (auto& Entry : Metrics)
|
||||
{
|
||||
FCogDebugMetricEntry& Metric = Entry.Value;
|
||||
Metric.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// FCogMetricInstance
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetricValue::Reset()
|
||||
{
|
||||
Last = 0.0f;
|
||||
Min = 0.0f;
|
||||
Max = 0.0f;
|
||||
PerSecond = 0.0f;
|
||||
PerFrame = 0.0f;
|
||||
Total = 0.0f;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetricValue::AddMetric(const float Metric)
|
||||
{
|
||||
Last = Metric;
|
||||
Min = Min == 0.0f ? Metric : FMath::Min(Min, Metric);
|
||||
Max = FMath::Max(Max, Metric);
|
||||
PerFrame += Metric;
|
||||
Total += Metric;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetricValue::UpdateMetricPerSecond(const float Duration)
|
||||
{
|
||||
PerSecond = Duration > 1.0f ? Total / Duration : Total;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetricEntry::Reset()
|
||||
{
|
||||
Count = 0;
|
||||
Crits = 0;
|
||||
TotalCritChances = 0.0f;
|
||||
|
||||
IsInProgress = false;
|
||||
Timer = 0.0f;
|
||||
RestartTimer = 0.0f;
|
||||
|
||||
Mitigated.Reset();
|
||||
Unmitigated.Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetricEntry::Add(const FCogDebugMetricParams& Params)
|
||||
{
|
||||
// If the max duration is reached, stop adding
|
||||
if (FCogDebugMetric::MaxDurationSetting != 0 && Timer >= FCogDebugMetric::MaxDurationSetting)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsInProgress = true;
|
||||
Count++;
|
||||
Crits += Params.IsCritical ? 1 : 0;
|
||||
|
||||
Mitigated.AddMetric(Params.MitigatedValue);
|
||||
Unmitigated.AddMetric(Params.UnmitigatedValue);
|
||||
Mitigated.UpdateMetricPerSecond(Timer);
|
||||
Unmitigated.UpdateMetricPerSecond(Timer);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugMetricEntry::Tick(const float DeltaSeconds)
|
||||
{
|
||||
if (IsInProgress)
|
||||
{
|
||||
// If the max duration is reached, stop increasing time.
|
||||
if (FCogDebugMetric::MaxDurationSetting <= 0 || Timer < FCogDebugMetric::MaxDurationSetting)
|
||||
{
|
||||
Timer += DeltaSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsInProgress = false;
|
||||
Timer = FCogDebugMetric::MaxDurationSetting;
|
||||
Mitigated.UpdateMetricPerSecond(Timer);
|
||||
Unmitigated.UpdateMetricPerSecond(Timer);
|
||||
}
|
||||
}
|
||||
|
||||
if (FCogDebugMetric::RestartDelaySetting > 0.0f)
|
||||
{
|
||||
if (Unmitigated.PerFrame == 0.0f)
|
||||
{
|
||||
RestartTimer += DeltaSeconds;
|
||||
if (RestartTimer > FCogDebugMetric::RestartDelaySetting)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RestartTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
Mitigated.PerFrame = 0.0f;
|
||||
Unmitigated.PerFrame = 0.0f;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugDefines.h"
|
||||
|
||||
#ifdef ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugMetricParams
|
||||
{
|
||||
TObjectPtr<const UObject> WorldContextObject = nullptr;
|
||||
|
||||
FName Name;
|
||||
|
||||
float MitigatedValue = 0;
|
||||
|
||||
float UnmitigatedValue = 0;
|
||||
|
||||
bool IsCritical = false;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugMetricValue
|
||||
{
|
||||
void Reset();
|
||||
|
||||
void AddMetric(const float Damage);
|
||||
|
||||
void UpdateMetricPerSecond(const float Duration);
|
||||
|
||||
float Last = 0.0f;
|
||||
|
||||
float Min = 0.0f;
|
||||
|
||||
float Max = 0.0f;
|
||||
|
||||
float PerFrame = 0.0f;
|
||||
|
||||
float PerSecond = 0.0f;
|
||||
|
||||
float Total = 0.0f;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct COGDEBUG_API FCogDebugMetricEntry
|
||||
{
|
||||
public:
|
||||
|
||||
void Add(const FCogDebugMetricParams& Params);
|
||||
|
||||
void Tick(const float DeltaSeconds);
|
||||
|
||||
void Reset();
|
||||
|
||||
int Count = 0;
|
||||
|
||||
int Crits = 0;
|
||||
|
||||
bool IsInProgress = false;
|
||||
|
||||
float TotalCritChances = 0.0f;
|
||||
|
||||
float Timer = 0.0f;
|
||||
|
||||
float RestartTimer = 0.0f;
|
||||
|
||||
FCogDebugMetricValue Mitigated;
|
||||
|
||||
FCogDebugMetricValue Unmitigated;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class COGDEBUG_API FCogDebugMetric
|
||||
{
|
||||
public:
|
||||
|
||||
static void Tick(float DeltaSeconds);
|
||||
|
||||
static void AddMetric(const FCogDebugMetricParams& Params);
|
||||
|
||||
static void AddMetric(const UObject* WorldContextObject, FName Name, float MitigatedValue, float UnmitigatedValue, bool IsCritical);
|
||||
|
||||
static void Reset();
|
||||
|
||||
static bool IsVisible;
|
||||
|
||||
static float MaxDurationSetting;
|
||||
|
||||
static float RestartDelaySetting;
|
||||
|
||||
static TMap<FName, FCogDebugMetricEntry> Metrics;
|
||||
};
|
||||
|
||||
#endif //ENABLE_COG
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
#include "CogEngineWindow_Metrics.h"
|
||||
|
||||
#include "CogDebugMetric.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "imgui.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Metrics::PostLoad()
|
||||
{
|
||||
FCogDebugMetric::MaxDurationSetting = MaxDurationSetting;
|
||||
FCogDebugMetric::RestartDelaySetting = RestartDelaySetting;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Metrics::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
WindowFlags = ImGuiWindowFlags_MenuBar;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Metrics::RenderTick(float DeltaTime)
|
||||
{
|
||||
Super::RenderTick(DeltaTime);
|
||||
FCogDebugMetric::IsVisible = GetIsVisible();
|
||||
|
||||
FCogDebugMetric::Tick(DeltaTime);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Metrics::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
bool bSettingModified = false;
|
||||
|
||||
FCogWindowWidgets::PushStyleCompact();
|
||||
if (ImGui::DragFloat("Auto Restart Delay", &RestartDelaySetting, 0.1f, 0.0f, FLT_MAX, "%0.1f"))
|
||||
{
|
||||
FCogDebugMetric::RestartDelaySetting = RestartDelaySetting;
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
|
||||
FCogWindowWidgets::PushStyleCompact();
|
||||
if (ImGui::DragFloat("Max Time", &MaxDurationSetting, 0.1f, 0.0f, FLT_MAX, "%0.1f"))
|
||||
{
|
||||
FCogDebugMetric::MaxDurationSetting = MaxDurationSetting;
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
if (FCogDebugMetric::Metrics.IsEmpty())
|
||||
{
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::Text("No metric received yet");
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
int32 Index = 0;
|
||||
for (auto& Entry : FCogDebugMetric::Metrics)
|
||||
{
|
||||
FName MetricName = Entry.Key;
|
||||
FCogDebugMetricEntry& Metric = Entry.Value;
|
||||
|
||||
if (ImGui::CollapsingHeader(TCHAR_TO_ANSI(*MetricName.ToString()), ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::PushID(Index);
|
||||
DrawMetric(Metric);
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric)
|
||||
{
|
||||
FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1.0f));
|
||||
|
||||
if (ImGui::BeginTable("MetricTable", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg))
|
||||
{
|
||||
ImGui::TableSetupColumn("");
|
||||
ImGui::TableSetupColumn("Mitigated");
|
||||
ImGui::TableSetupColumn("Unmitigated");
|
||||
ImGui::TableSetupColumn("Mitigation %");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
DrawMetricRow("Per Second", Metric.Mitigated.PerSecond, Metric.Unmitigated.PerSecond, ImVec4(1.0f, 1.0, 0.0f, 1.0f));
|
||||
DrawMetricRow("Total", Metric.Mitigated.Total, Metric.Unmitigated.Total, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
DrawMetricRow("Last", Metric.Mitigated.Last, Metric.Unmitigated.Last, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
DrawMetricRow("Min", Metric.Mitigated.Min, Metric.Unmitigated.Min, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
DrawMetricRow("Min", Metric.Mitigated.Max, Metric.Unmitigated.Max, ImVec4(1.0f, 1.0, 1.0f, 1.0f));
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::Text("Crits");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
FCogWindowWidgets::ProgressBarCentered(Metric.Count == 0 ? 0.0f : Metric.Crits / (float)Metric.Count, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), Metric.Crits, Metric.Count)));
|
||||
|
||||
if (FCogDebugMetric::MaxDurationSetting > 0.0f)
|
||||
{
|
||||
ImGui::Text("Timer");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
FCogWindowWidgets::ProgressBarCentered(Metric.Timer / (float)FCogDebugMetric::MaxDurationSetting, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%0.1f / %0.1f"), Metric.Timer, FCogDebugMetric::MaxDurationSetting)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("Timer");
|
||||
ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20);
|
||||
ImGui::Text("%0.1f", Metric.Timer);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
|
||||
if (ImGui::Button("Restart"))
|
||||
{
|
||||
Metric.Reset();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Metrics::DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(Title, false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(Color, "%.1f", MitigatedValue);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%.1f", UnmitigatedValue);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%.0f%%", UnmitigatedValue <= 0 ? 0.0 : 100.0f * (1.0f - (MitigatedValue / UnmitigatedValue)));
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
#include "CogEngineWindow_Spawn.h"
|
||||
#include "CogEngineWindow_Spawns.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawn::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
void UCogEngineWindow_Spawns::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
Super::PreRender(WindowFlags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawn::RenderContent()
|
||||
void UCogEngineWindow_Spawns::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
@@ -23,7 +23,7 @@ void UCogEngineWindow_Spawn::RenderContent()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawn::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup)
|
||||
void UCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup)
|
||||
{
|
||||
int32 GroupIndex = 0;
|
||||
|
||||
@@ -67,7 +67,7 @@ void UCogEngineWindow_Spawn::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool UCogEngineWindow_Spawn::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected)
|
||||
bool UCogEngineWindow_Spawns::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected)
|
||||
{
|
||||
bool IsPressed = false;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogEngineWindow_Metrics.generated.h"
|
||||
|
||||
struct FCogDebugMetricEntry;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Config = Cog)
|
||||
class COGENGINE_API UCogEngineWindow_Metrics : public UCogWindow
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void PostLoad() override;
|
||||
|
||||
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderTick(float DeltaTime) override;
|
||||
|
||||
virtual void DrawMetric(FCogDebugMetricEntry& Metric);
|
||||
|
||||
virtual void DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color);
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(Config)
|
||||
float MaxDurationSetting = 0.0f;
|
||||
|
||||
UPROPERTY(Config)
|
||||
float RestartDelaySetting = 5.0f;
|
||||
};
|
||||
+2
-2
@@ -2,13 +2,13 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogEngineWindow_Spawn.generated.h"
|
||||
#include "CogEngineWindow_Spawns.generated.h"
|
||||
|
||||
class UCogEngineDataAsset_Spawns;
|
||||
struct FCogEngineSpawnGroup;
|
||||
|
||||
UCLASS()
|
||||
class COGENGINE_API UCogEngineWindow_Spawn : public UCogWindow
|
||||
class COGENGINE_API UCogEngineWindow_Spawns : public UCogWindow
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@@ -12,6 +12,4 @@ class UCogInterfacesFilteredActor : public UInterface
|
||||
class ICogInterfacesFilteredActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
virtual bool IsActorFilteringDebug() const { return true; }
|
||||
};
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogInterfaceMetricActor.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct FCogInterfaceMetricEventParams
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FName Name;
|
||||
|
||||
float MitigatedValue = 0;
|
||||
|
||||
float UnmitigatedValue = 0;
|
||||
|
||||
bool IsCritical = false;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FCogInterfaceOnMetricEvent, const FCogInterfaceMetricEventParams&);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UINTERFACE(MinimalAPI, Blueprintable)
|
||||
class UCogInterfaceMetricActor : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class ICogInterfaceMetricActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual FCogInterfaceOnMetricEvent& OnMetricEvent() = 0;
|
||||
};
|
||||
@@ -77,9 +77,8 @@ void UCogWindow::DrawMenuItem(const FString& MenuItemName)
|
||||
{
|
||||
if (bShowInsideMenu && bIsVisible == false)
|
||||
{
|
||||
static const ImVec2 TEXT_BASE_SIZE = ImGui::CalcTextSize("A");
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(TEXT_BASE_SIZE.x * 40, TEXT_BASE_SIZE.y * 1),
|
||||
ImVec2(TEXT_BASE_SIZE.x * 50, TEXT_BASE_SIZE.y * 60));
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(FCogWindowWidgets::TextBaseWidth * 40, FCogWindowWidgets::TextBaseHeight * 1),
|
||||
ImVec2(FCogWindowWidgets::TextBaseWidth * 50, FCogWindowWidgets::TextBaseHeight * 60));
|
||||
|
||||
if (ImGui::BeginMenu(TCHAR_TO_ANSI(*MenuItemName)))
|
||||
{
|
||||
|
||||
@@ -108,10 +108,18 @@ void UCogWindowManager::Render(float DeltaTime)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::AddWindow(UCogWindow* Window)
|
||||
void UCogWindowManager::AddWindow(UCogWindow* Window, bool AddToMainMenu /*= true*/)
|
||||
{
|
||||
Window->SetOwner(this);
|
||||
Windows.Add(Window);
|
||||
|
||||
if (AddToMainMenu)
|
||||
{
|
||||
if (FMenu* Menu = AddMenu(Window->GetFullName()))
|
||||
{
|
||||
Menu->Window = Window;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -169,16 +177,21 @@ void UCogWindowManager::SaveLayout(int LayoutIndex)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindowManager::RebuildMenu()
|
||||
void UCogWindowManager::SortMainMenu()
|
||||
{
|
||||
MainMenu.SubMenus.Empty();
|
||||
|
||||
for (UCogWindow* Window : Windows)
|
||||
{
|
||||
check(Window);
|
||||
Windows.Sort();
|
||||
|
||||
FMenu* NewMenu = AddMenu(Window->GetFullName());
|
||||
NewMenu->Window = Window;
|
||||
TArray<UCogWindow*> SortedWindows = Windows;
|
||||
SortedWindows.Sort([](UCogWindow& Lhs, UCogWindow& Rhs) { return Lhs.GetFullName() < Rhs.GetFullName(); });
|
||||
|
||||
for (UCogWindow* Window : SortedWindows)
|
||||
{
|
||||
if (FMenu* Menu = AddMenu(Window->GetFullName()))
|
||||
{
|
||||
Menu->Window = Window;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,23 +23,23 @@ public:
|
||||
|
||||
void Shutdown();
|
||||
|
||||
void RebuildMenu();
|
||||
void SortMainMenu();
|
||||
|
||||
void Render(float DeltaTime);
|
||||
|
||||
void Tick(float DeltaTime);
|
||||
|
||||
template<class T>
|
||||
T* CreateWindow(const FString& Name)
|
||||
T* CreateWindow(const FString& Name, bool AddToMainMenu = true)
|
||||
{
|
||||
T* Window = NewObject<T>(this);
|
||||
Window->SetFullName(Name);
|
||||
Window->Initialize();
|
||||
AddWindow(Window);
|
||||
AddWindow(Window, AddToMainMenu);
|
||||
return Window;
|
||||
}
|
||||
|
||||
void AddWindow(UCogWindow* Window);
|
||||
void AddWindow(UCogWindow* Window, bool AddToMainMenu = true);
|
||||
|
||||
void AddMainMenuWidget(UCogWindow* Window);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "CogDebugLogMacros.h"
|
||||
#include "CogDebugMetric.h"
|
||||
#include "CogSampleAttributeSet_Health.h"
|
||||
#include "CogSampleAttributeSet_Misc.h"
|
||||
#include "CogSampleCharacterMovementComponent.h"
|
||||
@@ -345,26 +346,18 @@ void ACogSampleCharacter::Look(const FInputActionValue& Value)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleCharacter::OnDamageReceived(float ReceivedDamage, float IncomingDamage, AActor* DamageDealer, const FGameplayEffectSpec& EffectSpec)
|
||||
void ACogSampleCharacter::OnDamageReceived(float MitigatedDamage, float UnmitigatedDamage, AActor* DamageDealer, const FGameplayEffectSpec& EffectSpec)
|
||||
{
|
||||
#if USE_COG
|
||||
FCogInterfaceMetricEventParams Params;
|
||||
Params.Name = "Damage Received";
|
||||
Params.MitigatedValue = ReceivedDamage;
|
||||
Params.UnmitigatedValue = IncomingDamage;
|
||||
OnMetricEventDelegate.Broadcast(Params);
|
||||
FCogDebugMetric::AddMetric(this, "Damage Received", MitigatedDamage, UnmitigatedDamage, false);
|
||||
#endif //USE_COG
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleCharacter::OnDamageDealt(float ReceivedDamage, float IncomingDamage, AActor* DamageReceiver, const FGameplayEffectSpec& EffectSpec)
|
||||
void ACogSampleCharacter::OnDamageDealt(float MitigatedDamage, float UnmitigatedDamage, AActor* DamageReceiver, const FGameplayEffectSpec& EffectSpec)
|
||||
{
|
||||
#if USE_COG
|
||||
FCogInterfaceMetricEventParams Params;
|
||||
Params.Name = "Damage Dealt";
|
||||
Params.MitigatedValue = ReceivedDamage;
|
||||
Params.UnmitigatedValue = IncomingDamage;
|
||||
OnMetricEventDelegate.Broadcast(Params);
|
||||
FCogDebugMetric::AddMetric(this, "Damage Dealt", MitigatedDamage, UnmitigatedDamage, false);
|
||||
#endif //USE_COG
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "ActiveGameplayEffectHandle.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "CogDefines.h"
|
||||
#include "CogInterfaceMetricActor.h"
|
||||
#include "CogInterfaceFilteredActor.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameplayAbilitySpecHandle.h"
|
||||
@@ -59,7 +58,6 @@ UCLASS(config=Game)
|
||||
class ACogSampleCharacter : public ACharacter
|
||||
, public IAbilitySystemInterface
|
||||
, public ICogInterfacesFilteredActor
|
||||
, public ICogInterfaceMetricActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@@ -70,14 +68,22 @@ public:
|
||||
// ACharacter overrides
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
virtual void BeginPlay();
|
||||
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason);
|
||||
|
||||
virtual void MarkComponentsAsPendingKill() override;
|
||||
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
virtual void PossessedBy(AController* NewController) override;
|
||||
|
||||
virtual FCogInterfaceOnMetricEvent& OnMetricEvent() override { return OnMetricEventDelegate; }
|
||||
virtual bool IsActorFilteringDebug() const override { return true; }
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// IAbilitySystemInterface overrides
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
UFUNCTION(BlueprintPure)
|
||||
UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void OnAcknowledgePossession(APlayerController* InController);
|
||||
|
||||
void OnDamageReceived(float DamageAmount, float UnmitigatedDamageAmount, AActor* DamageDealer, const FGameplayEffectSpec& EffectSpec);
|
||||
@@ -92,9 +98,8 @@ public:
|
||||
|
||||
UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// Camera
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
/** Camera boom positioning the camera behind the character */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
|
||||
@@ -104,6 +109,9 @@ public:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
|
||||
UCameraComponent* FollowCamera;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// Input
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
/** MappingContext */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
UInputMappingContext* DefaultMappingContext;
|
||||
@@ -131,6 +139,9 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
TArray<UInputAction*> ItemActions;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// Ability
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
UPROPERTY(BlueprintReadOnly, Category = Ability, meta = (AllowPrivateAccess = "true"))
|
||||
UAbilitySystemComponent* AbilitySystem = nullptr;
|
||||
|
||||
@@ -146,31 +157,45 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Ability)
|
||||
TArray<TSubclassOf<UGameplayEffect>> Effects;
|
||||
|
||||
FCogInterfaceOnMetricEvent OnMetricEventDelegate;
|
||||
|
||||
private:
|
||||
|
||||
void InitializeAbilitySystem();
|
||||
|
||||
void ShutdownAbilitySystem();
|
||||
|
||||
void Move(const FInputActionValue& Value);
|
||||
|
||||
void MoveZ(const FInputActionValue& Value);
|
||||
|
||||
void Look(const FInputActionValue& Value);
|
||||
|
||||
void OnAbilityInputStarted(const FInputActionValue& Value, int32 Index);
|
||||
|
||||
void OnAbilityInputCompleted(const FInputActionValue& Value, int32 Index);
|
||||
|
||||
void ActivateItem(const FInputActionValue& Value, int32 Index);
|
||||
|
||||
void OnGameplayEffectAdded(UAbilitySystemComponent* AbilitySystemComponent, const FGameplayEffectSpec& GameplayEffectSpec, FActiveGameplayEffectHandle Handle);
|
||||
|
||||
void OnGameplayEffectRemoved(const FActiveGameplayEffect& RemovedGameplayEffect);
|
||||
|
||||
void OnGhostTagNewOrRemoved(const FGameplayTag InTag, int32 NewCount);
|
||||
|
||||
void OnScaleAttributeChanged(const FOnAttributeChangeData& Data);
|
||||
|
||||
UPROPERTY(Replicated, Transient)
|
||||
TArray<FGameplayAbilitySpecHandle> ActiveAbilityHandles;
|
||||
|
||||
FDelegateHandle GameplayEffectAddedHandle;
|
||||
|
||||
FDelegateHandle GameplayEffectRemovedHandle;
|
||||
|
||||
FDelegateHandle GhostTagDelegateHandle;
|
||||
|
||||
FDelegateHandle ScaleAttributeDelegateHandle;
|
||||
|
||||
bool bIsGhost = false;
|
||||
|
||||
bool bIsInitialized = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "CogAbilityWindow_Attributes.h"
|
||||
#include "CogAbilityWindow_Cheats.h"
|
||||
#include "CogAbilityWindow_Effects.h"
|
||||
#include "CogAbilityWindow_Metrics.h"
|
||||
#include "CogAbilityWindow_Pools.h"
|
||||
#include "CogAbilityWindow_Tags.h"
|
||||
#include "CogAbilityWindow_Tweaks.h"
|
||||
@@ -33,11 +32,12 @@
|
||||
#include "CogEngineWindow_LogCategories.h"
|
||||
#include "CogEngineWindow_NetEmulation.h"
|
||||
#include "CogEngineWindow_OutputLog.h"
|
||||
#include "CogEngineWindow_Metrics.h"
|
||||
#include "CogEngineWindow_Plots.h"
|
||||
#include "CogEngineWindow_Scalability.h"
|
||||
#include "CogEngineWindow_Selection.h"
|
||||
#include "CogEngineWindow_Skeleton.h"
|
||||
#include "CogEngineWindow_Spawn.h"
|
||||
#include "CogEngineWindow_Spawns.h"
|
||||
#include "CogEngineWindow_Stats.h"
|
||||
#include "CogEngineWindow_Time.h"
|
||||
#include "CogImguiModule.h"
|
||||
@@ -160,29 +160,22 @@ void ACogSampleGameState::InitializeCog()
|
||||
|
||||
CogWindowManager->CreateWindow<UCogEngineWindow_Plots>("Engine.Plots");
|
||||
|
||||
UCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow<UCogEngineWindow_Selection>("Engine.Selection");
|
||||
SelectionWindow->SetActorSubClasses({ AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass(), ACharacter::StaticClass() });
|
||||
SelectionWindow->SetCurrentActorSubClass(ACharacter::StaticClass());
|
||||
SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Pawn));
|
||||
|
||||
CogWindowManager->CreateWindow<UCogEngineWindow_Scalability>("Engine.Scalability");
|
||||
|
||||
CogWindowManager->CreateWindow<UCogEngineWindow_Skeleton>("Engine.Skeleton");
|
||||
|
||||
UCogEngineWindow_Spawn* SpawnWindow =CogWindowManager->CreateWindow<UCogEngineWindow_Spawn>("Engine.Spawn");
|
||||
UCogEngineWindow_Spawns* SpawnWindow =CogWindowManager->CreateWindow<UCogEngineWindow_Spawns>("Engine.Spawns");
|
||||
SpawnWindow->SetSpawnsAsset(GetFirstAssetByClass<UCogEngineDataAsset_Spawns>());
|
||||
|
||||
CogWindowManager->CreateWindow<UCogEngineWindow_Time>("Engine.Time");
|
||||
|
||||
UCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow<UCogEngineWindow_Selection>("Engine.Selection");
|
||||
TArray<TSubclassOf<AActor>> SubClasses
|
||||
{
|
||||
AActor::StaticClass(),
|
||||
AGameModeBase::StaticClass(),
|
||||
AGameStateBase::StaticClass(),
|
||||
ACharacter::StaticClass()
|
||||
};
|
||||
SelectionWindow->SetActorSubClasses(SubClasses);
|
||||
SelectionWindow->SetCurrentActorSubClass(ACharacter::StaticClass());
|
||||
SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Pawn));
|
||||
|
||||
UCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow<UCogEngineWindow_Stats>("Engine.Stats");
|
||||
|
||||
CogWindowManager->CreateWindow<UCogEngineWindow_Time>("Engine.Time");
|
||||
|
||||
//---------------------------------------
|
||||
// Abilities
|
||||
//---------------------------------------
|
||||
@@ -194,7 +187,7 @@ void ACogSampleGameState::InitializeCog()
|
||||
UCogAbilityWindow_Cheats* CheatsWindow = CogWindowManager->CreateWindow<UCogAbilityWindow_Cheats>("Gameplay.Cheats");
|
||||
CheatsWindow->CheatsAsset = GetFirstAssetByClass<UCogAbilityDataAsset_Cheats>();
|
||||
|
||||
CogWindowManager->CreateWindow<UCogAbilityWindow_Metrics>("Gameplay.Metrics");
|
||||
CogWindowManager->CreateWindow<UCogEngineWindow_Metrics>("Gameplay.Metrics");
|
||||
|
||||
UCogAbilityWindow_Effects* EffectsWindow = CogWindowManager->CreateWindow<UCogAbilityWindow_Effects>("Gameplay.Effects");
|
||||
EffectsWindow->NegativeEffectTag = Tag_Effect_Alignment_Negative;
|
||||
@@ -222,18 +215,11 @@ void ACogSampleGameState::InitializeCog()
|
||||
//---------------------------------------
|
||||
CogWindowManager->AddMainMenuWidget(SelectionWindow);
|
||||
CogWindowManager->AddMainMenuWidget(StatsWindow);
|
||||
|
||||
CogWindowManager->RebuildMenu();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogSampleGameState::RenderCog(float DeltaTime)
|
||||
{
|
||||
static bool ShowImGuiDemo = false;
|
||||
if (ShowImGuiDemo)
|
||||
{
|
||||
ImGui::ShowDemoWindow(&ShowImGuiDemo);
|
||||
}
|
||||
CogWindowManager->Render(DeltaTime);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user