Completed the play-seq animation command for characters
This commit is contained in:
@@ -76,7 +76,6 @@ static bool SetProperty(const FString& prefix, UObject* obj, const FlxAnimationF
|
||||
return false;
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
static FStructProperty *FindAnimationStepProperty(UClass *uclass, const FString &prefix) {
|
||||
FName nname(prefix + TEXT("Animation Step"));
|
||||
FStructProperty* fprop = FindFProperty<FStructProperty>(uclass, nname);
|
||||
@@ -85,7 +84,12 @@ static FStructProperty *FindAnimationStepProperty(UClass *uclass, const FString
|
||||
return fprop;
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
static FInt64Property *FindAnimationIDProperty(UClass *uclass, const FString &prefix) {
|
||||
FName nname(prefix + TEXT("Animation ID"));
|
||||
FInt64Property* fprop = FindFProperty<FInt64Property>(uclass, nname);
|
||||
return fprop;
|
||||
}
|
||||
|
||||
void UlxAnimationStepLibrary::UnpackAnimationStep(bool &bChanged, FString &Action, const FlxAnimationStep& step, UObject* target, const FString& prefix) {
|
||||
bChanged = false;
|
||||
Action = TEXT("");
|
||||
@@ -106,6 +110,12 @@ void UlxAnimationStepLibrary::UnpackAnimationStep(bool &bChanged, FString &Actio
|
||||
return;
|
||||
}
|
||||
|
||||
FInt64Property* idproperty = FindAnimationIDProperty(uclass, prefix);
|
||||
if (idproperty == nullptr) {
|
||||
UE_LOG(LogBlueprint, Error, TEXT("UnpackAnimationStep: Target object does not have a variable named: '%s Animation ID'"), *prefix);
|
||||
return;
|
||||
}
|
||||
|
||||
FlxAnimationStep* stepstorage = stepproperty->ContainerPtrToValuePtr<FlxAnimationStep>(target);
|
||||
int64 oldhash = stepstorage->Hash;
|
||||
|
||||
@@ -134,6 +144,10 @@ void UlxAnimationStepLibrary::UnpackAnimationStep(bool &bChanged, FString &Actio
|
||||
// Store the whole step.
|
||||
*stepstorage = step;
|
||||
|
||||
// Store the ID
|
||||
int64 *idstorage = idproperty->ContainerPtrToValuePtr<int64>(target);
|
||||
*idstorage = step.Hash;
|
||||
|
||||
// Return the correct values.
|
||||
Action = FString(actionfield.S.size(), (const UTF8CHAR*)actionfield.S.data());
|
||||
bChanged = (step.Hash != oldhash);
|
||||
|
||||
@@ -53,6 +53,23 @@ void UlxScriptedAnimations::AddAnimation(
|
||||
Animations.Insert(Result, 0);
|
||||
}
|
||||
|
||||
double UlxScriptedAnimations::CalculateTimeLeft(UObject *WorldContextObject, int64 AnimationID)
|
||||
{
|
||||
double max = 0.0;
|
||||
FlxWorldClocks Clocks = UlxScriptedAnimationLibrary::GetAllWorldClocks(WorldContextObject);
|
||||
for (int i = 0; i < Animations.Num(); i++)
|
||||
{
|
||||
const FlxScriptedAnimation &Anim = Animations[i];
|
||||
if (Anim.AnimationStepID == AnimationID)
|
||||
{
|
||||
double Current = Anim.ChooseCorrectClock(Clocks);
|
||||
double TimeLeft = Anim.ClampedTimeLeft(Current);
|
||||
if (TimeLeft > max) max = TimeLeft;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
void UlxScriptedAnimations::FadeGarbage(const UObject *WorldContextObject, TArray<int64> KeepIDs)
|
||||
{
|
||||
FlxWorldClocks Clocks = UlxScriptedAnimationLibrary::GetAllWorldClocks(WorldContextObject);
|
||||
|
||||
@@ -199,6 +199,14 @@ public:
|
||||
UObject *WorldContextObject, UAnimSequenceBase* Sequence, double FadeInTime = 0.2, double FadeOutTime = 0.2,
|
||||
int64 AnimationStepID=0, bool ContinueWhenPaused=false);
|
||||
|
||||
// Calculate time left for a given animation.
|
||||
//
|
||||
// If there are multiple animations playing with the given ID,
|
||||
// returns the MAX time left.
|
||||
//
|
||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Scripted Animations", meta=(WorldContext = "WorldContextObject"))
|
||||
double CalculateTimeLeft(UObject *WorldContextObject, int64 AnimationID=0);
|
||||
|
||||
// Fade all animations whose IDs are not in the 'Keep' list.
|
||||
//
|
||||
// Sometimes, predictive reexecution causes an animation step to
|
||||
|
||||
Reference in New Issue
Block a user