Character can now move interactively
This commit is contained in:
@@ -279,6 +279,9 @@ FlxAnimTracker::FlxAnimTracker() {
|
||||
void FlxAnimTracker::Clear() {
|
||||
AQ.Empty();
|
||||
Changed = true;
|
||||
AutoFinish = false;
|
||||
AutoFinishAction.Empty();
|
||||
AutoFinishXYZ.Set(0,0,0);
|
||||
}
|
||||
|
||||
void FlxAnimTracker::FinishedAnimation(uint64 hash) {
|
||||
@@ -358,7 +361,6 @@ void FlxAnimTracker::Update(std::string_view encqueue) {
|
||||
while (!newsteps.IsEmpty()) {
|
||||
FlxAnimationStepView step = newsteps.Pop();
|
||||
AQ.EmplaceLast(step.Hash, step.Body);
|
||||
|
||||
}
|
||||
|
||||
// If there are too many animations in AQ, discard
|
||||
@@ -374,6 +376,36 @@ void FlxAnimTracker::Update(std::string_view encqueue) {
|
||||
AQ.PopFirst();
|
||||
}
|
||||
}
|
||||
|
||||
// Autofinish up to one animation.
|
||||
//
|
||||
if (AutoFinish) {
|
||||
for (int i = 0; i < AQ.Num(); i++) {
|
||||
if (!AQ[i].Finished) {
|
||||
if (MatchesAutoFinish(AQ[i])) {
|
||||
AQ[i].Finished = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
AutoFinish = false;
|
||||
AutoFinishAction.Empty();
|
||||
AutoFinishXYZ.Set(0,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
void FlxAnimTracker::SetAutoFinish(const FString &action, const FVector &xyz) {
|
||||
AutoFinish = true;
|
||||
AutoFinishAction = action;
|
||||
AutoFinishXYZ = xyz;
|
||||
}
|
||||
|
||||
bool FlxAnimTracker::MatchesAutoFinish(const FlxAnimationStep &step) {
|
||||
FVector xyz = UlxAnimationStepLibrary::AnimationStepGetVector(step, TEXT("xyz"));
|
||||
if (xyz != AutoFinishXYZ) return false;
|
||||
FString action = UlxAnimationStepLibrary::AnimationStepGetString(step, TEXT("action"));
|
||||
if (action != AutoFinishAction) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
FString FlxAnimTracker::GetCurrentBlueprintName() {
|
||||
@@ -393,6 +425,8 @@ FlxAnimationStep FlxAnimTracker::GetCurrentAnimation() {
|
||||
}
|
||||
}
|
||||
result = AQ.Last();
|
||||
result.Hash = 0;
|
||||
// This next line is a hack. We need the idle step to have a unique
|
||||
// hash. This is a passable way to get a unique hash value.
|
||||
result.Hash += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user