diff --git a/Config/DefaultGameplayTags.ini b/Config/DefaultGameplayTags.ini index 5189dd3..61b5988 100644 --- a/Config/DefaultGameplayTags.ini +++ b/Config/DefaultGameplayTags.ini @@ -1,3 +1,4 @@ +;METADATA=(Diff=true, UseCommands=true) [/Script/GameplayTags.GameplayTagsSettings] ImportTagsFromConfig=True WarnOnInvalidTags=True @@ -5,9 +6,12 @@ ClearInvalidTags=False AllowEditorTagUnloading=True AllowGameTagUnloading=False FastReplication=False +bDynamicReplication=False InvalidTagCharacters="\"\'," NumBitsForContainerSize=6 NetIndexFirstBitSegment=16 ++GameplayTagList=(Tag="Effect.Type.Damage.Magical",DevComment="") ++GameplayTagList=(Tag="Effect.Type.Damage.Physical",DevComment="") +GameplayTagList=(Tag="GameplayCue.Ability.Hero1.Poison",DevComment="") +GameplayTagList=(Tag="GameplayCue.Ability.Hero1.PuhBack",DevComment="") +GameplayTagList=(Tag="GameplayCue.Ability.Hero1.Shield",DevComment="") diff --git a/Content/Characters/Hero1/Abilities/Shield/GE_Hero1_Shield.uasset b/Content/Characters/Hero1/Abilities/Shield/GE_Hero1_Shield.uasset index 4e94d6f..bbf878f 100644 Binary files a/Content/Characters/Hero1/Abilities/Shield/GE_Hero1_Shield.uasset and b/Content/Characters/Hero1/Abilities/Shield/GE_Hero1_Shield.uasset differ diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp index ccc5cc8..1cfe474 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp @@ -1,7 +1,6 @@ #include "CogDebugPlot.h" #include "CogDebug.h" -#include "CogDebugDraw.h" #include "CogDebugHelper.h" #include "CogImguiHelper.h" #include "Engine/Engine.h" @@ -13,6 +12,7 @@ bool FCogDebugPlot::IsVisible = false; bool FCogDebugPlot::Pause = false; FName FCogDebugPlot::LastAddedEventPlotName = NAME_None; int32 FCogDebugPlot::LastAddedEventIndex = INDEX_NONE; +TMap FCogDebugPlot::OccupiedRowMap; //-------------------------------------------------------------------------------------------------------------------------- // FCogPlotEvent @@ -131,10 +131,9 @@ FCogDebugPlotEvent& FCogDebugPlotEntry::AddEvent( Events.Reserve(200); } - //----------------------------------------------------------------------- - // We currently having two events with the same name at the same time. - // So we stop the current one if any exist. - //----------------------------------------------------------------------- + //---------------------------- + // Stop if any already exist. + //---------------------------- StopEvent(EventId); FCogDebugPlotEvent* Event = nullptr; @@ -159,7 +158,12 @@ FCogDebugPlotEvent& FCogDebugPlotEntry::AddEvent( Event->EndTime = IsInstant ? OwnwePlot.Time : 0.0f; Event->StartFrame = OwnwePlot.Frame; Event->EndFrame = IsInstant ? OwnwePlot.Frame : 0.0f; - Event->Row = (Row == FCogDebugPlot::AutoRow) ? OwnwePlot.FindFreeRow() : Row; + Event->Row = (Row == FCogDebugPlot::AutoRow) ? FCogDebugPlot::FindFreeEventRow() : Row; + + if (IsInstant == false) + { + FCogDebugPlot::OccupyRow(Event->Row); + } MaxRow = FMath::Max(Event->Row, MaxRow); @@ -187,6 +191,8 @@ FCogDebugPlotEvent& FCogDebugPlotEntry::StopEvent(const FName EventId) { Event->EndTime = Time; Event->EndFrame = Frame; + + FCogDebugPlot::FreeRow(Event->Row); } return *Event; @@ -239,54 +245,6 @@ FCogDebugPlotEvent* FCogDebugPlotEntry::FindLastEventByName(FName EventId) return nullptr; } -//-------------------------------------------------------------------------------------------------------------------------- -int32 FCogDebugPlotEntry::FindFreeRow() const -{ - static float InstantTimeThreshold = 1.0f; - static float TotalTimeThreshold = 10.0f; - TSet OccupiedRows; - - for (int32 i = Events.Num() - 1; i >= 0; --i) - { - int32 Index = i; - if (EventOffset != 0) - { - Index = (i + EventOffset) % Events.Num(); - } - const FCogDebugPlotEvent& Event = Events[Index]; - - if (Event.EndTime != 0.0f && Time > Event.EndTime + TotalTimeThreshold) - { - break; - } - - if (Event.StartTime == Event.EndTime && Time > Event.EndTime + InstantTimeThreshold) - { - continue; - } - - if (Event.EndTime != 0.0f) - { - continue; - } - - OccupiedRows.Add(Event.Row); - } - - int32 FreeRow = 0; - while (true) - { - if (OccupiedRows.Contains(FreeRow) == false) - { - break; - } - - FreeRow++; - } - - return FreeRow; -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogDebugPlotEntry::AssignAxis(int32 Row, ImAxis YAxis) { @@ -368,6 +326,7 @@ bool FCogDebugPlotEntry::FindValue(float x, float& y) const void FCogDebugPlot::Reset() { Plots.Empty(); + OccupiedRowMap.Empty(); Pause = false; ResetLastAddedEvent(); } @@ -375,11 +334,12 @@ void FCogDebugPlot::Reset() //-------------------------------------------------------------------------------------------------------------------------- void FCogDebugPlot::Clear() { - for (FCogDebugPlotEntry& Entry : FCogDebugPlot::Plots) + for (FCogDebugPlotEntry& Entry : Plots) { Entry.Clear(); } + OccupiedRowMap.Empty(); ResetLastAddedEvent(); } @@ -522,3 +482,45 @@ FCogDebugPlotEvent& FCogDebugPlot::PlotEventToggle(const UObject* WorldContextOb return PlotEventStop(WorldContextObject, PlotName, EventId); } } + + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugPlot::OccupyRow(const int32 Row) +{ + if (int32* RowOccupation = OccupiedRowMap.Find(Row)) + { + (*RowOccupation)++; + } + else + { + OccupiedRowMap.Add(Row, 1); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugPlot::FreeRow(const int32 Row) +{ + if (int32* RowOccupation = OccupiedRowMap.Find(Row)) + { + (*RowOccupation)--; + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +int32 FCogDebugPlot::FindFreeEventRow() +{ + constexpr int32 MaxRows = 100; + + int32 FreeRow = 0; + for (; FreeRow < MaxRows; ++FreeRow) + { + const int32* Occupation = OccupiedRowMap.Find(FreeRow); + if (Occupation == nullptr || *Occupation == 0) + { + break; + } + } + + return FreeRow; +} + diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugPlot.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugPlot.h index 71cfe80..3dba04e 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugPlot.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugPlot.h @@ -57,7 +57,6 @@ struct COGDEBUG_API FCogDebugPlotEntry FCogDebugPlotEvent& AddEvent(const FCogDebugPlotEntry& OwnwePlot, FString OwnerName, bool IsInstant, const FName EventId, const int32 Row, const FColor& Color); FCogDebugPlotEvent& StopEvent(const FName EventId); void UpdateTime(const UWorld* World); - int32 FindFreeRow() const; FCogDebugPlotEvent* GetLastEvent(); FCogDebugPlotEvent* FindLastEventByName(FName EventId); @@ -109,14 +108,24 @@ private: friend struct FCogDebugPlotEntry; static void ResetLastAddedEvent(); - static FCogDebugPlotEntry* RegisterPlot(const UObject* Owner, const FName PlotName, bool IsEventPlot); - FCogDebugPlotEventParams* PlotEventAddParam(const FName Name); + + static FCogDebugPlotEntry* RegisterPlot(const UObject* Owner, const FName PlotName, bool IsEventPlot); + static FCogDebugPlotEvent* GetLastAddedEvent(); + static void OccupyRow(const int32 Row); + + static void FreeRow(const int32 Row); + + static int32 FindFreeEventRow(); + static FName LastAddedEventPlotName; - static int32 LastAddedEventIndex; + + static int32 LastAddedEventIndex; static FCogDebugPlotEvent DefaultEvent; + + static TMap OccupiedRowMap; }; #endif //ENABLE_COG diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 83d0f3d..2eb83f7 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -106,11 +106,6 @@ void FCogEngineWindow_Plots::RenderMenu() if (ImGui::BeginMenu("Options")) { - if (ImGui::MenuItem("Clear data")) - { - FCogDebugPlot::Clear(); - } - if (ImGui::MenuItem("Reset")) { FCogDebugPlot::Pause = false; @@ -154,6 +149,11 @@ void FCogEngineWindow_Plots::RenderMenu() ImGui::EndMenu(); } + if (ImGui::MenuItem("Clear")) + { + FCogDebugPlot::Clear(); + } + FCogWindowWidgets::ToggleMenuButton(&FCogDebugPlot::Pause, "Pause", ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); ImGui::EndMenuBar(); diff --git a/Source/CogSample/CogSampleGameplayAbility.cpp b/Source/CogSample/CogSampleGameplayAbility.cpp index 2e485ec..df867b2 100644 --- a/Source/CogSample/CogSampleGameplayAbility.cpp +++ b/Source/CogSample/CogSampleGameplayAbility.cpp @@ -8,6 +8,10 @@ #include "CogSamplePlayerController.h" #include "CogSampleSpawnPredictionComponent.h" +#if ENABLE_COG +#include "CogDebugPlot.h" +#endif + //-------------------------------------------------------------------------------------------------------------------------- UCogSampleGameplayAbility::UCogSampleGameplayAbility() { @@ -18,8 +22,24 @@ UCogSampleGameplayAbility::UCogSampleGameplayAbility() //-------------------------------------------------------------------------------------------------------------------------- void UCogSampleGameplayAbility::PreActivate(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, FOnGameplayAbilityEnded::FDelegate* OnGameplayAbilityEndedDelegate, const FGameplayEventData* TriggerEventData) { +#if ENABLE_COG + COG_LOG_ABILITY(ELogVerbosity::Verbose, this, TEXT("")); + + FCogDebugPlot::PlotEventStart(this, "Ability", GetFName()) + .AddParam("Name", GetNameSafe(this)) + .AddParam("Owner", GetNameSafe(ActorInfo->OwnerActor.Get())) + .AddParam("Avatar", GetNameSafe(ActorInfo->AvatarActor.Get())) + .AddParam("Player Controller", GetNameSafe(ActorInfo->PlayerController.Get())) + .AddParam("Prediction Key", ActivationInfo.GetActivationPredictionKey().ToString()) + .AddParam("Event Tag", TriggerEventData ? *TriggerEventData->EventTag.ToString() : FString("None")) + .AddParam("Event Magnitude", TriggerEventData ? TriggerEventData->EventMagnitude : 0.0f); + +#endif + Super::PreActivate(Handle, ActorInfo, ActivationInfo, OnGameplayAbilityEndedDelegate, TriggerEventData); + + } //-------------------------------------------------------------------------------------------------------------------------- @@ -33,7 +53,14 @@ void UCogSampleGameplayAbility::ActivateAbility(const FGameplayAbilitySpecHandle void UCogSampleGameplayAbility::EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility, bool bWasCancelled) { Super::EndAbility(Handle, ActorInfo, ActivationInfo, bReplicateEndAbility, bWasCancelled); + +#if ENABLE_COG + COG_LOG_ABILITY(ELogVerbosity::Verbose, this, TEXT("")); + + FCogDebugPlot::PlotEventStop(this, "Ability", GetFName()); + +#endif } //--------------------------------------------------------------------------------------------------------------------------