Completed the play-seq animation command for characters
This commit is contained in:
BIN
Content/Luprex/lxGameMode.uasset
LFS
BIN
Content/Luprex/lxGameMode.uasset
LFS
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -76,7 +76,6 @@ static bool SetProperty(const FString& prefix, UObject* obj, const FlxAnimationF
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma optimize("", off)
|
|
||||||
static FStructProperty *FindAnimationStepProperty(UClass *uclass, const FString &prefix) {
|
static FStructProperty *FindAnimationStepProperty(UClass *uclass, const FString &prefix) {
|
||||||
FName nname(prefix + TEXT("Animation Step"));
|
FName nname(prefix + TEXT("Animation Step"));
|
||||||
FStructProperty* fprop = FindFProperty<FStructProperty>(uclass, nname);
|
FStructProperty* fprop = FindFProperty<FStructProperty>(uclass, nname);
|
||||||
@@ -85,7 +84,12 @@ static FStructProperty *FindAnimationStepProperty(UClass *uclass, const FString
|
|||||||
return fprop;
|
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) {
|
void UlxAnimationStepLibrary::UnpackAnimationStep(bool &bChanged, FString &Action, const FlxAnimationStep& step, UObject* target, const FString& prefix) {
|
||||||
bChanged = false;
|
bChanged = false;
|
||||||
Action = TEXT("");
|
Action = TEXT("");
|
||||||
@@ -106,6 +110,12 @@ void UlxAnimationStepLibrary::UnpackAnimationStep(bool &bChanged, FString &Actio
|
|||||||
return;
|
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);
|
FlxAnimationStep* stepstorage = stepproperty->ContainerPtrToValuePtr<FlxAnimationStep>(target);
|
||||||
int64 oldhash = stepstorage->Hash;
|
int64 oldhash = stepstorage->Hash;
|
||||||
|
|
||||||
@@ -134,6 +144,10 @@ void UlxAnimationStepLibrary::UnpackAnimationStep(bool &bChanged, FString &Actio
|
|||||||
// Store the whole step.
|
// Store the whole step.
|
||||||
*stepstorage = step;
|
*stepstorage = step;
|
||||||
|
|
||||||
|
// Store the ID
|
||||||
|
int64 *idstorage = idproperty->ContainerPtrToValuePtr<int64>(target);
|
||||||
|
*idstorage = step.Hash;
|
||||||
|
|
||||||
// Return the correct values.
|
// Return the correct values.
|
||||||
Action = FString(actionfield.S.size(), (const UTF8CHAR*)actionfield.S.data());
|
Action = FString(actionfield.S.size(), (const UTF8CHAR*)actionfield.S.data());
|
||||||
bChanged = (step.Hash != oldhash);
|
bChanged = (step.Hash != oldhash);
|
||||||
|
|||||||
@@ -53,6 +53,23 @@ void UlxScriptedAnimations::AddAnimation(
|
|||||||
Animations.Insert(Result, 0);
|
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)
|
void UlxScriptedAnimations::FadeGarbage(const UObject *WorldContextObject, TArray<int64> KeepIDs)
|
||||||
{
|
{
|
||||||
FlxWorldClocks Clocks = UlxScriptedAnimationLibrary::GetAllWorldClocks(WorldContextObject);
|
FlxWorldClocks Clocks = UlxScriptedAnimationLibrary::GetAllWorldClocks(WorldContextObject);
|
||||||
|
|||||||
@@ -199,6 +199,14 @@ public:
|
|||||||
UObject *WorldContextObject, UAnimSequenceBase* Sequence, double FadeInTime = 0.2, double FadeOutTime = 0.2,
|
UObject *WorldContextObject, UAnimSequenceBase* Sequence, double FadeInTime = 0.2, double FadeOutTime = 0.2,
|
||||||
int64 AnimationStepID=0, bool ContinueWhenPaused=false);
|
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.
|
// Fade all animations whose IDs are not in the 'Keep' list.
|
||||||
//
|
//
|
||||||
// Sometimes, predictive reexecution causes an animation step to
|
// Sometimes, predictive reexecution causes an animation step to
|
||||||
|
|||||||
@@ -84,3 +84,9 @@ function engio.presshotkey(action)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function jp3()
|
||||||
|
tangible.animate(actor, nil, {action="play", seq="jump"})
|
||||||
|
tangible.animate(actor, nil, {action="play", seq="jump"})
|
||||||
|
tangible.animate(actor, nil, {action="play", seq="jump"})
|
||||||
|
end
|
||||||
|
|
||||||
Reference in New Issue
Block a user