diff --git a/Source/UESVON/Private/BTTask_SVONMoveTo.cpp b/Source/UESVON/Private/BTTask_SVONMoveTo.cpp index e7d6751..1c2b02d 100644 --- a/Source/UESVON/Private/BTTask_SVONMoveTo.cpp +++ b/Source/UESVON/Private/BTTask_SVONMoveTo.cpp @@ -16,8 +16,7 @@ UBTTask_SVONMoveTo::UBTTask_SVONMoveTo(const FObjectInitializer& ObjectInitializ : Super(ObjectInitializer) { NodeName = "SVON Move To"; - bUseGameplayTasks = GET_AI_CONFIG_VAR(bEnableBTAITasks); - bNotifyTick = !bUseGameplayTasks; + bNotifyTick = ~bUseGameplayTasks; bNotifyTaskFinished = true; AcceptableRadius = GET_AI_CONFIG_VAR(AcceptanceRadius); @@ -314,54 +313,35 @@ EBTNodeResult::Type UBTTask_SVONMoveTo::PerformMoveTask(UBehaviorTreeComponent& if (MoveReq.IsValid()) { - if (GET_AI_CONFIG_VAR(bEnableBTAITasks)) + UAITask_SVONMoveTo* MoveTask = MyMemory->Task.Get(); + const bool bReuseExistingTask = (MoveTask != nullptr); + + MoveTask = PrepareMoveTask(OwnerComp, MoveTask, MoveReq); + if (MoveTask) { - UAITask_SVONMoveTo* MoveTask = MyMemory->Task.Get(); - const bool bReuseExistingTask = (MoveTask != nullptr); + MyMemory->bObserverCanFinishTask = false; - MoveTask = PrepareMoveTask(OwnerComp, MoveTask, MoveReq); - if (MoveTask) + if (bReuseExistingTask) { - MyMemory->bObserverCanFinishTask = false; - - if (bReuseExistingTask) + if (MoveTask->IsActive()) { - if (MoveTask->IsActive()) - { - UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s"), *GetNodeName(), *MoveTask->GetName()); - MoveTask->ConditionalPerformMove(); - } - else - { - UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s, but task is not active - handing over move performing to task mechanics"), *GetNodeName(), *MoveTask->GetName()); - } + UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s"), *GetNodeName(), *MoveTask->GetName()); + MoveTask->ConditionalPerformMove(); } else { - MyMemory->Task = MoveTask; - UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' task implementing move with task %s"), *GetNodeName(), *MoveTask->GetName()); - MoveTask->ReadyForActivation(); + UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s, but task is not active - handing over move performing to task mechanics"), *GetNodeName(), *MoveTask->GetName()); } - - MyMemory->bObserverCanFinishTask = true; - NodeResult = (MoveTask->GetState() != EGameplayTaskState::Finished) ? EBTNodeResult::InProgress : MoveTask->WasMoveSuccessful() ? EBTNodeResult::Succeeded : EBTNodeResult::Failed; } - } - else - { - FPathFollowingRequestResult RequestResult = MyController->MoveTo(MoveReq); - if (RequestResult.Code == EPathFollowingRequestResult::RequestSuccessful) - { - MyMemory->MoveRequestID = RequestResult.MoveId; - WaitForMessage(OwnerComp, UBrainComponent::AIMessage_MoveFinished, RequestResult.MoveId); - WaitForMessage(OwnerComp, UBrainComponent::AIMessage_RepathFailed); - - NodeResult = EBTNodeResult::InProgress; - } - else if (RequestResult.Code == EPathFollowingRequestResult::AlreadyAtGoal) + else { - NodeResult = EBTNodeResult::Succeeded; + MyMemory->Task = MoveTask; + UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' task implementing move with task %s"), *GetNodeName(), *MoveTask->GetName()); + MoveTask->ReadyForActivation(); } + + MyMemory->bObserverCanFinishTask = true; + NodeResult = (MoveTask->GetState() != EGameplayTaskState::Finished) ? EBTNodeResult::InProgress : MoveTask->WasMoveSuccessful() ? EBTNodeResult::Succeeded : EBTNodeResult::Failed; } } } diff --git a/Source/UESVON/Private/SVONVolume.cpp b/Source/UESVON/Private/SVONVolume.cpp index 6b680ac..833ea42 100644 --- a/Source/UESVON/Private/SVONVolume.cpp +++ b/Source/UESVON/Private/SVONVolume.cpp @@ -419,7 +419,7 @@ void ASVONVolume::Serialize(FArchive& Ar) float ASVONVolume::GetVoxelSize(layerindex_t aLayer) const { - return (myExtent.X / FMath::Pow(2, myVoxelPower)) * (FMath::Pow(2.0f, aLayer + 1)); + return (myExtent.X / FMath::Pow(2.f, myVoxelPower)) * (FMath::Pow(2.0f, aLayer + 1)); } bool ASVONVolume::IsReadyForNavigation() const @@ -429,12 +429,12 @@ bool ASVONVolume::IsReadyForNavigation() const int32 ASVONVolume::GetNumNodesInLayer(layerindex_t aLayer) const { - return FMath::Pow(FMath::Pow(2, (myVoxelPower - (aLayer))), 3); + return FMath::Pow(FMath::Pow(2.f, (myVoxelPower - (aLayer))), 3); } int32 ASVONVolume::GetNumNodesPerSide(layerindex_t aLayer) const { - return FMath::Pow(2, (myVoxelPower - (aLayer))); + return FMath::Pow(2.f, (myVoxelPower - (aLayer))); } void ASVONVolume::BeginPlay()