-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
custom timelines for vector and linear color added
- Loading branch information
Showing
11 changed files
with
445 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Source/EnhancedCodeFlow/Private/BP/Actions/ECFCustomTimelineLinearColorBP.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2024 Damian Nowakowski. All rights reserved. | ||
|
||
#include "ECFCustomTimelineLinearColorBP.h" | ||
#include "EnhancedCodeFlow.h" | ||
|
||
ECF_PRAGMA_DISABLE_OPTIMIZATION | ||
|
||
UECFCustomTimelineLinearColorBP* UECFCustomTimelineLinearColorBP::ECFCustomTimelineLinearColor(const UObject* WorldContextObject, UCurveLinearColor* CurveLinearColor, FECFActionSettings Settings, FECFHandleBP& Handle) | ||
{ | ||
UECFCustomTimelineLinearColorBP* Proxy = NewObject<UECFCustomTimelineLinearColorBP>(); | ||
if (Proxy) | ||
{ | ||
Proxy->Init(WorldContextObject, Settings); | ||
Proxy->Proxy_Handle = FFlow::AddCustomTimelineLinearColor(WorldContextObject, CurveLinearColor, | ||
[Proxy](FLinearColor Value, float Time) | ||
{ | ||
if (IsProxyValid(Proxy)) | ||
{ | ||
Proxy->OnTick.Broadcast(Value, Time, false); | ||
} | ||
}, | ||
[Proxy](FLinearColor Value, float Time, bool bStopped) | ||
{ | ||
if (IsProxyValid(Proxy)) | ||
{ | ||
Proxy->OnFinished.Broadcast(Value, Time, bStopped); | ||
Proxy->ClearAsyncBPAction(); | ||
} | ||
}, | ||
Settings); | ||
Handle = FECFHandleBP(Proxy->Proxy_Handle); | ||
} | ||
|
||
return Proxy; | ||
} | ||
|
||
ECF_PRAGMA_ENABLE_OPTIMIZATION |
25 changes: 25 additions & 0 deletions
25
Source/EnhancedCodeFlow/Private/BP/Actions/ECFCustomTimelineLinearColorBP.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2024 Damian Nowakowski. All rights reserved. | ||
|
||
#pragma once | ||
|
||
#include "../ECFActionBP.h" | ||
#include "ECFCustomTimelineLinearColorBP.generated.h" | ||
|
||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnECFCustomTimelineLinearColorBPEvent, FLinearColor, Value, float, Time, bool, bStopped); | ||
|
||
UCLASS() | ||
class ENHANCEDCODEFLOW_API UECFCustomTimelineLinearColorBP : public UECFActionBP | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
|
||
UPROPERTY(BlueprintAssignable) | ||
FOnECFCustomTimelineLinearColorBPEvent OnTick; | ||
|
||
UPROPERTY(BlueprintAssignable) | ||
FOnECFCustomTimelineLinearColorBPEvent OnFinished; | ||
|
||
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AdvancedDisplay = "Settings", ToolTip = "Adds a custom timeline defined by a float curve.", DisplayName = "ECF - Custom Timeline LinearColor"), Category = "ECF") | ||
static UECFCustomTimelineLinearColorBP* ECFCustomTimelineLinearColor(const UObject* WorldContextObject, class UCurveLinearColor* CurveLinearColor, FECFActionSettings Settings, FECFHandleBP& Handle); | ||
}; |
37 changes: 37 additions & 0 deletions
37
Source/EnhancedCodeFlow/Private/BP/Actions/ECFCustomTimelineVectorBP.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2024 Damian Nowakowski. All rights reserved. | ||
|
||
#include "ECFCustomTimelineVectorBP.h" | ||
#include "EnhancedCodeFlow.h" | ||
|
||
ECF_PRAGMA_DISABLE_OPTIMIZATION | ||
|
||
UECFCustomTimelineVectorBP* UECFCustomTimelineVectorBP::ECFCustomTimelineVector(const UObject* WorldContextObject, UCurveVector* CurveVector, FECFActionSettings Settings, FECFHandleBP& Handle) | ||
{ | ||
UECFCustomTimelineVectorBP* Proxy = NewObject<UECFCustomTimelineVectorBP>(); | ||
if (Proxy) | ||
{ | ||
Proxy->Init(WorldContextObject, Settings); | ||
Proxy->Proxy_Handle = FFlow::AddCustomTimelineVector(WorldContextObject, CurveVector, | ||
[Proxy](FVector Value, float Time) | ||
{ | ||
if (IsProxyValid(Proxy)) | ||
{ | ||
Proxy->OnTick.Broadcast(Value, Time, false); | ||
} | ||
}, | ||
[Proxy](FVector Value, float Time, bool bStopped) | ||
{ | ||
if (IsProxyValid(Proxy)) | ||
{ | ||
Proxy->OnFinished.Broadcast(Value, Time, bStopped); | ||
Proxy->ClearAsyncBPAction(); | ||
} | ||
}, | ||
Settings); | ||
Handle = FECFHandleBP(Proxy->Proxy_Handle); | ||
} | ||
|
||
return Proxy; | ||
} | ||
|
||
ECF_PRAGMA_ENABLE_OPTIMIZATION |
25 changes: 25 additions & 0 deletions
25
Source/EnhancedCodeFlow/Private/BP/Actions/ECFCustomTimelineVectorBP.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2024 Damian Nowakowski. All rights reserved. | ||
|
||
#pragma once | ||
|
||
#include "../ECFActionBP.h" | ||
#include "ECFCustomTimelineVectorBP.generated.h" | ||
|
||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnECFCustomTimelineVectorBPEvent, FVector, Value, float, Time, bool, bStopped); | ||
|
||
UCLASS() | ||
class ENHANCEDCODEFLOW_API UECFCustomTimelineVectorBP : public UECFActionBP | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
|
||
UPROPERTY(BlueprintAssignable) | ||
FOnECFCustomTimelineVectorBPEvent OnTick; | ||
|
||
UPROPERTY(BlueprintAssignable) | ||
FOnECFCustomTimelineVectorBPEvent OnFinished; | ||
|
||
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AdvancedDisplay = "Settings", ToolTip = "Adds a custom timeline defined by a float curve.", DisplayName = "ECF - Custom Timeline Vector"), Category = "ECF") | ||
static UECFCustomTimelineVectorBP* ECFCustomTimelineVector(const UObject* WorldContextObject, class UCurveVector* CurveVector, FECFActionSettings Settings, FECFHandleBP& Handle); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
Source/EnhancedCodeFlow/Public/CodeFlowActions/ECFCustomTimelineLinearColor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Copyright (c) 2024 Damian Nowakowski. All rights reserved. | ||
|
||
#pragma once | ||
|
||
#include "ECFActionBase.h" | ||
#include "Components/TimelineComponent.h" | ||
#include "Curves/CurveLinearColor.h" | ||
#include "ECFCustomTimelineLinearColor.generated.h" | ||
|
||
ECF_PRAGMA_DISABLE_OPTIMIZATION | ||
|
||
UCLASS() | ||
class ENHANCEDCODEFLOW_API UECFCustomTimelineLinearColor : public UECFActionBase | ||
{ | ||
GENERATED_BODY() | ||
|
||
friend class UECFSubsystem; | ||
|
||
protected: | ||
|
||
TUniqueFunction<void(FLinearColor, float)> TickFunc; | ||
TUniqueFunction<void(FLinearColor, float, bool)> CallbackFunc; | ||
TUniqueFunction<void(FLinearColor, float)> CallbackFunc_NoStopped; | ||
FTimeline MyTimeline; | ||
|
||
FLinearColor CurrentValue = FLinearColor::Black; | ||
float CurrentTime = 0.f; | ||
|
||
UPROPERTY(Transient) | ||
UCurveLinearColor* CurveLinearColor = nullptr; | ||
|
||
bool Setup(UCurveLinearColor* InCurveLinearColor, TUniqueFunction<void(FLinearColor, float)>&& InTickFunc, TUniqueFunction<void(FLinearColor, float, bool)>&& InCallbackFunc = nullptr) | ||
{ | ||
TickFunc = MoveTemp(InTickFunc); | ||
CallbackFunc = MoveTemp(InCallbackFunc); | ||
CurveLinearColor = InCurveLinearColor; | ||
|
||
if (TickFunc && CurveLinearColor) | ||
{ | ||
FOnTimelineLinearColor ProgressFunction; | ||
ProgressFunction.BindUFunction(this, FName("HandleProgress")); | ||
MyTimeline.AddInterpLinearColor(CurveLinearColor, ProgressFunction); | ||
|
||
FOnTimelineEvent FinishFunction; | ||
FinishFunction.BindUFunction(this, FName("HandleFinish")); | ||
MyTimeline.SetTimelineFinishedFunc(FinishFunction); | ||
|
||
MyTimeline.PlayFromStart(); | ||
|
||
return true; | ||
} | ||
else | ||
{ | ||
ensureMsgf(false, TEXT("ECF - custom timeline LinearColor failed to start. Are you sure Tick Function and Curve are set properly?")); | ||
return false; | ||
} | ||
} | ||
|
||
bool Setup(UCurveLinearColor* InCurveLinearColor, TUniqueFunction<void(FLinearColor, float)>&& InTickFunc, TUniqueFunction<void(FLinearColor, float)>&& InCallbackFunc = nullptr) | ||
{ | ||
CallbackFunc_NoStopped = MoveTemp(InCallbackFunc); | ||
return Setup(InCurveLinearColor, MoveTemp(InTickFunc), [this](FLinearColor Value, float Time, bool bStopped) | ||
{ | ||
if (CallbackFunc_NoStopped) | ||
{ | ||
CallbackFunc_NoStopped(Value, Time); | ||
} | ||
}); | ||
} | ||
|
||
void Tick(float DeltaTime) override | ||
{ | ||
#if STATS | ||
DECLARE_SCOPE_CYCLE_COUNTER(TEXT("CustomTimelineLinearColor - Tick"), STAT_ECFDETAILS_CUSTOMTIMELINELINEARCOLOR, STATGROUP_ECFDETAILS); | ||
#endif | ||
MyTimeline.TickTimeline(DeltaTime); | ||
} | ||
|
||
void Complete(bool bStopped) override | ||
{ | ||
if (CallbackFunc) | ||
{ | ||
CallbackFunc(CurrentValue, CurrentTime, bStopped); | ||
} | ||
} | ||
|
||
private: | ||
|
||
UFUNCTION() | ||
void HandleProgress(FLinearColor Value) | ||
{ | ||
CurrentValue = Value; | ||
CurrentTime = MyTimeline.GetPlaybackPosition(); | ||
if (HasValidOwner()) | ||
{ | ||
TickFunc(CurrentValue, CurrentTime); | ||
} | ||
} | ||
|
||
UFUNCTION() | ||
void HandleFinish() | ||
{ | ||
if (HasValidOwner()) | ||
{ | ||
Complete(false); | ||
} | ||
MarkAsFinished(); | ||
} | ||
}; | ||
|
||
ECF_PRAGMA_ENABLE_OPTIMIZATION |
Oops, something went wrong.