diff --git a/Changelog.txt b/Changelog.txt index ca434b4..5e719ab 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,11 @@ +###### 3.6.0 +* Added Labels. You can add a Label to every Action which helps with debugging (Labels are displayed in logs) and you + can search for running action's handles by these Labels. +* GetActionsHandlesByClass and GetActionsHandlesByLabel functions added which returns an array of handles of valid Actions. +* GetAllActions, GetActionsCount, GetActionFromHandle, and GetActionFromInstancedId functions has been added for C++, which + returns pointers to actual Actions objects. Use them for DEBUGGING purposes only! +* MarkAsFinished function is now protected + ###### 3.5.4 * Better detection of if the compiler supports coroutines or not. * ECF_WITH_COROUTINES macro added for excluding coroutine code for compilers that do not support them. diff --git a/EnhancedCodeFlow.uplugin b/EnhancedCodeFlow.uplugin index 6403c2d..10bac43 100644 --- a/EnhancedCodeFlow.uplugin +++ b/EnhancedCodeFlow.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, "Version": 1, - "VersionName": "3.5.4", + "VersionName": "3.6.0", "FriendlyName": "Enhanced Code Flow", "Description": "This code plugin provides functions that drastically improve the quality of life during the implementation of game flow in C++.", "Category": "Programming", diff --git a/README.md b/README.md index dc5ab68..a4f10f0 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ The plugin works on Unreal Engine: 4.27, 5.2-5.7. - [Extra Settings](#extra-settings) - [Instanced Actions](#instanced-actions) - [Coroutines (experimental)](#coroutines-experimental) +- [Getting Running Actions](#getting-running-actions) - [Pausing and Resuming](#pausing-and-resuming) - [Stopping Actions](#stopping-actions) - [Resetting Actions](#resetting-actions) @@ -569,6 +570,7 @@ You can define extra settings at the end of each action launch. Currently the fo * Ignore Game Pause - it will ignore the game pause. * Ignore Global Time Dilation - it will ignore global time dilation when ticking. * Start Paused - the action will start in paused state and must be resumed manually. +* Label - the string that can be used to identify the action. ``` cpp FFlow::AddTicker(this, 10.f, [this](float DeltaTime) @@ -752,6 +754,27 @@ This applies especially to places where you use coroutine keywords, like `co_awa [Back to coroutines](#coroutines-experimental) [Back to top](#table-of-content) +# Getting Running Actions +To get running action's handles use one of the following functions: + +#### Get Actions Handles by Class + +```cpp +TArray Handles = FFlow::GetActionsHandlesByClass(GetWorld()); +``` + +ecffindbyclass + +#### Get Actions Handles by Label + +```cpp +TArray Handles = FFlow::GetActionsHandlesByLabel(TEXT("MyLabel")); +``` + +ecffindbylabel + +[Back to top](#table-of-content) + # Pausing and Resuming ## Actions diff --git a/Source/EnhancedCodeFlow/Private/BP/ECFBPLibrary.cpp b/Source/EnhancedCodeFlow/Private/BP/ECFBPLibrary.cpp index 20fcbcc..2e7909b 100644 --- a/Source/EnhancedCodeFlow/Private/BP/ECFBPLibrary.cpp +++ b/Source/EnhancedCodeFlow/Private/BP/ECFBPLibrary.cpp @@ -24,6 +24,30 @@ void UECFBPLibrary::ECFIsActionRunning(bool& bIsRunning, const UObject* WorldCon bIsRunning = FFlow::IsActionRunning(WorldContextObject, Handle.Handle); } +TArray UECFBPLibrary::GetActionsHandlesByClass(const UObject* WorldContextObject, TSubclassOf Class) +{ + TArray Result = FFlow::GetActionsHandlesByClass(WorldContextObject, Class); + TArray ResultBP; + ResultBP.Reserve(Result.Num()); + for (const FECFHandle& Handle : Result) + { + ResultBP.Add(FECFHandleBP(Handle)); + } + return ResultBP; +} + +TArray UECFBPLibrary::GetActionsHandlesByLabel(const UObject* WorldContextObject, const FString& Label) +{ + TArray Result = FFlow::GetActionsHandlesByLabel(WorldContextObject, Label); + TArray ResultBP; + ResultBP.Reserve(Result.Num()); + for (const FECFHandle& Handle : Result) + { + ResultBP.Add(FECFHandleBP(Handle)); + } + return ResultBP; +} + void UECFBPLibrary::ECFPauseAction(const UObject* WorldContextObject, const FECFHandleBP& Handle) { FFlow::PauseAction(WorldContextObject, Handle.Handle); @@ -182,6 +206,5 @@ FString UECFBPLibrary::Conv_ECFInstanceIdToString(const FECFInstanceIdBP& Instan return InstanceId.InstanceId.ToString(); } -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ ECF_PRAGMA_ENABLE_OPTIMIZATION \ No newline at end of file diff --git a/Source/EnhancedCodeFlow/Private/ECFSubsystem.cpp b/Source/EnhancedCodeFlow/Private/ECFSubsystem.cpp index e0b5516..e5cf3ee 100644 --- a/Source/EnhancedCodeFlow/Private/ECFSubsystem.cpp +++ b/Source/EnhancedCodeFlow/Private/ECFSubsystem.cpp @@ -138,12 +138,78 @@ UECFActionBase* UECFSubsystem::FindAction(const FECFHandle& HandleId) const return nullptr; } +TArray UECFSubsystem::GetActionsHandlesByClass(TSubclassOf Class) const +{ + TArray Result; + if (Class == nullptr) + { + return Result; + } + // Search in active actions + for (UECFActionBase* Action : Actions) + { + if (IsActionValid(Action) && (Action->GetClass() == Class)) + { + Result.Add(Action->GetHandleId()); + } + } + // Search in pending actions + for (UECFActionBase* PendingAction : PendingAddActions) + { + if (IsActionValid(PendingAction) && (PendingAction->GetClass() == Class)) + { + Result.Add(PendingAction->GetHandleId()); + } + } + return Result; +} + +TArray UECFSubsystem::GetActionsHandlesByLabel(const FString& Label) const +{ + TArray Result; + if (Label.IsEmpty()) + { + return Result; + } + // Search in active actions + for (UECFActionBase* Action : Actions) + { + if (IsActionValid(Action) && (Action->Settings.Label == Label)) + { + Result.Add(Action->GetHandleId()); + } + } + // Search in pending actions + for (UECFActionBase* PendingAction : PendingAddActions) + { + if (IsActionValid(PendingAction) && (PendingAction->Settings.Label == Label)) + { + Result.Add(PendingAction->GetHandleId()); + } + } + return Result; +} + +TArray UECFSubsystem::GetAllActions() const +{ + TArray Result; + Result.Reserve(GetActionsCount()); + Result.Append(Actions); + Result.Append(PendingAddActions); + return Result; +} + +int32 UECFSubsystem::GetActionsCount() const +{ + return Actions.Num() + PendingAddActions.Num(); +} + void UECFSubsystem::PauseAction(const FECFHandle& HandleId) { if (UECFActionBase* ActionFound = FindAction(HandleId)) { #if (ECF_LOGS && ECF_LOGS_VERBOSE) - UE_LOG(LogECF, Verbose, TEXT("Paused Action of class: %s"), *ActionFound->GetName()); + UE_LOG(LogECF, Verbose, TEXT("Paused Action of class: %s, Label: %s"), *ActionFound->GetName(), *ActionFound->GetLabel()); #endif ActionFound->bIsPaused = true; } @@ -160,7 +226,7 @@ void UECFSubsystem::ResumeAction(const FECFHandle& HandleId) if (UECFActionBase* ActionFound = FindAction(HandleId)) { #if (ECF_LOGS && ECF_LOGS_VERBOSE) - UE_LOG(LogECF, Verbose, TEXT("Resume Action of class: %s"), *ActionFound->GetName()); + UE_LOG(LogECF, Verbose, TEXT("Resume Action of class: %s, Label: %s"), *ActionFound->GetName(), *ActionFound->GetLabel()); #endif ActionFound->bIsPaused = false; } @@ -189,7 +255,7 @@ void UECFSubsystem::ResetAction(const FECFHandle& HandleId, bool bCallUpdate) if (IsActionValid(ActionFound)) { #if (ECF_LOGS && ECF_LOGS_VERBOSE) - UE_LOG(LogECF, Verbose, TEXT("Reset Action of class: %s"), *ActionFound->GetName()); + UE_LOG(LogECF, Verbose, TEXT("Reset Action of class: %s, Label: %s"), *ActionFound->GetName(), *ActionFound->GetLabel()); #endif ActionFound->Reset(bCallUpdate); return; @@ -206,7 +272,7 @@ void UECFSubsystem::RemoveAction(FECFHandle& HandleId, bool bComplete) if (UECFActionBase* ActionFound = FindAction(HandleId)) { #if (ECF_LOGS && ECF_LOGS_VERBOSE) - UE_LOG(LogECF, Verbose, TEXT("Remove Action of class: %s"), *ActionFound->GetName()); + UE_LOG(LogECF, Verbose, TEXT("Remove Action of class: %s, Label: %s"), *ActionFound->GetName(), *ActionFound->GetLabel()); #endif FinishAction(ActionFound, bComplete); HandleId.Invalidate(); diff --git a/Source/EnhancedCodeFlow/Private/EnhancedCodeFlow.cpp b/Source/EnhancedCodeFlow/Private/EnhancedCodeFlow.cpp index a081a39..e3fff6c 100644 --- a/Source/EnhancedCodeFlow/Private/EnhancedCodeFlow.cpp +++ b/Source/EnhancedCodeFlow/Private/EnhancedCodeFlow.cpp @@ -37,6 +37,48 @@ bool FFlow::IsActionRunning(const UObject* WorldContextObject, const FECFHandle& return false; } +TArray FEnhancedCodeFlow::GetActionsHandlesByClass(const UObject* WorldContextObject, TSubclassOf Class) +{ + if (UECFSubsystem* ECF = UECFSubsystem::Get(WorldContextObject)) + return ECF->GetActionsHandlesByClass(Class); + return {}; +} + +TArray FEnhancedCodeFlow::GetActionsHandlesByLabel(const UObject* WorldContextObject, const FString& Label) +{ + if (UECFSubsystem* ECF = UECFSubsystem::Get(WorldContextObject)) + return ECF->GetActionsHandlesByLabel(Label); + return {}; +} + +TArray FEnhancedCodeFlow::GetAllActions(const UObject* WorldContextObject) +{ + if (UECFSubsystem* ECF = UECFSubsystem::Get(WorldContextObject)) + return ECF->GetAllActions(); + return {}; +} + +int32 FEnhancedCodeFlow::GetActionsCount(const UObject* WorldContextObject) +{ + if (UECFSubsystem* ECF = UECFSubsystem::Get(WorldContextObject)) + return ECF->GetActionsCount(); + return 0; +} + +UECFActionBase* FEnhancedCodeFlow::GetActionFromHandle(const UObject* WorldContextObject, const FECFHandle& Handle) +{ + if (UECFSubsystem* ECF = UECFSubsystem::Get(WorldContextObject)) + return ECF->FindAction(Handle); + return nullptr; +} + +UECFActionBase* FEnhancedCodeFlow::GetActionFromHandle(const UObject* WorldContextObject, const FECFInstanceId& InstancedId) +{ + if (UECFSubsystem* ECF = UECFSubsystem::Get(WorldContextObject)) + return ECF->GetInstancedAction(InstancedId); + return nullptr; +} + void FEnhancedCodeFlow::PauseAction(const UObject* WorldContextObject, const FECFHandle& Handle) { if (UECFSubsystem* ECF = UECFSubsystem::Get(WorldContextObject)) diff --git a/Source/EnhancedCodeFlow/Public/BP/ECFBPLibrary.h b/Source/EnhancedCodeFlow/Public/BP/ECFBPLibrary.h index 93df246..fabd5cf 100644 --- a/Source/EnhancedCodeFlow/Public/BP/ECFBPLibrary.h +++ b/Source/EnhancedCodeFlow/Public/BP/ECFBPLibrary.h @@ -47,6 +47,18 @@ class ENHANCEDCODEFLOW_API UECFBPLibrary : public UBlueprintFunctionLibrary UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject", DisplayName = "ECF - Is Action Running"), Category = "ECF") static void ECFIsActionRunning(UPARAM(DisplayName = "IsRunning") bool& bIsRunning, const UObject* WorldContextObject, const FECFHandleBP& Handle); + /** + * Finds handles of running or pending action of the given Class its FECFHandles. + */ + UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject", DisplayName = "ECF - Get Actions Handles By Class"), Category = "ECF") + static TArray GetActionsHandlesByClass(const UObject* WorldContextObject, TSubclassOf Class); + + /** + * Finds handles of running or pending action of the given Label its FECFHandles (for Blueprints). + */ + UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject", DisplayName = "ECF - Get Actions Handles By Label"), Category = "ECF") + static TArray GetActionsHandlesByLabel(const UObject* WorldContextObject, const FString& Label); + /** * Pause running action. */ diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimeline.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimeline.h index 666a44c..3935492 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimeline.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimeline.h @@ -46,7 +46,7 @@ class ENHANCEDCODEFLOW_API UECFCustomTimeline : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - custom timeline failed to start. Are you sure Tick Function and Curve are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] custom timeline failed to start. Are you sure Tick Function and Curve are set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineLinearColor.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineLinearColor.h index 5392eee..dba2267 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineLinearColor.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineLinearColor.h @@ -46,7 +46,7 @@ class ENHANCEDCODEFLOW_API UECFCustomTimelineLinearColor : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - custom timeline LinearColor failed to start. Are you sure Tick Function and Curve are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] custom timeline LinearColor failed to start. Are you sure Tick Function and Curve are set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineVector.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineVector.h index 9c4a57e..b5d8c91 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineVector.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineVector.h @@ -46,7 +46,7 @@ class ENHANCEDCODEFLOW_API UECFCustomTimelineVector : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - custom timeline vector failed to start. Are you sure Tick Function and Curve are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] custom timeline vector failed to start. Are you sure Tick Function and Curve are set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelay.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelay.h index c6e7327..28ff7b7 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelay.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelay.h @@ -37,7 +37,7 @@ class ENHANCEDCODEFLOW_API UECFDelay : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - delay failed to start. Are you sure the DelayTime is not negative and Callback Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] delay failed to start. Are you sure the DelayTime is not negative and Callback Function is set properly?"), *Settings.Label); #endif return false; } @@ -56,7 +56,7 @@ class ENHANCEDCODEFLOW_API UECFDelay : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - delay failed to start. Are you sure the Callback Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] delay failed to start. Are you sure the Callback Function is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelayTicks.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelayTicks.h index 5b82d70..5e56024 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelayTicks.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDelayTicks.h @@ -33,7 +33,7 @@ class ENHANCEDCODEFLOW_API UECFDelayTicks : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - delay ticks failed to start. Are you sure the DelayTicks is not negative and Callback Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] delay ticks failed to start. Are you sure the DelayTicks is not negative and Callback Function is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNTimes.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNTimes.h index 07eec3e..9e69bf1 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNTimes.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNTimes.h @@ -32,7 +32,7 @@ class ENHANCEDCODEFLOW_API UECFDoNTimes : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - DoNTimes failed to start. Are you sure Exec Fuinction and Times number are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Do N Times failed to start. Are you sure the Exec Function is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNoMoreThanXTime.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNoMoreThanXTime.h index 115f4ae..fa5b5e9 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNoMoreThanXTime.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoNoMoreThanXTime.h @@ -36,7 +36,7 @@ class ENHANCEDCODEFLOW_API UECFDoNoMoreThanXTime : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Do No More Than Times failed to start. Are you sure the Lock time and Max Execs Eneueud are greater than 0 and the Exec Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Do No More Than Times failed to start. Are you sure the Lock time and Max Execs Eneueud are greater than 0 and the Exec Function is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoOnce.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoOnce.h index ccbca4a..2cb813b 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoOnce.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFDoOnce.h @@ -30,7 +30,7 @@ class ENHANCEDCODEFLOW_API UECFDoOnce : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - do once failed to start. Are you sure the Exec Function is is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] do once failed to start. Are you sure the Exec Function is is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFRunAsyncThen.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFRunAsyncThen.h index aa8e1c8..54595bd 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFRunAsyncThen.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFRunAsyncThen.h @@ -81,7 +81,7 @@ class ENHANCEDCODEFLOW_API UECFRunAsyncThen : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Run Async Task and Run failed to start. Are you sure the AsyncTask and Function are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Run Async Task and Run failed to start. Are you sure the AsyncTask and Function are set properly?"), *Settings.Label); #endif return false; } @@ -100,7 +100,7 @@ class ENHANCEDCODEFLOW_API UECFRunAsyncThen : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Run Async Task and Run failed to start. Are you sure the Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Run Async Task and Run failed to start. Are you sure the Function is set properly?"), *Settings.Label); #endif return false; } @@ -119,7 +119,7 @@ class ENHANCEDCODEFLOW_API UECFRunAsyncThen : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Run Async Task and Run failed to start. Are you sure the Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Run Async Task and Run failed to start. Are you sure the Function is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTicker.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTicker.h index c9f0d24..e59ab88 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTicker.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTicker.h @@ -43,7 +43,7 @@ class ENHANCEDCODEFLOW_API UECFTicker : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Ticker(2) failed to start. Are you sure the Ticking time and Ticking Function are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] ticker failed to start. Are you sure the Ticking time is greater than 0 and Ticking Function are set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeLock.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeLock.h index 9eea8b8..d370615 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeLock.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeLock.h @@ -33,7 +33,7 @@ class ENHANCEDCODEFLOW_API UECFTimeLock : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Timelock failed to start. Are you sure the Lock time is greater than 0 and the Exec Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Timelock failed to start. Are you sure the Lock time is greater than 0 and the Exec Function is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeline.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeline.h index dd5fd19..b37917e 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeline.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimeline.h @@ -70,7 +70,7 @@ class ENHANCEDCODEFLOW_API UECFTimeline : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Timeline failed to start. Are you sure the Ticking time is greater than 0 and Ticking Function are set properly? /n Remember, that BlendExp must be different than zero and StartValue and StopValue must not be the same!")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Timeline failed to start. Are you sure the Ticking time is greater than 0 and Ticking Function are set properly? /n Remember, that BlendExp must be different than zero and StartValue and StopValue must not be the same!"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineLinearColor.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineLinearColor.h index 741821b..32d6ba0 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineLinearColor.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineLinearColor.h @@ -70,7 +70,7 @@ class ENHANCEDCODEFLOW_API UECFTimelineLinearColor: public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Timeline Linear Color failed to start. Are you sure the Ticking time is greater than 0 and Ticking Function are set properly? /n Remember, that BlendExp must be different than zero and StartValue and StopValue must not be the same!")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Timeline Linear Color failed to start. Are you sure the Ticking time is greater than 0 and Ticking Function are set properly? /n Remember, that BlendExp must be different than zero and StartValue and StopValue must not be the same!"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineVector.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineVector.h index f0e9b8e..aa4cb5a 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineVector.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFTimelineVector.h @@ -70,7 +70,7 @@ class ENHANCEDCODEFLOW_API UECFTimelineVector : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Timeline Vector failed to start. Are you sure the Ticking time is greater than 0 and Ticking Function are set properly? /n Remember, that BlendExp must be different than zero and StartValue and StopValue must not be the same!")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Timeline Vector failed to start. Are you sure the Ticking time is greater than 0 and Ticking Function are set properly? /n Remember, that BlendExp must be different than zero and StartValue and StopValue must not be the same!"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWaitAndExecute.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWaitAndExecute.h index e9574fa..8871f97 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWaitAndExecute.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWaitAndExecute.h @@ -60,7 +60,7 @@ class ENHANCEDCODEFLOW_API UECFWaitAndExecute : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Wait and Execute failed to start. Are you sure the Predicate and Function are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Wait and Execute failed to start. Are you sure the Predicate and Function are set properly?"), *Settings.Label); #endif return false; } @@ -82,7 +82,7 @@ class ENHANCEDCODEFLOW_API UECFWaitAndExecute : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Wait and Execute failed to start. Are you sure the Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Wait and Execute failed to start. Are you sure the Function is set properly?"), *Settings.Label); #endif return false; } @@ -104,7 +104,7 @@ class ENHANCEDCODEFLOW_API UECFWaitAndExecute : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Wait and Execute failed to start. Are you sure the Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Wait and Execute failed to start. Are you sure the Function is set properly?"), *Settings.Label); #endif return false; } @@ -131,7 +131,7 @@ class ENHANCEDCODEFLOW_API UECFWaitAndExecute : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Wait and Execute failed to start. Are you sure the Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Wait and Execute failed to start. Are you sure the Function is set properly?"), *Settings.Label); #endif return false; } @@ -153,7 +153,7 @@ class ENHANCEDCODEFLOW_API UECFWaitAndExecute : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Wait and Execute failed to start. Are you sure the Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Wait and Execute failed to start. Are you sure the Function is set properly?"), *Settings.Label); #endif return false; } @@ -180,7 +180,7 @@ class ENHANCEDCODEFLOW_API UECFWaitAndExecute : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - Wait and Execute failed to start. Are you sure the Function is set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] Wait and Execute failed to start. Are you sure the Function is set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWhileTrueExecute.h b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWhileTrueExecute.h index 88c2eb2..a8c6eef 100644 --- a/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWhileTrueExecute.h +++ b/Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFWhileTrueExecute.h @@ -61,7 +61,7 @@ class ENHANCEDCODEFLOW_API UECFWhileTrueExecute : public UECFActionBase else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("ECF - While True Execute failed to start. Are you sure the Predicate and Function are set properly?")); + UE_LOG(LogECF, Error, TEXT("ECF - [%s] While True Execute failed to start. Are you sure the Predicate and Function are set properly?"), *Settings.Label); #endif return false; } diff --git a/Source/EnhancedCodeFlow/Public/ECFActionBase.h b/Source/EnhancedCodeFlow/Public/ECFActionBase.h index b675788..b6f1d38 100644 --- a/Source/EnhancedCodeFlow/Public/ECFActionBase.h +++ b/Source/EnhancedCodeFlow/Public/ECFActionBase.h @@ -54,14 +54,16 @@ class ENHANCEDCODEFLOW_API UECFActionBase : public UObject return InstanceId; } - // Marks this action as finished. It makes it invalid. - // This action will be deleted soon. - void MarkAsFinished() + // Returns this action Label + FString GetLabel() const { -#if (ECF_LOGS && ECF_LOGS_VERBOSE) - UE_LOG(LogECF, Verbose, TEXT("Action of class %s marked as finished"), *GetName()); -#endif - bHasFinished = true; + return Settings.Label; + } + + // Checks if this action is paused + bool IsPaused() const + { + return bIsPaused; } // Checks if this action has this instance id. @@ -93,6 +95,16 @@ class ENHANCEDCODEFLOW_API UECFActionBase : public UObject // Function called when the action is requested to be completed before it ends. virtual void Complete(bool bStopped) {} + // Marks this action as finished. It makes it invalid. + // This action will be deleted soon. + void MarkAsFinished() + { +#if (ECF_LOGS && ECF_LOGS_VERBOSE) + UE_LOG(LogECF, Verbose, TEXT("Action of class %s marked as finished, Label: %s"), *GetName(), *GetLabel()); +#endif + bHasFinished = true; + } + // Function called when this action is instanced and something tried to call it again. virtual void RetriggeredInstancedAction() {} diff --git a/Source/EnhancedCodeFlow/Public/ECFActionSettings.h b/Source/EnhancedCodeFlow/Public/ECFActionSettings.h index c62336e..40cdccc 100644 --- a/Source/EnhancedCodeFlow/Public/ECFActionSettings.h +++ b/Source/EnhancedCodeFlow/Public/ECFActionSettings.h @@ -15,19 +15,20 @@ struct ENHANCEDCODEFLOW_API FECFActionSettings FirstDelay(0.f), bIgnorePause(false), bIgnoreGlobalTimeDilation(false), - bStartPaused(false) + bStartPaused(false), + Label(TEXT("")) { } - FECFActionSettings(float InTickInterval, float InFirstDelay = 0.f, bool InIgnorePause = false, bool InIgnoreTimeDilation = false, bool InStartPaused = false) : + FECFActionSettings(float InTickInterval, float InFirstDelay = 0.f, bool InIgnorePause = false, bool InIgnoreTimeDilation = false, bool InStartPaused = false, const FString& InLabel = TEXT("")) : TickInterval(InTickInterval), FirstDelay(InFirstDelay), bIgnorePause(InIgnorePause), bIgnoreGlobalTimeDilation(InIgnoreTimeDilation), - bStartPaused(InStartPaused) + bStartPaused(InStartPaused), + Label(InLabel) { - } UPROPERTY(BlueprintReadWrite, Category = "ECF") @@ -44,11 +45,15 @@ struct ENHANCEDCODEFLOW_API FECFActionSettings UPROPERTY(BlueprintReadWrite, Category = "ECF") bool bStartPaused = false; + + UPROPERTY(BlueprintReadWrite, Category = "ECF") + FString Label; }; -#define ECF_TICKINTERVAL(_Interval) FECFActionSettings(_Interval, 0.f, false, false, false) -#define ECF_DELAYFIRST(_Delay) FECFActionSettings(0.f, _Delay, false, false, false) -#define ECF_IGNOREPAUSE FECFActionSettings(0.f, 0.f, true, false, false) -#define ECF_IGNORETIMEDILATION FECFActionSettings(0.f, 0.f, false, true, false) -#define ECF_IGNOREPAUSEDILATION FECFActionSettings(0.f, 0.f, true, true, false) -#define ECF_STARTPAUSED FECFActionSettings(0.f, 0.f, false, false, true) +#define ECF_TICKINTERVAL(_Interval) FECFActionSettings(_Interval, 0.f, false, false, false, TEXT("")) +#define ECF_DELAYFIRST(_Delay) FECFActionSettings(0.f, _Delay, false, false, false, TEXT("")) +#define ECF_IGNOREPAUSE FECFActionSettings(0.f, 0.f, true, false, false, TEXT("")) +#define ECF_IGNORETIMEDILATION FECFActionSettings(0.f, 0.f, false, true, false, TEXT("")) +#define ECF_IGNOREPAUSEDILATION FECFActionSettings(0.f, 0.f, true, true, false, TEXT("")) +#define ECF_STARTPAUSED FECFActionSettings(0.f, 0.f, false, false, true, TEXT("")) +#define ECF_LABEL(_Label) FECFActionSettings(0.f, 0.f, false, false, false, _Label) diff --git a/Source/EnhancedCodeFlow/Public/ECFSubsystem.h b/Source/EnhancedCodeFlow/Public/ECFSubsystem.h index e252066..1b7beb5 100644 --- a/Source/EnhancedCodeFlow/Public/ECFSubsystem.h +++ b/Source/EnhancedCodeFlow/Public/ECFSubsystem.h @@ -70,11 +70,11 @@ class ENHANCEDCODEFLOW_API UECFSubsystem : public UGameInstanceSubsystem, public #if (ECF_LOGS && ECF_LOGS_VERBOSE) if (InstanceId.IsValid()) { - UE_LOG(LogECF, Verbose, TEXT("Started Instanced Action of class: %s, with HandleId: %s, and InstanceId: %s"), *NewAction->GetName(), *LastHandleId.ToString(), *InstanceId.ToString()); + UE_LOG(LogECF, Verbose, TEXT("Started Instanced Action of class: %s, with HandleId: %s, and InstanceId: %s, Label: %s"), *NewAction->GetName(), *LastHandleId.ToString(), *InstanceId.ToString(), *Settings.Label); } else { - UE_LOG(LogECF, Verbose, TEXT("Started Action of class: %s, with HandleId: %s"), *NewAction->GetName(), *LastHandleId.ToString()); + UE_LOG(LogECF, Verbose, TEXT("Started Action of class: %s, with HandleId: %s, Label: %s"), *NewAction->GetName(), *LastHandleId.ToString(), *Settings.Label); } #endif return NewAction->GetHandleId(); @@ -82,7 +82,7 @@ class ENHANCEDCODEFLOW_API UECFSubsystem : public UGameInstanceSubsystem, public else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("Failed to Setup Action of class: %s"), *NewAction->GetName()); + UE_LOG(LogECF, Error, TEXT("Failed to Setup Action of class: %s, Label: %s"), *NewAction->GetName(), *Settings.Label); #endif } @@ -111,21 +111,33 @@ class ENHANCEDCODEFLOW_API UECFSubsystem : public UGameInstanceSubsystem, public { NewAction->Init(); #if (ECF_LOGS && ECF_LOGS_VERBOSE) - UE_LOG(LogECF, Verbose, TEXT("Started Coroutine Action of class: %s"), *NewAction->GetName()); + UE_LOG(LogECF, Verbose, TEXT("Started Coroutine Action of class: %s, Label: %s"), *NewAction->GetName(), *Settings.Label); #endif PendingAddActions.Add(NewAction); } else { #if ECF_LOGS - UE_LOG(LogECF, Error, TEXT("Failed to Setup Coroutine Action of class: %s"), *NewAction->GetName()); + UE_LOG(LogECF, Error, TEXT("Failed to Setup Coroutine Action of class: %s, Label: %s"), *NewAction->GetName(), *Settings.Label); #endif } } - // Try to find running or pending action. + // Try to find running or pending action based on it's handle. UECFActionBase* FindAction(const FECFHandle& HandleId) const; + // Finds handles of running or pending action of the given Class its FECFHandles. + TArray GetActionsHandlesByClass(TSubclassOf Class) const; + + // Finds handles of running or pending action of the given Label its FECFHandles. + TArray GetActionsHandlesByLabel(const FString& Label) const; + + // Returns the array of all running and pending actions. Use it mostly for debugging purposes. + TArray GetAllActions() const; + + // Returns the number of all running and pending actions. Use it mostly for debugging purposes. + int32 GetActionsCount() const; + // Check if the action is running or pending to run. bool HasAction(const FECFHandle& HandleId) const; diff --git a/Source/EnhancedCodeFlow/Public/EnhancedCodeFlow.h b/Source/EnhancedCodeFlow/Public/EnhancedCodeFlow.h index fb08a33..46907fc 100644 --- a/Source/EnhancedCodeFlow/Public/EnhancedCodeFlow.h +++ b/Source/EnhancedCodeFlow/Public/EnhancedCodeFlow.h @@ -45,6 +45,42 @@ class ENHANCEDCODEFLOW_API FEnhancedCodeFlow */ static bool IsActionRunning(const UObject* WorldContextObject, const FECFHandle& Handle); + /** + * Finds handles of running or pending action of the given Class its FECFHandles. + */ + static TArray GetActionsHandlesByClass(const UObject* WorldContextObject, TSubclassOf Class); + + template + static TArray GetActionsHandlesByClass(const UObject* WorldContextObject) + { + return GetActionsHandlesByClass(WorldContextObject, T::StaticClass()); + } + + /** + * Finds handles of running or pending action of the given Label its FECFHandles. + */ + static TArray GetActionsHandlesByLabel(const UObject* WorldContextObject, const FString& Label); + + /** + * Returns the array of all running and pending actions. Use it mostly for debugging purposes. + */ + static TArray GetAllActions(const UObject* WorldContextObject); + + /** + * Returns the number of all running and pending actions. Use it mostly for debugging purposes. + */ + static int32 GetActionsCount(const UObject* WorldContextObject); + + /** + * Returns the popinter to the Action. Use it mostly for debugging purposes. + */ + static UECFActionBase* GetActionFromHandle(const UObject* WorldContextObject, const FECFHandle& Handle); + + /** + * Returns the popinter to the Instanced Action. Use it mostly for debugging purposes. + */ + static UECFActionBase* GetActionFromHandle(const UObject* WorldContextObject, const FECFInstanceId& InstancedId); + /** * Pause ticking in the action pointed by given handle. */ @@ -533,6 +569,8 @@ class ENHANCEDCODEFLOW_API FEnhancedCodeFlow * it will remove Wait Until actions from everywhere. */ static void RemoveAllRunAsyncAndWait(const UObject* WorldContextObject, bool bComplete = false, UObject* InOwner = nullptr); + + }; using FFlow = FEnhancedCodeFlow; \ No newline at end of file