diff --git a/Content/Luprex/lxGameMode.uasset b/Content/Luprex/lxGameMode.uasset index 0ef2a8c2..d5532c4f 100644 --- a/Content/Luprex/lxGameMode.uasset +++ b/Content/Luprex/lxGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b9eb5234455c1b12e80a9eed6b5a8348795cd8567e5227a60f7290b4083f000 -size 165832 +oid sha256:1470cae3a445cda9c8f78df8b9af59cccff4c34bd190025dd92a2c820459584c +size 164027 diff --git a/Content/Luprex/lxUtilityFunctionsLibrary.uasset b/Content/Luprex/lxUtilityFunctionsLibrary.uasset index 3af30cf0..f1111465 100644 --- a/Content/Luprex/lxUtilityFunctionsLibrary.uasset +++ b/Content/Luprex/lxUtilityFunctionsLibrary.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8365b2c87a615ab893faebe00d0e44d4774c169472ca5d8ce83a174b85e82b5a -size 119675 +oid sha256:485d6236764f8ffa03dc4b23d17f58147b4e415fff22894bf2050a888d11a616 +size 120143 diff --git a/Content/Tangibles/TAN_Character.uasset b/Content/Tangibles/TAN_Character.uasset index 457795ff..814933f4 100644 --- a/Content/Tangibles/TAN_Character.uasset +++ b/Content/Tangibles/TAN_Character.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c5a84148e336b18a658fc7d174a7b9487fd7bc8a7661ac91e386ec4975387d7b -size 329642 +oid sha256:7120f545caec529c725ddf8bed8d920bee650b12e8523ce33a6f60a0939f0492 +size 368674 diff --git a/Content/Tangibles/TAN_StaticMesh.uasset b/Content/Tangibles/TAN_StaticMesh.uasset index 0a684522..1fd549e4 100644 --- a/Content/Tangibles/TAN_StaticMesh.uasset +++ b/Content/Tangibles/TAN_StaticMesh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:450bef454ae7dd0b67054f8ce437e2f2c2d7473f996c520e30868ae28663352a -size 185797 +oid sha256:fbe3996324bb661f531d74df77e6eccec5e63f5709ca361db3e3b757dad0106e +size 187482 diff --git a/Source/Integration/AnimQueue.cpp b/Source/Integration/AnimQueue.cpp index e79aa34f..2be9be7f 100644 --- a/Source/Integration/AnimQueue.cpp +++ b/Source/Integration/AnimQueue.cpp @@ -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(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(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(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(target); + *idstorage = step.Hash; + // Return the correct values. Action = FString(actionfield.S.size(), (const UTF8CHAR*)actionfield.S.data()); bChanged = (step.Hash != oldhash); diff --git a/Source/Integration/ScriptedAnimation.cpp b/Source/Integration/ScriptedAnimation.cpp index dd84d9da..37ec2225 100644 --- a/Source/Integration/ScriptedAnimation.cpp +++ b/Source/Integration/ScriptedAnimation.cpp @@ -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 KeepIDs) { FlxWorldClocks Clocks = UlxScriptedAnimationLibrary::GetAllWorldClocks(WorldContextObject); diff --git a/Source/Integration/ScriptedAnimation.h b/Source/Integration/ScriptedAnimation.h index a6e3894d..b8016f02 100644 --- a/Source/Integration/ScriptedAnimation.h +++ b/Source/Integration/ScriptedAnimation.h @@ -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 diff --git a/luprex/lua/login.lua b/luprex/lua/login.lua index 089bc572..59d224c6 100644 --- a/luprex/lua/login.lua +++ b/luprex/lua/login.lua @@ -84,3 +84,9 @@ function engio.presshotkey(action) 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 + \ No newline at end of file